I'm a morning person, and I usually get up quite early. As a result, I'm the first person up in our house. Once I'm awake, I'll get out of bed, find my way to the ensuite to get ready, and once I've finished in the ensuite, I'll find my way back across the bedroom to the door to the hallway. I try and do this all without turning on any lights so as not to disturb my partner, who is still asleep. Unfortunately, avoiding turning on lights often means that this is a bit of a slow process. There has to be a smarter way.

Over the last year, I have been getting into home automation. This blog post explains how I've added home automation improvements to the ensuite to make my morning routine much more comfortable.

The Challenge

I have several objectives that I'm looking to achieve with this home automation project:

  1. Can I light the ensuite in a way that I can see what I'm doing whilst I get ready, but without destroying my night vision. After all, I still need to get back across a dark bedroom to get to the hallway.
  2. The ensuite bathroom door is reasonably close to the bed, so I want to minimise any light disruption when opening and closing the door.
  3. As the ensuite is close to the bed, I want to eliminate unnecessary noise. At the moment, the extractor fan turns on automatically when the bathroom lights are turned on. However, I usually shower in the evenings during the week, and, as a result, I don't need the extractor fan in the early midweek mornings. Ideally, I'd like to selectively control when the extractor fan is turned on based on the time of the day?

Before going down a high tech route, I did try and use a small battery operated motion-activated light in the ensuite to help get ready:

MB720A Sleep Friendly Battery-Powered Motion-Sensing LED Stick-Anywhere Nightlight

Despite being small and battery operated, this thing does emit a fairly bright warn-yellow light. It wasn't too bad, but I found it quite harsh on the eyes, and it didn't help to preserve my night vision when going back into the dark bathroom. I've therefore ruled out the option of using regular light bulbs with a dimmer switch.

Instead, I'm going to replace the standard GU10 lights in the bathroom with RGB LED GU10 lights and use them to emit a low brightness red light in the early morning to provide me with enough light to get ready whilst preserving my night vision. Red light is widely accepted as being a good way to protect night vision given that the human eye is less sensitive to the red colour spectrum:

"Rhodopsin in the human rods is insensitive to the longer red wavelengths, so traditionally many people use red light to help preserve night vision" - Wikipedia

The Solution

In the rest of my house, I've used Shelly Dimmer and Shelly 1L devices to convert my traditional light switches into smart light switches. There are so many benefits of an approach like this:

  • I can use any light switch that I find aesthetically pleasing. I'm not limited to "smart light switches".
  • I can control the lights using the light switch or using automation.
  • The light switch will still function like a light switch even if the home network goes down.
  • This approach means I don't need to use more expensive smart light bulbs and risk the power being cut off by someone using the light switch, which would prevent any automation from controlling the state of the light bulbs.

I want to try and preserve as many of these benefits as possible with my solution for the ensuite.

Lighting

I have a couple of Philips Hue Iris lamps in my home office that I use for ambient lighting, so the first obvious choice for changing the bathroom lighting is to replace the standard GU10 light bulbs with Philips Hue GU10 RGB LEDs.

The only downside with Philips Hue is that they can be a bit pricey, so I'm taking a bit of a risk with some Innr GU10s, which are supposed to be Philips Hue compatible.

Innr GU10 - Philips Hue Compatible

I've avoided using smart bulbs in the rest of the house because I'm concerned that people will expect to use the light switch normally (like any other light switch). But, if someone turns off the power to a smart bulb at the light switch, it's no longer powered and becomes inaccessible to any automation that might want to engage with the bulb.

Whilst I'm trying to make the house smarter, I don't want to force people to change their instinctive behaviour of interacting with light switches and other standard functions of a home. As a result, expecting anyone in the house (especially guests) to use an app to turn on or off smart bulbs isn't a viable option for me.

I plan to do something a little bit different so that my smart lights will always be accessible to home automations and so that anyone in the house can continue to use the light switch the same way they would normally.

