I have read the complete tutorial on the Wiki "DzVents: next generation LUA scripting" and have seen the complete dzVents starters Video on Youtube, made by Dannybloe. Great video btw!
One thing that is not clear to me: how can I use variables of the triggering device for other devices. My case:
I have 3 identical Ikea Tradfri bulbs, connected via zigbee2mqtt. I want to copy all changes of bulb1 to bulb2 and bulb3. I can copy the on/off status, but not the light temperature and the dim percentages.
Currently my script is:
Code: Select all
return {
on = {
devices = {
'Tafellamp1'
}
},
execute = function(domoticz, device)
domoticz.log('Tafellamp1 geactiveerd')
domoticz.log(device.state)
if (device.state == 'Off') then
domoticz.devices('Tafellamp3').switchOff()
domoticz.devices('Tafellamp2').switchOff()
domoticz.log('tafellampen zijn uit', domoticz.LOG_INFO)
elseif (device.state == 'On') then
domoticz.log(color, domoticz.LOG_INFO)
domoticz.devices('Tafellamp1').getkelvinlevel(kelvin)
domoticz.devices('Tafellamp2').switchOn()
domoticz.devices('Tafellamp3').switchOn()
domoticz.devices('Tafellamp2').dimTo(percentage)
domoticz.devices('Tafellamp2').setKelvin(kelvin)
domoticz.devices('Tafellamp3').dimTo(percentage)
domoticz.devices('Tafellamp3').setKelvin(kelvin)
domoticz.log('tafellampen zijn aan', domoticz.LOG_INFO)
end
end
}
Code: Select all
lua:16: attempt to call field 'getkelvinlevel' (a nil value)