Making dumb RF ceiling fans smart

I’ve got a few remote-controlled ceiling fans (Lucci Air) in our house and I find them a complete pain to operate as you need to remember to turn the switch on and then use the remote to control the light and fan speed. And they are also not integrated with HA, so I can’t control them as part of the house climate control.

So, I decided to solve that - Building a Smart Home - Part 4 Ceiling Fans

It works by via

  • Broadlink RM4 Pro to RF blast
  • Fan template entities to represent each one
  • Input helpers to track speed, fan on/off state, and light state
  • Scripts to fire the right RF signals

Really happy with how this works as now the fans will just turn themselves on and off… assuming we don’t turn them off at the wall!

3 Likes

If you add something like i.e. a ZigBee Switch Electricity Energy Monitor KWh (I use these) you can even “sense” the current status of those fans by their power usage (speed, fan on/off state, light state) no matter whether they are switched through the wall switch or through HA. I am using this for ACs (controlled by Broadlink IR blasters) and it works very reliable.

I’m going to put a Shelly in the wall behind the switch, just waiting for my electrician to be available to do that wiring

Also be aware that if anyone uses the fan remote to change anything on the fan then the state in HA and the actual state will be out of synch.

Yep, that’s why the remotes are hidden :wink:

1 Like

Im so excited to find/ read this post, thank you @slace

Im in the same boat with ceiling fans and cant wait to go through your implementation.

Thank you! :slight_smile:

1 Like

Tempted to try changing the controller in my fans to these…and see if I can drive them with HA

https://www.amazon.co.uk/SONOFF-iFan04-Wi-Fi-Ceiling-Controller

Not if you add something like a Shelly 1PM & code like this.

sensor:
  - platform: template
    sensors:
      template_fan_percentage_family_room:
        friendly_name: Family Estimated Fan Percentage
        value_template: >-
         {% set fan_power = states('sensor.family_room_fan_power') | float (0) %}

         {% if 3 < fan_power < 13 %}
           33
         {% elif 16 <= fan_power < 32 %}
           66
         {% elif fan_power >= 50 %}
           100
         {% else %}
           0
         {% endif %}

## Speed Reference ##
## (Off) <3 watts
## (1) 12.34~12.74 watts
## (2) 29~30.4 watts
## (3) 61~64 watts
fan:
  - platform: template
    fans:
      template_family_room_fan:
        friendly_name: "Family Room Fan"
        # Measures the power use from a Shelly1 PM and if over 3W, marks the fan as on
        value_template: "{% if states('sensor.family_room_fan_power') | float (0) > 3 %}on{% else %}off{% endif %}"
        # Uses the Shelly1 PM sensor value to determine what speed the fan is going at. Only set to measure 33, 66, 100
        percentage_template: "{{ states('sensor.template_fan_percentage_family_room') }}"

@slace Hey Aaron. Is your full code on Github somewhere? I couldn’t find any of your repos written in YAML. I’d like to try and merge your code with mine but I’m unsure what name you used for your speed commands and as a hardware guy, deciphering many lines of complex template code is not my forte.

I don’t have my YAML files on GitHub, one day I’ll get around to that :sweat_smile:

For the RF commands recorded per-fan I have then named fan_speed_<number> so fan_speed_1 is the first speed, etc. I don’t track fan_speed_0 though as that is when it’s turned off, so I just call the off command.

Since the commands are scoped to the fan by Home Assistant, I don’t put the name in the command storage.

This is how I use it in a script (fan_speed_set from the blog post):

    - service: remote.send_command
      data:
        device: "{{ fan }}"
        command: fan_speed_{{ speed | round (0, 'floor') }}

Thanks Aaron. I’ll have a go at using your code and then modifying the percentage_template to use my power consumption sensor and see how that looks. I’ll report back.

1 Like

A slightly unrelated question, but I have not seen a lot of threads about ceiling fans (for some reason it is only popular in the US as far as I could tell):

  • how do you find the setup itself? How does a ceiling fan compare to - let’s say - a tower fan? Is it more for mixing the air for the given room in the house, or can you actually feel some form of cooling effect?
  • regarding the Broadlink, where did you place the unit itself? Would it be feasible to place it in the living room and expecting it to be able to control the fan in the kitchen for example? Can it control fans/devices on a different floor?

I am considering the same setup with ceiling fans albeit I am bit hesitant to but them as I am not sure if they would have the desired effect (on-demand cooling of a given area)

We built a new house and the fans were installed as part of that so I can’t comment on whether a tower fan would be better.

For placement, I have the broadlink in around about the middle of the house (sitting on a TV unit as it also controls the TV) and it’s able to reach everywhere just fine.

Hi Aaron
first, thank you for the scripts and great explanation.
I used it to install my 3 speed ceiling fan today and it took me a while to figure out why it would only set speed to 1 and 3, not 2.

The Problem is in fan_set_speed_state:

value: "{{ (speed / 100) * 6 | round(0, 'ceil') }}"

Your code rounds just the 6 and not the result of (speed/100)*6
To fix it one has to put the calculation in parentheses:

value: "{{ ((speed / 100) * 6) | round(0, 'ceil') }}"

The reason for this is described here

Not sure if its noticeable on a six speed fan if it skips a speed level but it sure is on a 3 speed one :slight_smile:

Greetings

Ah, yeah I think I hit that some time after the blog went out as I have changed that in my HA install. I should update the blog :sweat_smile: