Wake up light with Lua & Domoticz

This is a script I originally made with blocky, but that didn’t really work for some reason. Also I wanted it to be flexible, taking the date and time in consideration. So if my next alarm is set for monday, it won’t start on sunday when I want to sleep in.

This script uses three variables, which you’ll find at the top of the script.

wakeupspan – The time you want the light to take
steps – the number of iterations you want your light to take
switch – the name of the switch you want to use

Some thoughts

This doesn’t work very well if you don’t have Tasker as it is tied to a date, see below how to set that up.
It’s a lot faster than adding a ‘wait’ or sleep in your script and should finish within a second or so. But the downside of this is that if you turn the light on or off during the timespan, the light will fall back to the scheduled commands, so if you decide to sleep in, it will come back with a vengeance ;-)
You might want to insert a ‘Holiday Mode’ check or whether you’re home at all.

Why two user variables? Well, it’s only one extra line in Tasker, but a whole lot more annoying to parse in Lua if I were to use one date-time or string.

So here’s the code:

 

To use

Place this script in your domoticz/scripts/lua folder named ‘script_time_wakeup.lua’. or something you prefer. Don’t forget to set two user variables ‘WakeUpTime’ and ‘WakeUpDate’.

I use Tasker and AutoAlarm to read my next alarm at around 3am and send it to my Raspberry Pi with a simple http get command:

and

(repace the IP address with your own)
It should look like this:

Leave a Reply

Your email address will not be published. Required fields are marked *