UI Simple Equivalent as a Plugin? (Monitor all devices for changes)

I have a Perl script running on a separate computer that uses the model shown in “UI Simple” to monitor all device changes on the Vera and sends on appropriate xPL events.

I’m trying to determine if there is a simple way to do something similar in a plugin. I would need to have the plugin code called if any device changes (for instance, a light was turned on) so I could send out an xPL event for the state change.

Not sure if this is easy to do or if it would be too taxing on the Vera?

This is very simple. Just use the luup.variable_watch function. This is exacty what dataMine does - it sets up a number of watches to watch whatever variables you want, and then waits for Vera to call the plugin. It then just write the data to a file. You need to do the same thing, but produce an xPL message instead of writing to disk.

Chris

Your right… pretty simple solution!

Thanks!

Can this be used to set a variable to whatever light in the house was turned on last?

For instance I have a scene that sets the dimming level of the device turned on after sunset. The problem is, I need to create a scene for every device I want it to work with, and that’s 40 scenes. Can I simply create a single scene, and replace the device ID, with the variable created with this? In theory, I could use the one scene and this will catch every dimmable device being turned on, correct?

There may be better ways of doing this, but you could (reasonably easily) write a plugin that set up a watch for all dimmable devices, and then exposed a service providing information on the last swtich.

What is the lag of that watch? How long does it take to realize that the state of a light, for example, has changed?

Depends on what devices you are using it with. Not all devices report status back to Vera. If they do, the response would be ‘instant’. If they don’t, it relies on the polling process to pick up the change (which takes, say, minutes).

The GE dimmers I use are instantly reported it seems. As long as the dimming isn’t adjusted too fast or instant on, it’s caught.

@Chris do you have a working plugin?

Has anyone created this [quote=“Chris, post:5, topic:169153”]There may be better ways of doing this, but you could (reasonably easily) write a plugin that set up a watch for all dimmable devices, and then exposed a service providing information on the last swtich.[/quote]

Thanks!

Do you have any of them in a 3-way setup; if so, does it work with both switches?

The lag with the variable watch function is minimal - milliseconds. As stated already, the issue is how the change is reported to Vera. Some devices report their status automatically when it changes, so this will again have a very short lag, but others only get updated when Vera polls their status - this seems (on my config) to be about every minute.

The dataMine plugin does exactly this. It sets up the watch with the following call

luup.variable_watch('watchVariable', v.Service, v.Variable, tonumber(v.Device))

If you just itterated through each device with service set to “urn:upnp-org:serviceId:SwitchPower1”, and variable set to “Status”, then this might work (I don’t know what happens if the device doesn’t support this service - I would hope it gets ignored, but I’m not sure). There are functions available to find if a device supports a particular service, but I understand that they aren’t reliable (Luup Lua extensions - MiOS).

then has the function watchVariable defined as follows

function watchVariable(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
This function gets called pretty quickly after Vera becomes aware of the change.

Do you have any of them in a 3-way setup; if so, does it work with both switches?[/quote]

@oTi@,
It works with the vizia 4 zone controller, and the scene I assigned to the button simply turns my chandelier ON, and it still works that way ;D. I really haven’t tried it on the 3 ways that are wired yet. I’ll give it a run for you asap!

@Chris,
So I create the dataMine device, go through and set the variable for all the respective dimmers, let’s say we call the variable “lastActiveDimmer”
Create the scene that does the dimming based on time of day, then simply reference the dataMine device and the variable? if so, What would the trigger be?

Right, that’s the sunny day scenario. When you hit the zone controller button, Vera is notified, and she then turns on your GE stuff. Obviously she’s aware of the state change in this case.

However, the GE stuff doesn’t talk to Vera when you change state locally. Vera does pick up on it though, in some cases. You will probably find that it doesn’t work from auxiliary switches (i.e., those that are not the primary switch in a 3-way, etc., setups) and it doesn’t work from switches that are out of direct radio reach (and probably doesn’t work reliably for switches that are on the edge).

There are some prior topics on that, where folks have one GE follow another and find that there are limitations.

So I create the dataMine device, go through and set the variable for all the respective dimmers, let's say we call the variable "lastActiveDimmer" Create the scene that does the dimming based on time of day, then simply reference the dataMine device and the variable? if so, What would the trigger be?
No, sorry. I was simply using the dataMine source as an example of how you could write a plugin that monitored all the status variables for switches, or dimmer levels (oe anything else). That would allow you to have a function that gets called when these things change, but I think you need another plugin to do that. Once you've got this plugin, I think you could use it to trigger your event.

I don’t know if you can use these functions directly in scenes - I don’t think do, but I haven’t tried anything fancy in a scene yet.