Automated Stairway Night Lights

I wanted a simple but useful project as my first bit of home automation after getting some CloudFree smart plugs. We have fairy (christmas) lights on our banisters going upstairs that we plug in whenever we want to use them, so why not set them up on the smart plugs and setup an automation to turn them on at night, and turn them off around when we should be going to bed. This seemed like a simple enough project for a first shot at it, and something that we would use.

Goal

  • Stairway lights turn on before sundown
  • Stairway lights turn off around bedtime on weekdays
  • Stairway lights turn off slightly later on weekends

Automations

After getting the two smart plugs setup on MQTT, the process in home assistant was straight forward to do. Under Configuration → Automations, I added 3 total automations:

  1. Turn off at Bedtime Weekday
  2. Turn off at Bedtime Weekend
  3. Turn on at Night

Turn on At Night

Home Assistant has a trigger at sunset, so I used that with a 30 minute offset (turn them on slightly before sunset). For the actions on this automation, I wanted to turn on the lights (not toggle), so I used that in my actions, and since this wasn’t dependent on the day of the week, this automation won’t have any conditions on it.

Trigger:

  • Type: Sun
  • Event: Sunset
  • Offset: -00:30:00

Actions:

  • Type: Device
  • Device: CloudFree
  • Action: Turn on CloudFree CloudFreeSmartPlug1 (will be different based on the friendly name of your smart plugs)
  • Type: Device
  • Device: CloudFree
  • Action: Turn on CloudFree SmartPlug2 (will be different based on the friendly name of your smart plugs)

Turn off At Bedtime

I have two automations for turning the lights off, one for weekdays, and one for weekends. I couldn’t see a straight forward way to change the time without having a separate automation, and since this is the first set of automations I’ve worked on, I didn’t mind having multiple of them for the same task. Since both of the turn off automations are extremely similar, I’m going to group them together in this guide. The only differences between them are the trigger time and the condition days.

Triggers:

  • Type: Time
  • At Time: 21:30 (military time)

Conditions:

  • Condition Type: Time

This was setup as YAML, so click those 3 dots and click “Edit as YAML”. The GUI doesn’t have the day of week conditions available, but they can be configured in the YAML, which is why we needed to do it this way. Below is for the weekday settings, and the second group of days is for the weekend settings.

weekday:
  - sun
  - mon
  - tue
  - wed
  - thu

Below are the days for the weekend settings.

condition: time
weekday:
  - fri
  - sat

Actions:

  • Type: Device
  • Device: CloudFree
  • Action: Turn off CloudFree CloudFreeSmartPlug1
  • Type: Device
  • Device: CloudFree
  • Action: Turn off CloudFree SmartPlug2

Conclusion

This was a relatively quick project from receiving the smart plugs to having them in home assistant with automations in place. We already like the ability to turn them on and off from the HASS GUI and having the automations on them is that much better.