Flashing lights, howto?
Posted: Saturday 19 December 2020 15:54
I've the following script that is triggered when the doorbell is pressed.
I want the lights to go on and off 5 times but I cannot get this working.
On top of this the current status of the lamp needs to be saved so that I can but the light back on or off again after the flashing is completed.
This is my script, what am I doing wrong?
The log that is generated is as follow:
I want the lights to go on and off 5 times but I cannot get this working.
On top of this the current status of the lamp needs to be saved so that I can but the light back on or off again after the flashing is completed.
This is my script, what am I doing wrong?
Code: Select all
return {
logging = {
level = domoticz.LOG_DEBUG,
marker = 'ControlDeurBel'
},
on = {
devices = {
'Deurbel Input 1'
}
},
execute = function(domoticz, device)
-- If the Doorbell is pressed, take action and ring the bell.
if (device.name == 'Deurbel Input 1') and (device.state == 'On') then
local deurBelOut = domoticz.devices('Deurbel Output 2')
-- Log information to the debug window
domoticz.log('Doorbell was pressed, lets ring the bell!', domoticz.LOG_INFO)
-- Send a message to Telegram that the doorbell was pressed.
local DateTimePressed = os.date("%d/%m/%Y %X")
domoticz.notify("HoekHuis Deurbel", "Doorbell was pressed at " .. DateTimePressed .. ".", domoticz.PRIORITY_HIGH)
-- Enable the doorbell, smart implant output.
-- Smart implant is configured to switch off the output automatically.
deurBelOut.switchOn()
-- Enable the gang door light
local VoorDeurLight = domoticz.devices('Lamp Hal Voordeur')
domoticz.log('Switch on the gang front door lamp.', domoticz.LOG_DEBUG)
VoorDeurLight.switchOn()
VoorDeurLight.switchOff().afterSec(10)
-- Switch On and Off the Kitchen light
local KeukenLamp = domoticz.devices('Keuken Lamp')
KeukenLamp.cancelQueuedCommands()
-- Save the status of the keuken Lamp to put it back to this status later
local KeukenLampStatus = KeukenLamp.state
domoticz.log('Keuken lamp status: ' .. KeukenLampStatus .. '.', domoticz.LOG_DEBUG)
-- Flash the kitchen lamp a couple of times
KeukenLamp.switchOn().forSec(1).repeatAfterSec(1, 5)
domoticz.log('Keuken lamp was flashed a number of times.', domoticz.LOG_DEBUG)
if (KeukenLampStatus == 'On') then
domoticz.log('Switch keuken lamp on again.', domoticz.LOG_DEBUG)
KeukenLamp.switchOn().afterMin(1)
else
domoticz.log('Switch keuken lamp off again.', domoticz.LOG_DEBUG)
KeukenLamp.switchOff().afterMin(1)
end
end
end
}Code: Select all
2020-12-19 15:49:22.484 Status: dzVents: Info: ControlDeurBel: ------ Start internal script: ControlDeurBel: Device: "Deurbel Input 1 (HoekHuisZwave)", Index: 275
2020-12-19 15:49:22.484 Status: dzVents: Debug: ControlDeurBel: ============================================================================================
2020-12-19 15:49:22.484 Status: dzVents: Debug: ControlDeurBel: Device Deurbel Input 1 was changed. Status is: On.
2020-12-19 15:49:22.485 Status: dzVents: Debug: ControlDeurBel: Processing device-adapter for Deurbel Output 2: Switch device adapter
2020-12-19 15:49:22.485 Status: dzVents: Info: ControlDeurBel: Doorbell was pressed, lets ring the bell!
2020-12-19 15:49:22.485 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Processing device-adapter for Lamp Hal Voordeur: Switch device adapter
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Switch on the gang front door lamp.
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: Off
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: Off AFTER 10 SECONDS
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Processing device-adapter for Huiskamer Lamp: Switch device adapter
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Keuken lamp status: On.
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On
2020-12-19 15:49:22.486 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On FOR 1 SECONDS
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On FOR 1 SECONDS REPEAT 6 INTERVAL 1 SECONDS
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: Keuken lamp was flashed a number of times.
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: Switch keuken lamp on again.
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: Constructed timed-command: On AFTER 60 SECONDS
2020-12-19 15:49:22.487 Status: dzVents: Debug: ControlDeurBel: ============================================================================================
2020-12-19 15:49:22.487 Status: dzVents: Info: ControlDeurBel: ------ Finished ControlDeurBel
2020-12-19 15:49:22.768 Status: dzVents: Info: ControlDeurBel: ------ Start internal script: ControlDeurBel: Device: "Deurbel Input 1 (HoekHuisZwave)", Index: 275
2020-12-19 15:49:22.768 Status: dzVents: Debug: ControlDeurBel: ============================================================================================
2020-12-19 15:49:22.768 Status: dzVents: Debug: ControlDeurBel: Device Deurbel Input 1 was changed. Status is: Off.
2020-12-19 15:49:22.768 Status: dzVents: Debug: ControlDeurBel: ============================================================================================
2020-12-19 15:49:22.769 Status: dzVents: Info: ControlDeurBel: ------ Finished ControlDeurBel