I have a single switch ceiling fan in my bedroom. This means there is one line that powers both the fan and the lights. Naturally, if the switch is off there is no power to the fan or lights. If the switch is on, one must pull the draw strings to toggle the light and / or change the fan mode. Obviously those of you reading this will agree getting up to change the fan settings is unacceptable.
I scoured for a long time to try and find a solution to this problem. One of the ideas was to use the GE fan control and an aeotec nano swtich in the fan canopy. My particular fan has a small canopy space and those devices might not have fit. Further I am not sure if the wiring would work and that solution provides me with no redundancy should my Zwave or HomeAssistant go down.
I settled on an RF fan control to sit in the canopy and controlled it with a Broadlink pro that I purchased off Amazon. I will say that the Broadlink has been rock solid for the last few months used exclusively for fan control.
The part about this setup that I did not like was that the RF control would not read states. Everything was executed by a script and I would have to assume state. While not a bad setup, I had pondered looking into new setups. Recently I began playing with the new lovelace UI and figured out how to solve all of my problems.
The end state is fan control with an RF device in the canopy. I save the state of the lights and I save the state of the fan. Should the fan be adjusted through the remote and not HA I will lose synch. I have built some protocols to get me back into synch quickly via a script and with a daily reset.
-
Installed honeywell fan controller which has a light toggle, fan speed off / low / med / high, button to turn off fan and lights in 60 seconds
https://www.lowes.ca/ceiling-fan-controls-remotes/honeywell-handheld-step-up-full-function-ceiling-fan-remote-control_g1839802.html?searchTerm=Honeywell-fan -
Setup Broadlink pro+ to control fan through home assistant creating 6 switches
- fan high
- fan med
- fan low
- fan off
- fan lights
- turn off fan and lights in 60 seconds
-
Create input booleans which will be used to record the states of the lights and fan speed. RF does not record states and so the switches do not tell us on or off. Switches will be called by a script which will update input boolean
input_boolean.yaml
bedroom_ceiling_lights:
name: Bedroom Ceiling Lights
icon: mdi:lightbulb
bedroom_fan_off:
name: Bedroom Fan Off
icon: mdi:fan-off
bedroom_fan_low:
name: Bedroom Fan Low
icon: mdi:fan
bedroom_fan_med:
name: Bedroom Fan Med
icon: mdi:fan
bedroom_fan_high:
name: Bedroom Fan High
icon: mdi:fan
- Create scripts for fan control. Example below turns the fan to low, puts the corresponding input booleans to “on” and the other input_booleans to “off”
scripts.yaml
sequence:
- service: switch.turn_on
data:
entity_id: switch.ceiling_fan_low
- service: input_boolean.turn_on
data:
entity_id: input_boolean.bedroom_fan_low
- service: input_boolean.turn_off
data:
entity_id:
- input_boolean.bedroom_fan_off
- input_boolean.bedroom_fan_med
- input_boolean.bedroom_fan_high
- Customize the scripts. I used the mdi:numeric-X-box as my icons to show 0 1 2 3 for off, low, med high
customize.yaml
script.ceiling_fan_high:
friendly_name: High
icon: mdi:numeric-3-box
script.ceiling_fan_med:
friendly_name: Med
icon: mdi:numeric-2-box
script.ceiling_fan_low:
friendly_name: Low
icon: mdi:numeric-1-box
script.ceiling_fan_off:
friendly_name: "Off"
icon: mdi:numeric-0-box
- Create a front end conditional glance card for each fan state. Which ever input boolean is “on” will have a custom icon for the corresponding script, I used the mdi:numeric-X-box-multiple-outline. Example below:
ui-lovelace.yaml
- type: conditional
conditions:
- entity: input_boolean.bedroom_fan_off
state: "on"
card:
type: glance
title: Bedroom Fan
column_width: calc(100% / 4)
show_name: true
show_state: false
entities:
- entity: script.ceiling_fan_off
tap_action: toggle
icon: mdi:numeric-0-box-multiple-outline
- entity: script.ceiling_fan_low
tap_action: toggle
- entity: script.ceiling_fan_med
tap_action: toggle
- entity: script.ceiling_fan_high
tap_action: toggle
- type: conditional
conditions:
- entity: input_boolean.bedroom_fan_low
state: "on"
card:
type: glance
title: Bedroom Fan
column_width: calc(100% / 4)
show_name: true
show_state: false
entities:
- entity: script.ceiling_fan_off
tap_action: toggle
- entity: script.ceiling_fan_low
tap_action: toggle
icon: mdi:numeric-1-box-multiple-outline
- entity: script.ceiling_fan_med
tap_action: toggle
- entity: script.ceiling_fan_high
tap_action: toggle
-
Fan setup is now complete!
-
Back to the lights
-
Create script for light control
scripts.yaml
ceiling_light
sequence:
- service: switch.turn_on
data:
entity_id: switch.ceiling_light
- Create a template switch mapped to the the input boolean for light created in step 3. This is because the front end will not change colour of light to yellow when on for input booleans but will for template switches
switches.yaml
- platform: template
switches:
bedroom_ceiling_lights:
value_template: "{{ is_state('input_boolean.bedroom_ceiling_lights', 'on') }}"
turn_on:
service: input_boolean.turn_on
data:
entity_id: input_boolean.bedroom_ceiling_lights
turn_off:
service: input_boolean.turn_off
data:
entity_id: input_boolean.bedroom_ceiling_lights
-
Create automation to toggle the script.ceiling_light whenever the input_boolean state changes
-
Add recorder line to customize.yaml to save previous state of input boolean during power cycle
customize.yaml
recorder:
- Create script that will toggle the input boolean for the lights should the system go out of synch. If someone turns the light on from the RF remote the system will go out of synch. The script will toggle the input boolean, the automation created above will also toggle the lights so we wait 1 second and toggle again. This is handy in a hidden folder
sequence:
- service: input_boolean.toggle
data:
entity_id: input_boolean.bedroom_ceiling_lights - delay:
seconds: 1 - service: switch.turn_on
data:
entity_id: switch.ceiling_light
-
OPTIONAL STEPS BELOW – I reset the fan and switches daily. I like to turn everything off at 11:00am because I do not need the fan or lights on at that time ever.
-
Create script to toggle the fans 60 second timer which will turn off fans and light. Within the script we reset the 5 input booleans to the appropriate state
scripts.yaml
ceiling_fan_light_off
sequence:
- service: switch.turn_on
data:
entity_id: switch.ceiling_fan_light_off
- service: input_boolean.turn_off
data:
entity_id:
- input_boolean.bedroom_ceiling_lights
- input_boolean.bedroom_fan_low
- input_boolean.bedroom_fan_med
- input_boolean.bedroom_fan_high
- service: input_boolean.turn_on
data:
entity_id:
- input_boolean.bedroom_fan_off
- Create automation daily to call script from step 15