Homekit + broadlink + fan (traditional with remote) control

Hi,
Firs of all, this is my first question and need to say you at HA do a gread job. I.m not a developer, but with some communit help I did lots of integrations at my home, I appreciate this, simple things.

I use HA with broadlnk to control several items, some from Broadlink (TC2), some old with remote controlers learned by Broadlink RM or Mini.

I Start to use Homekit this week, most of things are easy solved, but the Fans have problems.

Homebridge broadlink component only accepts ON/OFF Keys, but before I use Homekit I have it working in a Homebridge PI system.

I learn all commands at broadlink

`switches:
 ventilador_light_q:
    friendly_name: "Bedroom"
    command_on: 'JgBo...'
    command_off: 'JgBo.......
 ventilator_power_q:
    friendly_name: "Bedroom Ventiladtr"
    command_on: 'JgBoAAA...'
    command_off: 'JgBoAAA....'
 ventilator_level_1_q:
    friendly_name: "Bedroom level 1"
    command_on: 'JgBoAAA...'
    command_off: 'JgBoAAA...'
 vententilaTor_level_2_q:
    friendly_name: "bedroom level 2"
    command_on: 'JgBoAAA....'
    command_off: 'JgBoAAA....'
 vententilator_level_3_q:
    friendly_name: "bedroom level 3"
    command_on: 'JgBoAAAB....'
    command_off: 'JgBoAAA.....'
 vententilator_reverse_q:
    friendly_name: "Bedroom reverse"
    command_on: 'JgBgAAA...'
    command_off: 'JgBgAAA...'

`
If helps, when mapped at home bridge I used the code below, works gread with home app

`"name": "Bedroom Ventilator",
                "type": "fan",
                "host": "aa:aa:aa...",
                "data": \{
                    "on": "260068...",
                    "off": "260068",
                    "clockwise": "2600600....",
                    "counterClockwise": "2600600....",
                    "fanSpeed10": "260068....",
                    "fanSpeed20": "260068000...",
                    "fanSpeed30": "260068000....",
                    "fanSpeed40": "2600680000",
                    "fanSpeed50": "2600680000",
                    "fanSpeed60": "260068000001...",
                    "fanSpeed70": "2600680000....",
                    "fanSpeed80": "260068000001",
                    "fanSpeed90": "26006800000",
                    "fanSpeed100": "2600680000012"
                \}\
            \},\
            \{\`

With homebridge I can get all features, like speed, revert direction, etc, at homebridge and also Apple Home recognize it as a Fan.

Is there any way to do something lik I had at homebridge using Homekit at HA?

Thanks again for your help.

As long as the fan is exposed in HA as a fan entity, it should support on/off and direction already. Setting the speed is not yet supported unfortunately.

ok, but how to define as fan to HA, at broadlink configurations it is set as switch, homekit undestand it as switch. what I have to change at HA?

You would need to use the tempalate fan to map the switches to fan functions: https://www.home-assistant.io/components/fan.template/

I tried, but but could not associate it with the fans, any tip?

I include the template, one for each fan, creat scripts, but when check configurations got erros I could not manage.

I Start with on/off only, just to inclued the template

`fan:
  • platform: template
    fans:
    bedroom_fan:
    friendly_name: “Ventilador do Guarto”
    value_template: “{{ states(‘input_boolean.state’) }}”
    speed_template: “{{ states(‘input_select.speed’) }}”
    oscillating_template: “{{ states(‘input_select.osc’) }}”
    direction_template: “{{ states(‘input_select.direction’) }}”
    turn_on:
    service: script.fan_q_on
    turn_off:
    service: script.fan_q_off

set_speed:

service: script.fan_speed

data_template:

speed: “{{ speed }}”

set_oscillating:

service: script.fan_oscillating

data_template:

oscillating: “{{ oscillating }}”

set_direction:

service: script.fan_q_direction

data_template:

direction: “{{ direction }}”

speeds:

- ‘1’

- ‘2’

- ‘3’

`
Also creat the scripts for it

`fan_q_on:
  • service: switch.turn_on
    entity_id: switch.ventilador_power_q

fan_q_off:

  • service: switch.turn_off
    entity_id: switch.ventilador_power_q

