use device name in Variable
Posted: Saturday 03 April 2021 18:52
Hi all,
I have this dzVent script to control the (start) level of the dimmed lights
The script works as it is (when using Dimmer 1 ) but I have now 9 dimmers which I want to control all in the same way..
I could ofcourse create 9 scripts but is it possible to use the device name in calling domoticz variable?
here is my script:
so basically i want something like : dz.variables('devicename').value
Thanks
I have this dzVent script to control the (start) level of the dimmed lights
The script works as it is (when using Dimmer 1 ) but I have now 9 dimmers which I want to control all in the same way..
I could ofcourse create 9 scripts but is it possible to use the device name in calling domoticz variable?
here is my script:
Code: Select all
return
{
on =
{
devices =
{
'Dimmer 1',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'dimmer',
},
execute = function(dz, item)
local PreviousState = dz.variables('Dimmer_1').value
if item.sValue == 'On' and dz.time.matchesRule('at 21:00-02:00') and (PreviousState) == 'Off' then
dz.variables('Dimmer_1').set('On')
item.dimTo(20).silent()
elseif item.sValue == 'On' and dz.time.matchesRule('at 11:00-20:59') and (PreviousState) == 'Off' then
dz.variables('Dimmer_1').set('On')
item.dimTo(70).silent()
elseif item.sValue == 'Off' and (PreviousState) ~= 'Off' then
dz.variables('Dimmer_1').set('Off')
end
end
}
Thanks