But with the following script i get stuck on the filter and forEach function as the lights aren't turned off.
Help is appreciated
Code: Select all
local w2k1 = 127 --wandschakelaar 2 knops knop 1
local w2k2 = 128 --wandschakelaar 2 knops knop 2
local w2k2dubbel = 137 --wandschakelaar 2 knops knop 2 dubbelklik
local eettafel = 130
local wandlamp = 93
local lichtstraat = 88
local wkhue = 8
local keuken_spots = 73
local kookeiland = 78
local spotshal = 97
return
{
on =
{
devices =
{
w2k1,
w2k2,
w2k2dubbel
},
},
logging =
{
level = domoticz.LOG_INFO, -- set to LOG_ERROR when tested and OK
marker = "Script Woonkamer",
},
execute = function(dz, item)
w2k1 = dz.devices(w2k1)
w2k2 = dz.devices(w2k2)
w2k2dubbel = dz.devices(w2k2dubbel)
wandlamp = dz.devices(wandlamp)
lichtstraat = dz.devices(lichtstraat)
wkhue = dz.devices(wkhue)
keuken_spots = dz.devices(keuken_spots)
kookeiland = dz.devices(kookeiland)
eettafel = dz.devices(eettafel)
spotshal = dz.devices(spotshal)
lampenwk = {wandlamp, lichtstraat, wkhue, keuken_spots, kookeiland} --alle lampen in woonkamer
--Verlichting hal
if item == w2k1 then
spotshal.switchOn()
end
if item == w2k2 then
spotshal.switchOff()
end
--Verlichting woonkamer alles uit
if item == w2k2dubbel then
dz.devices().filter(lampenwk).forEach(function(device)
device.switchOff().checkFirst()
end)
dz.openURL({url = 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=130&switchcmd=Off'}) --workaround eettafel
end
end
}