A light switch typically provides a "switched live" feed to the lights, which will connect the lights to the live power feed from the consumer unit when the light switch is switched on (hence "switched live"). I plan to change the wiring in the switch so that the lights will be permanently powered all the time.

Instead of switching the live power feed, the light switch will use a Shelly i3 and an automation to toggle the smart bulbs on and off.

Shelly i3

The Shely i3 is "the smallest WiFi action and scenes activation device in the world". The i3 has three inputs that can detect up to 24 actions and command other connected Shelly relays and sensors, or HTTP, MQTT or CoAP controlled devices.

Pros:

  • The light switch can be used as a light switch.
  • Automations can turn the lights on or off regardless of what state the light switch is in.

Cons:

  • If the home network goes down, I won't be able to turn the ensuite lights on or off

I'm happy with the single con I have for this approach as the chances of this happening are slim, and this is the only room in the house with this limitation.

When the light switch is pressed, a home automation will be triggered. Based on the time of day, the automation will determine whether to light the ensuite bathroom normally or with low-brightness red light.

Extractor Fan

The goal with the extractor fan is only to turn it on when it is needed, based on the time of the day.

Extractor fans typically take a permanent power feed and a "switched live" connection that is connected to the light switch. When the lights are turned on, the switched live triggers the fan to turn on.

After the lights are turned off, the fan usually runs for a period of time. This is because the extractor fan is permanently powered, and the switched live is simply acting as a trigger to determine when the fan should turn on. The permanent power feed lets the fan run for a configured time after the bathroom has been used and the lights have been switched off so that the fan can do its job.

So how can I ensure the extractor fan only turns on when I want it to? I can use a Shelly relay such as the Shelly 1 Plus. I picked the Shelly 1 Plus for two reasons:

  • It's rated for a load of up to 16A, which is more than plenty for a simple extractor fan
  • The Shelly 1 Plus is a dry-contact relay which will be safe for switching an inductive load such as a fan motor
Shelly 1 Plus

The relay will need to be placed between the switched live feed and the fan. Then, when the light switch is pressed, and the Shelly i3 automaton is toggled, the Shelly 1 Plus relay can also be turned on when I want the fan to be on.

The depth of the isolator switch didn't allow for the Shelly to fit inside the backbox. Therefore I replaced the original isolator switch back box with a "1 + 1-Gang" back box. A blank plate covers the Shelly 1 Plus.

Similarly, when the light switch toggles the i3 to an off state, I can turn off the Shelly 1 Plus relay.

Automations

I've added a number of automations to my home assistant setup to allow these devices to work together in the way I want them to.

The first task was to setup the Shelly i3. After connecting it my IoT WiFi network I was planning to set the i3 input to "Toggle" mode and have this trigger a webhook whenever the switch was pressed.

Shelly i3 settings for the first input which is connected to the light switch

However, I found that the webhook didn't always fire in Toggle mode. So instead, I opted to use MQTT, which talks to Mosquitto MQTT Broker, which is already running in my home assistant setup. So far, MQTT has proven to be very reliable with the i3.

The next step was to add two basic automations: turning the lights on and turning the lights off.

alias: Ensuite Lights On
description: ""
mode: single
trigger:
  - platform: mqtt
    topic: "shellies/shellyix3-FE9DE4D4101F/input/0"
condition:
  - condition: template
    value_template: "{{ trigger.payload == '1' }}"
  - condition: device
    type: is_off
    device_id: ef6cf6ec2c2b11600fb6ff99671434f7
    entity_id: light.ensuite_window
    domain: light
action:
  - service: light.turn_on
    target:
      entity_id:
        - light.ensuite_window
        - light.ensuite_shower
    data_template:
      brightness: >
        {% if now().hour >= 22 %}175
        {% elif now().hour < 7 %}175
        {% else %}255
        {% endif %}
      color_name: >
        {% if now().hour >= 22 %}red
        {% elif now().hour < 7 %}red
        {% else %}white
        {% endif %}
