I've a Blockly script that sends a notification when the front- or backdoor is opened, while the switch "Beveiliging" has status ON
In dzVents I've made the following config:
Code: Select all
return {
on =
{
devices = {
'Sensor Voordeur',
'Sensor Achterdeur',
'Beveiliging'
}
},
execute = function(domoticz, device)
if
{(device.name == 'Sensor Voordeur' and device.state == 'Open') and
(device.name == 'Beveiliging' and device.state == 'On')}
then
domoticz.notify('Beveiliging', 'De voordeur wordt geopend')
domoticz.log('Voordeur wordt geopend!!')
elseif
{(device.name == 'Sensor Achterdeur' and device.state == 'Open') and
(device.name == 'Beveiliging' and device.state == 'On')}
then
domoticz.notify('Beveiliging', 'De achterdeur wordt geopend')
domoticz.log('Achterdeur wordt geopend!!')
end
end
}
In the Domoticz log (and also the notification) I get for both frontdoor (voordeur) as for backdoor (achterdeur) "Beveiliging: De voordeur wordt geopend"
Domoticz Log:
Code: Select all
2018-01-26 10:20:24.607 dzVents: Info: Handling events for: "Sensor Achterdeur", value: "Open"
2018-01-26 10:20:24.607 dzVents: Info: ------ Start internal script: Sensoren: Device: "Sensor Achterdeur (Aeon Labs Z-Stick GEN5)", Index: 559
2018-01-26 10:20:24.607 dzVents: Info: Voordeur wordt geopend!!
2018-01-26 10:20:24.607 dzVents: Info: ------ Finished Sensoren
2018-01-26 10:20:24.680 EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2018-01-26 10:20:26.113 dzVents: Info: Handling events for: "Sensor Achterdeur", value: "Closed"
2018-01-26 10:20:26.113 dzVents: Info: ------ Start internal script: Sensoren: Device: "Sensor Achterdeur (Aeon Labs Z-Stick GEN5)", Index: 559
2018-01-26 10:20:26.113 dzVents: Info: Voordeur wordt geopend!!
2018-01-26 10:20:26.113 dzVents: Info: ------ Finished Sensoren
2018-01-26 10:20:26.191 EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua