Github Boards Devices Community Docs Blog

Proper Config of RF Ceiling Fan in HA - Speed and State Updates

Hi,

I have 3 315MHz RF Ceiling fans in my house. I have setup a receiver and transmitter with OpenMQTTGateway which is working wonderfully after failing to get ESPHome working.

I am attempting to setup the fans in my configuration based on the codes I sniffed from the remotes. The remote has 4 buttons: Off, Speed 1, Speed 2, and Speed 3. Each button sends a different code. The off payload looks as follows:

{
    "value": 522775,
    "protocol": 6,
    "length": 24,
    "delay": 482
}

I tried to setup the fan using the template examples I’ve found and have fooled around with getting the fan state/speed state to stay in sync with the remote/HA. I think I am just misunderstanding how OpenMQTTGateway and Home Assitant interact. I have posted the config that I am trying to use and hope someone can set me straight. Thank you.

fan:
- platform: mqtt
  name: office_ceiling_fan
  unique_id: fan.office_ceiling_fan
  state_topic: "home/OpenMQTTGateway/433toMQTT"
  state_value_template: >-
    {% if value_json.value == 522887 %}
       {{'ON'}}
    {% elif value_json.value == 522823 %}
       {{'ON'}}
    {% elif value_json.value == 522951 %}
       {{'ON'}}
    {% elif value_json.value == 522775 %}
       {{'OFF'}}
    {% else %}
       {{ states('fan.office_ceiling_fan') | upper }}
    {% endif %}
  speed_state_topic: "home/OpenMQTTGateway/433toMQTT"
  speed_command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
  speed_value_template: >-
    {% if value_json.value == 522887 %}
       {{'low'}}
    {% elif value_json.value == 522823 %}
       {{'medium'}}
    {% elif value_json.value == 522951 %}
       {{'high'}}
    {% elif value_json.value == 522775 %}
       {{'off'}}
    {% else %}
       {{ state_attr('fan.office_ceiling_fan', 'speed') | upper }}
    {% endif %}
  command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
  payload_off: '{"value":522775,"protocol":6,"length":24,"delay":481}'
  payload_low_speed: '{"value":522887,"protocol":6,"length":24,"delay":481}'
  payload_medium_speed: '{"value":522823,"protocol":6,"length":24,"delay":481}'
  payload_high_speed: '{"value":522951,"protocol":6,"length":24,"delay":481}'
  speeds:
    - 'off'
    - low
    - medium
    - high
  availability_topic: "home/OpenMQTTGateway/LWT"
  payload_available: "online"
  payload_not_available: "offline"
  qos: 0

With this setup I am able to control the fan with the remote or HA, but HA doesn’t see speed/state changes done with the remote. Can someone point me in the right direction? Thanks.

I’ve also tried re-flashing with simple receiving enabled so that my command topics look like this home/OpenMQTTGateway/commands/MQTTto433/433_6/RFBITS_24/PLSL_480/

This seems to have gotten me a bit further as the fan speeds stay in sync. However, the state is always off. The template doesn’t seem to be processing properly?

Could you provide logs of the MQTT topic(s) when various actions are performed - especially pressing a button on the remote?