I want to change my current dzvents scripts to the following scenario. And I could really use some help to get the logic in order. Since I geuss my current script doesn't function the way I designed it and my use case has changed a bit.
Scenario
- zwave - 30 seconds blink strobe only
- turn off zwave switch
- change zwave config
- wait a second (or maybe more) until the config has changed and been acknowledged by domoticz
- turn on zwave (with strobe and alarm siren) max 2 minutes.
- The limit of 2 minutes has to do with jurisdiction. You're only allowed to have a siren on the outside for a short period of time.
- I should be able to turn off the alarm at any moment in time.
Code: Select all
-- local alarm_status = 'ALARMSTATUS'
-- local alarm_switch = 'Z-wave Alarm'
-- local alarm_state = 'woonveilig - Bedieningspaneel'
-- # Zet het buitenalarm aan als er een alarm actie is
-- was .forMin(5).afterSec(10)
-- dzVents 2.2.0 versie
-- help
-- https://github.com/domoticz/domoticz/blob/9f75e45f994f87c8d8ce9cb39eaab85886df0be4/scripts/dzVents/documentation/README.md
-- domoticz.devices(123).switchOn().forMin(5).afterSec(10)
-- if lastUpdate.secondsAgo() then
-- local led1 = domoticz.devices('$Vloer-LED-R')
return {
active = true,
on = {
devices = {
'ALARMSTATUS'
}
},
execute = function(domoticz, alarmSwitch)
local alarm_status = domoticz.devices('ALARMSTATUS')
local alarm_switch = domoticz.devices('Z-wave Alarm')
local alarm_state = domoticz.devices('woonveilig - Bedieningspaneel')
if (alarmSwitch.state == 'On' and alarm_state.state == 'On' ) then
alarm_state.switchOn().forMin(10).afterSec(15)
domoticz.log('Buitenalarm gaat over 10 seconden aan', domoticz.LOG_DEBUG)
-- notify(subject, message, priority, sound, extra, subsystem)
domoticz.notify('Alarm', 'Buitenalarm gaat over 10 seconden aan', domoticz.PRIORITY_EMERGENCY, domoticz.SOUND_NONE, domoticz.EXTRA_NONE,domoticz.NSS_PUSHOVER)
domoticz.notify('Alarm', 'Buitenalarm gaat over 10 seconden aan', domoticz.PRIORITY_EMERGENCY, domoticz.SOUND_NONE, domoticz.EXTRA_NONE,domoticz.NSS_PUSHBULLET)
-- domoticz.devices('Z-wave Alarm').switchOff().afterSec(130)
-- domoticz.devices('Z-wave Alarm').switchOn().afterSec(10)
end
end
}
Code: Select all
#!/bin/bash
#### Laat het buitenalarm afgaan.
## Eerst 30 seconden LED's flikkeren (strobe)
## Dan stop zetten
##
# 32 rflink433 008A562A 1 Stroom z-wave alarm buiten Light/Switch TriState On - - 2019-04-08 18:31:26
# 35 zwave 00000B01 1 Z-wave Alarm Light/Switch Switch Off
IDX_alarm=35
IDX_power=32
aanzetten()
{
#### TODO: # Check of de instellingen goed staan.
# We zetten de instellingen goed
#Strobe only - will not automatically stop
curl 'http://127.0.0.1:8080/json.htm?type=command¶m=applyzwavenodeconfig&idx=9&valuelist=1_U3Ryb2JlIE9ubHk%3D_2_V2lsbCBOb3QgQXV0b21hdGljYWxseSBTdG9w_'
# Alarm aan; alleen strobe
curl -s 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=$IDX_alarm&switchcmd=On'
sleep 30
curl -s 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=$IDX_alarm&switchcmd=Off'
sleep 1
#All enabled - 120s
curl 'http://127.0.0.1:8080/json.htm?type=command¶m=applyzwavenodeconfig&idx=9&valuelist=1_QWxsIEVuYWJsZQ%3D%3D_2_MTIwcw%3D%3D_'
sleep 1
curl -s 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=$IDX_alarm&switchcmd=On'
}
uitzetten()
{
curl -s 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=$IDX_alarm&switchcmd=Off'
sleep 1
curl -s 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=$IDX_power&switchcmd=Off'
}
case "${1}" in
start)
aanzetten
stop)
uitzetten
*)
echo "Usage: ${0} {start|stop}" >&2
exit 1
;;
esac
exit 0