DzVents - Light Flicker before Turning Off
Purpose
The purpose of this script is to have the light flicker 5 minutes before it is going to turn off. This script could be used to indicate to people in the house that the light is about to turn off for the night.
Dependencies
This script’s first dependency is a light that is compatible with Domoticz. This script was written and tested using a Yeelight (Color) and functioned properly.
Domoticz Setup
This script will require that you have a switch that connects to the light you are trying to use. You will need the name of your switch to substitute for ‘Home Yeelight’ in the script below.
Installation Instructions
Copy this script in your domoticz\scripts\dzVents\ folder.
Script with Comments
return {
on = {
--will run at 9 P.M. every weekday
timer = {'at 19:00 on mon, tue, wed, thu, fri' },
},
execute = function(domoticz, timer)
light = domoticz.devices('Home Yeelight')
--check to see if the light is on
if (light.state == 'On') then
--flicker the light on and off for 6 seconds
light.switchOff().afterSec(1)
light.switchOn().afterSec(2)
light.switchOff().afterSec(3)
light.switchOn().afterSec(4)
light.switchOff().afterSec(5)
light.switchOn().afterSec(6)
--send message to log that flicker has completed
domoticz.log('Flicker complete')
--turn off the light 5 minutes after the flicker
light.switchOff().afterSec(300)
--check to see if the light state is off
elseif (light.state == 'Off') then
--Log the message that the light is already off
domoticz.log('Light is already off')
end
end
}
Notes
The script above can be customized very easily. To run the script at a different time besides 9 P.M., change the timer variable to match when you want the script to run. Also, if you wanted to change how long after the flicker the light should turn off, you just need to change the parameters in the command: light.switchOff().afterSec(300) to be however many minutes after you want it to turn off * 60 to convert it to seconds.