I am trying to dim all the devices in a specific scene by using the method .devices() as per the documentation at https://www.domoticz.com/wiki/DzVents:_ ... ting#Scene
Maybe I am doing this one wrong, but I always receive the error that I am trying to call a nil value with the foreach.
Can someone point out to me what I am doing wrong?
Code: Select all
--[[
Prerequisites
==================================
Domoticz v3.8837 or later (dzVents version 2.4 or later)
User Variable named UV_ToonIP type string, that holds the internal Toon IP
Dummy switches that match the variables beneath
CHANGE LOG: See https://github.com/Geo-Ron/dzVents/commits/master/dzToon.lua
]] --
local scriptVersion = '1.0.1'
return {
active = true,
logging = {
level = domoticz.LOG_DEBUG, -- Uncomment to override the dzVents global logging setting
marker = 'dzIkeaSwitch1 '..scriptVersion
},
on = {
devices = {
'Zigbee2MQTT - 0x842e14fffe45b570 (Left Arrow)',
'Zigbee2MQTT - 0x842e14fffe45b570 (Right Arrow)'
}
},
execute = function(domoticz, item)
--item.dump()
if (item.name == 'Zigbee2MQTT - 0x842e14fffe45b570 (Left Arrow)' and item.levelName == 'Click') then
domoticz.scenes('TV Kijken').switchOn()
end
if (item.name == 'Zigbee2MQTT - 0x842e14fffe45b570 (Left Arrow)' and item.levelName == 'Hold') then
domoticz.scenes('TV Kijken').dump()
domoticz.scenes('TV Kijken').devices().foreach(
function(device)
domoticz.log('dimming the light.'..device.name..' to '.. device.level/2, domoticz.LOG_DEBUG)
device.dump()
end
)
end
end
}