`

and got invalid configuration

nvalid config for [script]: expected a dictionary for dictionary value @ data[‘script’][‘fan_q_off’]. Got [OrderedDict([(‘service’, ‘switch.turn_off’), (‘entity_id’, ‘switch.ventilador_power_q’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_q_on’]. Got [OrderedDict([(‘service’, ‘switch.turn_on’), (‘entity_id’, ‘switch.ventilador_power_q’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_s_off’]. Got [OrderedDict([(‘service’, ‘switch.turn_off’), (‘entity_id’, ‘switch.ventilador_power’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_s_on’]. Got [OrderedDict([(‘service’, ‘switch.turn_on’), (‘entity_id’, ‘switch.ventilador_power’)])]. (See /config/configuration.yaml, line 48). Please check the docs at https://home-assistant.io/components/script/

sorry, I’m not a developer.

Please start by using Markdown when posting yaml or error messeages, otherwise I can’t help you. This might be useful: https://support.discordapp.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-

It’s for discord, but our forum supports nearly all of it.

Really sorry,

I copy the template code, set most of it as comment (#), just to test ON/OFF command

platform: template
 fans:
 bedroom_fan:
 friendly_name: “Ventilador do Guarto”
 value_template: “{{ states(‘input_boolean.state’) }}”
 speed_template: “{{ states(‘input_select.speed’) }}”
 oscillating_template: “{{ states(‘input_select.osc’) }}”
 direction_template: “{{ states(‘input_select.direction’) }}”
 turn_on:
 service: script.fan_q_on
 turn_off:
 service: script.fan_q_off

Creat the scripts

service: switch.turn_on
entity_id: switch.ventilador_power_q
fan_q_off:

service: switch.turn_off
entity_id: switch.ventilador_power_q`

and got an invalid configuration error

invalid config for [script]: expected a dictionary for dictionary value @ data[‘script’][‘fan_q_off’]. Got [OrderedDict([(‘service’, ‘switch.turn_off’), (‘entity_id’, ‘switch.ventilador_power_q’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_q_on’]. Got [OrderedDict([(‘service’, ‘switch.turn_on’), (‘entity_id’, ‘switch.ventilador_power_q’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_s_off’]. Got [OrderedDict([(‘service’, ‘switch.turn_off’), (‘entity_id’, ‘switch.ventilador_power’)])]
expected a dictionary for dictionary value @ data[‘script’][‘fan_s_on’]. Got [OrderedDict([(‘service’, ‘switch.turn_on’), (‘entity_id’, ‘switch.ventilador_power’)])]. (See /config/configuration.yaml, line 48). Please check the docs at https://home-assistant.io/components/script/`

I read the scripts link, but can’t manage the error

Please post the whole scripts. As it seems now: Your formatting is wrong.
You could also use the script editor. That’s probably easier.

Hi,

I’ve made a few attemps, put the script inside the template, ot works for on/off, now I’m trying to se the reverse and velocity, even if it works only at HA interface

The code at configuraton yaml is:

fans:
  bedroom_fan:
    friendly_name: "Ventilador do Guarto"
    value_template: "{{ states('input_boolean.state') }}"
    speed_template: "{{ states('input_select.speed') }}"
    oscillating_template: "{{ states('input_select.osc') }}"
    direction_template: "{{ states('input_select.direction') }}"
    turn_on:
      service: switch.turn_on
      entity_id: switch.ventilador_power_q
    turn_off:
      service: switch.turn_off
      entity_id: switch.ventilador_power_q
    set_speed:
       service: script.fan_speed
       data_template:
         speed: "{{ speed }}"
         event_data:
           state: '1'
           service: switch.turn_on
           entity_id: switch.quarto_nivel_1
         event_data:
           state: '2'
           service: switch.turn_on
           entity_id: switch.quarto_nivel_2
         event_data:
           state: '3'
           service: switch.turn_on
           entity_id: switch.quarto_nivel_3
    set_direction:
      service: switch.turn_on
      entity_id: switch.quarto_inverter
    speeds:
      - '1'
      - '2'
      - '3' 

ON/OFF is working and also Homekit recognize it as a fan, thanks, but direction is not working, i believe i didn’t understand how to work with variables at the code, speed and direction havve variables, on/off not.