Generally speaking, changing Status
or Target
directly using set_variable
on a switch is the wrong thing to do. That’s because it does not actually cause action on the switch. If this was a Z-Wave switch, changing the value of Target
would not change the on-off state of the switch, and in fact, when the switch is next polled or a Vera restart occurs, the value is likely to go back to the switch’s reported value. Luup’s driver and the switch itself control the value of Target
and Status
, and the way to ask a switch to (a) change its hardware state, and (b) simultaneously update the state of Target
and Status
, is to use the action. For a Z-Wave switch, the action causes the mesh dialog with the switch. During that dialog with the switch hardware, Target
will be set by Luup to reflect the new desired setting. If/when the switch accomplishes that wish, it will send a report back to Luup which will then update Status
accordingly. This is also the way that dimming levels work on dimmers, and similar values on other devices. To put that all in a shorter description: setting the variable will not change the associated physical device (if there is one); calling the action initiates communication with the associated physical device and updates the variables to reflect both goal and actual.
Virtual switches work the same way. If you call the SetTarget
action, it will set the desired Target
and Status
values. In the case of a virtual switch, that may not be different, in your view, from using set_variable
, because there is no associated physical device (i.e. that’s why it’s virtual), but in fact there is background logic in the Switchboard plugin (you indicated you are using it, and I wrote it so I can speak to its functions) to handle the additional features like its delay off timer, etc., that will only function when the action is used.
This model comes from UPnP, by the way. Generally in UPnP, you can get values, but you never set them; you use actions to do things and the actions do the setting of values.
If call_action
has never worked for you, the most common problem is that you have the parameters incorrect. You have to be very strict with case of the parameter names, and there are some actions/parameters that have inconsistencies in case usage. The parameters also have to be passed in an object/table (as shown in my example), so the syntax is awkward and sometimes troublesome for the new players. The second most common problem I would estimate to be incorrect service ID.
You can go on using set_variable
if you wish, but do not be surprised if it doesn’t work for any Z-Wave switch, or physical switches driven by other plugins, or if you decide to use some of the other switch features of virtual switches in Switchboard and they don’t work for you. But being consistent and learning to use the actions will work for both virtual and physical devices, and so that’s my recommendation.