The concept behind this is pretty simple: at a specific time each night, the system dims all the lights that are currently on. A couple minutes later if the lights haven’t been brought back to full brightness, they’re turned off. The idea is that if someone is actually awake at that unholy hour, they aren’t plunged into darkness and can just hit the switch to turn the light back on.
Additionally, while the MorningLinc locks don’t have a mechanism to indicate their state, I’ve got a lock sensor that allows me to lock the front door if it’s not already locked (you could always just send a “lock” signal without checking if the door is locked, but you may hear the lock beeping when the signal is sent).
The programs use state variables to trigger other events; this way I can use a main program to set a flag at the prescribed time, and easily change the time in one place if I find the lights are going off too early or too late.
The code for the master programs are as follows:
If Time is 2:00:00AM Then $nightly_shutdown_dim = 1 Wait 30 seconds $nightly_shutdown_dim = 0
If Time is 2:00:00AM Then $nightly_shutdown_off = 1 Wait 30 seconds $nightly_shutdown_off = 0
… and then there are respective programs for each scene that look like this:
If $nightly_shutdown_dim is 1 And Status 'Basement - Main' is not Off And Status 'Basement - Main' is not 20% Then Set 'Basement - Main' 20%
If $nightly_shutdown_off is 1 And Status 'Basement - Main' is 20% Then Set 'Basement - Main' Off
.. The door lock is handled in a similar way:
If $nightly_shutdown_off is 1 And Status 'Front Door Lock Sensor' is On Then Set 'Front Lock' Locked