Page 1 of 1

equivalent to "Set Virtual On/Off Device State" via python

PostPosted: Fri Feb 12, 2021 6:05 pm
by tcherna
I'm wondering if there is a way to script setting the device state to on or off via a python script (Server Actions->Script and File Actions) vs Device Actions->Virtual Device Controls

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 1:31 am
by neilk
Take a look at https://wiki.indigodomo.com/doku.php?id=indigo_6_documentation:plugin_scripting_tutorial that should point you in the right direction, with the first example.

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 12:40 pm
by tcherna
Right, but that page talks about how to turn the device on, which I think is different then setting the internal state of the virtual device (otherwise why would there be a special command for it). Specifically, calling the on method would activate the on action group, but setting its internal state does not. This would be the shortcut to setting the variable, if I was using a status variable.

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 1:03 pm
by jay (support)
You can script the UI action to set a Virtual Device state. And, no, you aren't crazy, I realized that it was missing from the docs to I just added it... ;)

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 1:09 pm
by tcherna
There is an extra & in the link ;)

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 1:17 pm
by tcherna
Thanks Jay. A follow up question. Is it more efficient to create a virtual device with a named variable, or an implicit one (and use the above scripting to set it)?

Re: equivalent to "Set Virtual On/Off Device State" via pyth

PostPosted: Sat Feb 13, 2021 1:34 pm
by jay (support)
tcherna wrote:
There is an extra & in the link ;)


Fixed, thanks for the heads up.

tcherna wrote:
Thanks Jay. A follow up question. Is it more efficient to create a virtual device with a named variable, or an implicit one (and use the above scripting to set it)?


I suppose using the action (via UI or script) is maybe slightly more efficient since we wouldn't have to process variable changes, but the plugin is already receiving all variable updates anyway so the actual processing is negligible.