Page 1 of 1

Differences in Lua commandArray 'UpdateDevice' and OpenURL 'udevice'

Posted: Saturday 13 February 2016 10:41
by Toni
I'm writing some event code based on virtual switches. Now I'm wondering about an inconsistency about the firing of subsequent events. I.e. my event script should cause device updates which fire other events.

So, if my Lua event script updates the status of an another device, I can do it in two ways: But why only the second alternative causes an event to be fired on the device I'm updating?

Re: Differences in Lua commandArray 'UpdateDevice' and OpenURL 'udevice'

Posted: Saturday 13 February 2016 12:52
by Siewert308SW
What about the following in for example a script_device_something.lua

When something triggers Lights to go ON then do something:
if devicechanged['Lights'] == 'On' then
commandArray['Do_Something']='On'
end

When something triggers Lights to go OFF then do something
if devicechanged['Lights'] == 'Off' then
commandArray['Do_Something']='On'
end

When something triggers Lights to go ON or OFF then do something
if devicechanged['Lights'] then
commandArray['Do_Something']='On'
end

Or do i misunderstand you?

Re: Differences in Lua commandArray 'UpdateDevice' and OpenURL 'udevice'

Posted: Saturday 13 February 2016 13:25
by Toni
It's not that simple. What I want to update in my event script is a set of multiselectors, and I want the multiselector event to fire when the multiselector value is updated through the event script.

So I need to use the "commandArray['UpdateDevice'] = idx|nValue|sValue" format, instead of the "commandArray['Devicename'] = status". The UpdateDevice command does not fire an event on the updated device.