Is it possible to create a custom device by combining a switch and an RF fan control?

I have several RF fans that I can control from a Bond bridge. These fans also have wifi smart switches that can turn power to the fan on and off. If you set the fan speed to 100% and then turn the fan off via the switch the bond bridge still reports that the fan is at 100% and shows it as on. That behavior is bit annoying and confusing, but totally understandable. The bond bridge doesn’t know about the switch so it can’t know that the fan is actually off.

What I’d like to be able to do is create a custom device that combines the switch and the bond bridge fan control. When you turn the switch off on the wall this device would report that the fan is off. When you turn the fan on it would report whatever the current speed from the bond bridge is. When you command the fan off from the dashboard it would turn the switch off rather than use the bond bridge to turn the fan off.

Is this possible? If so, can someone kindly point me in the right direction?

1 Like

I got this working on my HA setup using the configuration below:

fan:
  - platform: template
    fans:
      office_fan_helper:
        unique_id: "09807609-ca74-4ab6-b547-a17faf1598a9"
        friendly_name: "Office Fan"
        value_template: "{{ states('switch.office_fan_switch') }}"
        percentage_template: "{{ state_attr('fan.office_fan', 'percentage') if is_state('switch.office_fan_switch', 'on') else 0 }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.office_fan_switch
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.office_fan_switch
        speed_count: 8
        set_percentage:
          - service: switch.turn_{{ 'on' if percentage > 0 else 'off' }}
            target:
              entity_id: switch.office_fan_switch
          - service: fan.set_percentage
            target:
              entity_id: fan.office_fan
            data:
              percentage: "{{ percentage }}"