I have a script that checks Doors and Windows and send a message if they are open and the Air Con is on, This works fine, and to date I have just checked the outside openings.
I want to merge two devices, as I am only concerned if both devices are open, if the internal door is closed then the air can't reach the open window.
So, I thought I could just build a dummy device, and check that, but as my function calls the domoticz.device it doesn't like that, just after an easy way to do this without rewriting my function.
my previous array of devices looks like this.
Code: Select all
local openings = {
[FRONTDOOR_DEVICE]=true,
[BACKDOOR_DEVICE]=true,
[LAUNDRYWINDOW_DEVICE]=true,
[PLAYROOMWINDOW_DEVICE]=true
}
Code: Select all
domoticz.devices().filter( function(device)
return (openings[device.name] == true)
end).forEach( function(device)
if (device.state == "Open") then
if LOGGING then domoticz.log("Turning ON the Openings Light as "..device.name.." is "..device.state, domoticz.LOG_FORCE) end
domoticz.setScene('Yellow Light', 'On')
domoticz.devices(AC_DOORLIGHT).switchOn().checkFirst()
open_count = open_count + 1
end
end)
Code: Select all
local playroom = {
name = "Playroom Window and Door"
}
if (domoticz.devices(PLAYROOMWINDOW_DEVICE).state == "Open" and domoticz.devices(PLAYROOMDOOR_DEVICE).state == "Open") then
playroom.state = "Open"
else
playroom.state = "Closed"
end
Thanks,
Wob