ensuite_lights_on.yaml
alias: Ensuite Lights Off
description: ""
mode: single
trigger:
  - platform: mqtt
    topic: "shellies/shellyix3-FE9DE4D4101F/input/0"
condition:
  - condition: template
    value_template: "{{ trigger.payload == '0' }}"
  - condition: device
    type: is_on
    device_id: ef6cf6ec2c2b11600fb6ff99671434f7
    entity_id: light.ensuite_window
    domain: light
action:
  - service: light.turn_off
    target:
      entity_id:
        - light.ensuite_window
        - light.ensuite_shower
ensuite_lights_off.yaml

I did find that I would sometimes get duplicate MQTT events from the i3. When this happened, the automation would run again and change the brightness and colour to what was in the automation. Unfortunately, this meant I couldn't turn on the lights and then change the colour in the Home Assistant app, as the duplicate MQTT events would often cause the bulbs to reset to the state defined in the "turn on" automation. This is why the automation checks that the light isn't already turned on.

Once the Shelly 1 Plus had been installed to control the fan, I added a separate automation to turn on the relay, provided the light is turned on at a time when the extractor fan is allowed to run. This was added as a seperate automation because turning on the relay is a conditional action depending on the time of day and I couldn't find a way to add a conditional action to the existing ensuite_lights_on.yaml automation.

alias: Ensuite Fan - On
description: ""
mode: single
trigger:
  - platform: mqtt
    topic: "shellies/shellyix3-FE9DE4D4101F/input/0"
condition:
  - condition: time
    after: "07:00:00"
    before: "22:15:00"
  - condition: template
    value_template: "{{ trigger.payload == '1' }}"
  - condition: state
    entity_id: switch.ensuite_bathroom_fan_switch
    state: "off"
action:
  - service: switch.turn_on
    target:
      entity_id: switch.ensuite_bathroom_fan_switch
ensuite_fan_on.yaml

I also updated the "Esnuite - Lights Off" automation to turn off the fan:

alias: Ensuite Lights Off
description: ""
mode: single
trigger:
  - platform: mqtt
    topic: "shellies/shellyix3-FE9DE4D4101F/input/0"
condition:
  - condition: template
    value_template: "{{ trigger.payload == '0' }}"
  - condition: device
    type: is_on
    device_id: ef6cf6ec2c2b11600fb6ff99671434f7
    entity_id: light.ensuite_window
    domain: light
action:
  - service: light.turn_off
    target:
      entity_id:
        - light.ensuite_window
        - light.ensuite_shower
  - service: switch.turn_off
    target:
      entity_id: switch.ensuite_bathroom_fan_switch
ensuite_lights_off.yaml

When the lights are turned off, the automation will ensure that the relay is turned off immediately. The fan will then run for a few minutes on its built-in timer before turning off.

Conclusion

I've been using these automations for weeks now, and I'm delighted with the results.

I was surprised at home much kinder using low-level red lighting has been on my eyes when I first get up in the morning. It took a couple of attempts to get the brightness level just right – not bright enough that my eyes need to adjust and not too dark that I can't see what I'm doing.

The Innr bulbs are working out to be a great alternative to the official Hue Bulbs. They're cheaper than the Philips Hue bulbs, and they work just as well with the Hue app and Home Assistant as the official bulbs.

It took a bit of time to figure out that the webhook on the i3 wasn't going to work, and the MQTT was the way to go. However, it's been plain sailing ever since once I got over these minor teathing issues.

Whilst I was sorting out the lights and extractor fan, I also added an Aqara Temperature and Humidity Sensor into the bathroom to monitor the humidity and temperature in the ensuite. In the future, I may choose to factor in the humidity reading from the Aqara sensor into the automation that triggers the extractor fan relay.

Aqara Temperature and Humidity Sensor