I want to flash some lights if the door is left open for x minutes.
I get the lights flashing with the code below, but only when lights are off.
I tried to set them off but the lamps are not reacting and are not set to off.
Someone any clue?
Code: Select all
return {
on = {
timer = {
'every minute', -- causes the script to be called every minute
},
},
execute = function(domoticz, timer)
domoticz.log('======================== ', domoticz.LOG_INFO)
domoticz.log('======================== ', domoticz.LOG_INFO)
domoticz.log('======================== ', domoticz.LOG_INFO)
domoticz.log('Diepvries trigger started ' .. timer.trigger, domoticz.LOG_INFO)
local diepVriesDeur = domoticz.devices('DiepvriesSensor')
local sonoffKeuken = domoticz.devices('sonoff keuken')
local sonoffKeukenKoof = domoticz.devices('sonoff keukenkoof')
--first turn off the lights if the are on
if (sonoffKeuken.active) then
sonoffKeuken.switchOff().silent()
end
if (sonoffKeukenKoof.active) then
sonoffKeukenKoof.switchOff().silent()
end
if (diepVriesDeur.state == 'Open' and diepVriesDeur.lastUpdate.minutesAgo > 1) then -- > 1 to be change to a higher value when script is final
domoticz.log('Dievries trigger: hij staat open, laat de lampen knipperen... ', domoticz.LOG_INFO)
--domoticz.notify('Dievriesdeur alert', 'De diepvriesdeur staat al meer dan 5 minuten open!', domoticz.PRIORITY_HIGH)
-- flash a light for 5 times
sonoffKeuken.switchOn().forSec(1).repeatAfterSec(1, 5)
sonoffKeukenKoof.switchOn().forSec(1).repeatAfterSec(1, 5)
end
end
}
- Spoiler: show
-
2020-03-23 23:35:00.128 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:00.128 Status: dzVents: Debug: - Timer
2020-03-23 23:35:00.185 Status: dzVents: Info: ------ Start internal script: Diepvries:, trigger: every minute
2020-03-23 23:35:00.185 Status: dzVents: Info: ========================
2020-03-23 23:35:00.185 Status: dzVents: Info: ========================
2020-03-23 23:35:00.185 Status: dzVents: Info: ========================
2020-03-23 23:35:00.186 Status: dzVents: Info: Diepvries trigger started every minute
2020-03-23 23:35:00.220 Status: dzVents: Debug: Processing device-adapter for DiepvriesSensor: Switch device adapter
2020-03-23 23:35:00.221 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:00.221 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:00.222 Status: dzVents: Debug: Constructed timed-command: Off
2020-03-23 23:35:00.222 Status: dzVents: Debug: Constructed timed-command: Off NOTRIGGER
2020-03-23 23:35:00.222 Status: dzVents: Debug: Constructed timed-command: Off
2020-03-23 23:35:00.222 Status: dzVents: Debug: Constructed timed-command: Off NOTRIGGER
2020-03-23 23:35:00.222 Status: dzVents: Info: Dievries trigger: hij staat open, laat de lampen knipperen...
2020-03-23 23:35:00.222 Status: dzVents: Debug: Constructed timed-command: On
2020-03-23 23:35:00.223 Status: dzVents: Debug: Constructed timed-command: On FOR 1 SECONDS
2020-03-23 23:35:00.223 Status: dzVents: Debug: Constructed timed-command: On FOR 1 SECONDS REPEAT 6 INTERVAL 1 SECONDS
2020-03-23 23:35:00.223 Status: dzVents: Debug: Constructed timed-command: On
2020-03-23 23:35:00.223 Status: dzVents: Debug: Constructed timed-command: On FOR 1 SECONDS
2020-03-23 23:35:00.223 Status: dzVents: Debug: Constructed timed-command: On FOR 1 SECONDS REPEAT 6 INTERVAL 1 SECONDS
2020-03-23 23:35:00.224 Status: dzVents: Info: ------ Finished Diepvries
2020-03-23 23:35:00.224 Status: dzVents: Debug: Commands sent to Domoticz:
2020-03-23 23:35:00.224 Status: dzVents: Debug: - sonoff keuken = Off NOTRIGGER
2020-03-23 23:35:00.224 Status: dzVents: Debug: - sonoff keukenkoof = Off NOTRIGGER
2020-03-23 23:35:00.224 Status: dzVents: Debug: - sonoff keuken = On FOR 1 SECONDS REPEAT 6 INTERVAL 1 SECONDS
2020-03-23 23:35:00.224 Status: dzVents: Debug: - sonoff keukenkoof = On FOR 1 SECONDS REPEAT 6 INTERVAL 1 SECONDS
2020-03-23 23:35:00.224 Status: dzVents: Debug: =====================================================
2020-03-23 23:35:00.227 Status: EventSystem: Script event triggered: C:\Program Files (x86)\Domoticz\dzVents\runtime\dzVents.lua
2020-03-23 23:35:01.883 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:01.955 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:01.956 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:01.956 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:01.956 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:02.790 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:02.863 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:02.863 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:02.863 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:02.864 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:03.744 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:03.822 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:03.822 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:03.822 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:03.822 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:03.942 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:04.020 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:04.021 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:04.021 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:04.022 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:04.022 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:04.022 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:04.133 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:04.208 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:04.208 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:04.209 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:04.209 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:04.356 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:04.429 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:04.430 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:04.430 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:04.430 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:04.528 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:04.610 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:04.611 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:04.611 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:04.611 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:04.823 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:04.877 Status: dzVents: Debug: Processing device-adapter for WaterTeller: Counter device adapter
2020-03-23 23:35:04.877 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:04.877 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:04.878 Status: dzVents: Debug: - Device: WaterTeller
2020-03-23 23:35:04.933 Status: dzVents: Info: Handling events for: "WaterTeller", value: "18446744073709538118"
2020-03-23 23:35:04.933 Status: dzVents: Info: ------ Start internal script: WaterTeller2InfluxDB_2: Device: "WaterTeller (ESP8266)", Index: 171
2020-03-23 23:35:04.934 Status: dzVents: Info: CHRISTIAN NEW value(Total):589 valueQuantity:Count counterDiff:0
2020-03-23 23:35:04.935 Status: dzVents: Info: ------ Finished WaterTeller2InfluxDB_2
2020-03-23 23:35:05.341 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:05.418 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:05.419 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:05.419 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:05.419 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:05.518 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:05.587 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:05.587 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:05.587 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:05.588 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:06.335 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:06.409 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:06.409 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:06.410 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:06.410 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:06.498 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:06.554 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:06.554 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:06.554 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:06.554 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:07.322 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:07.394 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:07.394 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:07.394 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:07.395 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:07.490 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:07.545 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:07.546 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:07.546 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:07.546 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:08.337 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:08.404 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:08.405 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:08.405 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:08.405 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:08.496 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:08.551 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:08.552 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:08.552 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:08.552 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:09.322 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:09.387 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:09.388 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:09.388 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:09.388 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:09.487 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:09.549 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:09.550 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:09.550 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:09.550 Status: dzVents: Debug: - Device: sonoff keukenkoof
2020-03-23 23:35:10.331 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:10.402 Status: dzVents: Debug: Processing device-adapter for sonoff keuken: Switch device adapter
2020-03-23 23:35:10.402 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:10.402 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:10.402 Status: dzVents: Debug: - Device: sonoff keuken
2020-03-23 23:35:10.489 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2020-03-23 23:35:10.552 Status: dzVents: Debug: Processing device-adapter for sonoff keukenkoof: Switch device adapter
2020-03-23 23:35:10.553 Status: dzVents: Debug: dzVents version: 2.5.2
2020-03-23 23:35:10.553 Status: dzVents: Debug: Event triggers:
2020-03-23 23:35:10.553 Status: dzVents: Debug: - Device: sonoff keukenkoof