I want to make a single script to handle all my notifications and need (at the moment) 3 seperate groups for this (doors/windows, motion sensors and lights) to display the right message for each group.
Unfortunately only the first listed devices will work with the code below.
i didn't see any other script with this kind a code so i think that's the reason it's not working
I tried to convert
Code: Select all
-- Send message when sensor triggered
return {
on = {
devices = {
'Voordeur',
'Keukendeur',
'Slaapkamerraam',
'Voordeursensor',
'Achtertuinsensor',
'Voordeurlamp',
'Achtertuinverlichting',
'TESTdoor',
'TESTmotion'
}
},
execute = function(domoticz, item)
local tijd = os.date("%X")
local MAGNOmodus = domoticz.devices('MAGNOmodus')
local lights = domoticz.devices('Voordeurlamp','Achtertuinverlichting','Woonkamer Spot')
local DWsensors = domoticz.devices('Voordeur','Keukendeur','Slaapkamerraam','TESTdoor')
local MOsensors = domoticz.devices('Voordeursensor','Achtertuinsensor','TESTmotion')
domoticz.log(item.name.." triggerd")
if MAGNOmodus.state == 'Standaard' then
if (DWsensors.active) then
domoticz.notify(item.name,"Geopend om "..tijd,domoticz.PRIORITY_NORMAL)
end
if (lights.active) then
domoticz.notify(item.name,"Ingeschakeld om "..tijd,domoticz.PRIORITY_NORMAL)
end
end
if MAGNOmodus.state == 'Afwezig' then
if (DWsensors.active) then
domoticz.notify(item.name,"Is geopend om "..tijd.."!",domoticz.PRIORITY_EMERGENCY)
end
if (MOsensors.active) then
domoticz.notify(item.name,"Beweging gedetecteerd om "..tijd.."!",domoticz.PRIORITY_MODERATE)
end
end
end
} DEBUG with TESTdoor switched
Code: Select all
---- Start internal script: 04 SEN_NOTIFYv1: Device: "TESTdoor (VIRTUAL)", Index: 779
2019-04-15 18:43:07.184 Status: dzVents: Debug: Processing device-adapter for MAGNOmodus: Switch device adapter
2019-04-15 18:43:07.186 Status: dzVents: Debug: Processing device-adapter for Voordeurlamp: Switch device adapter
2019-04-15 18:43:07.188 Status: dzVents: Debug: Processing device-adapter for Voordeur: Switch device adapter
2019-04-15 18:43:07.189 Status: dzVents: Debug: Processing device-adapter for Voordeursensor: Switch device adapter
2019-04-15 18:43:07.189 Status: dzVents: Info: TESTdoor triggerd
2019-04-15 18:43:07.189 Status: dzVents: Info: ------ Finished 04 SEN_NOTIFYv1