Fan Template Error when adding Input Boolean

Hi, i’ve spent the last few weeks trying to automate my ceiling fan using a Broadlink RM Pro. I have a toggle setup on my dashboard to turn it on which was working, but then I tried to setup an input boolean to remember the state, and then it started giving me the following error when I try and switch it on/off.

failed to call service fan/turn_on. extra keys not allowed @ data['target']

Below is the config I have. I assume it doesnt like the input_boolean code in the scripts.yaml, but i’ve seen other people using this same code.

I’m surprised at how difficult this config has been. I thought setting up the RF scripts would be hard but that was a walk in the park compared to setting up these scripts. This is just to get the fan to turn on/off, i’m not even at the point of trying to get the speeds or direction working.

Any help appreciated.

configuration.yaml

fan:
  - platform: template
    fans:
      living_room_fan:
        friendly_name: "Living Room Fans"
        value_template: "{{ states('input_boolean.living_room_fan_state') }}"
        percentage_template: "{{ states('input_number.living_room_fan_percentage') }}"
        direction_template: "{{ states('input_select.living_room_fan_direction') }}"
        turn_on:
          service: script.living_room_fans_power_on
        turn_off:
          service: script.living_room_fans_power_off
        set_direction:
          service: script.living_room_fans_direction
          data_template:
            direction: "{{ direction }}"
        set_percentage:
          service: script.fans_set_speed
          data_template:
            percentage: "{{ percentage }}"
        speed_count: 6

scripts.yaml

living_room_fans_power_on:
  alias: living_room_fans_power_on
  sequence:
    - service: remote.send_command
      data:
        device: living_room_fans
        command: power_on
        target:
          entity_id: remote.rm_pro_remote
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.living_room_fan_state
  
living_room_fans_power_off:
  alias: living_room_fans_power_off
  sequence:
    - service: remote.send_command
      data:
        device: living_room_fans
        command: power_off
        target:
          entity_id: remote.rm_pro_remote
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.living_room_fan_state

Nope. It does not like the fact that you are using target: in the remote.send_command data block. It should be at the same level as data:, like this:

living_room_fans_power_on:
  alias: living_room_fans_power_on
  sequence:
    - service: remote.send_command
      data:
        device: living_room_fans
        command: power_on
      target:
        entity_id: remote.rm_pro_remote

The error was a dead give away:

Same goes for your off script.

Thanks tom_l that was the issue and i’m surprised I didnt notice it, i’m still very much a noob when it comes to yaml.

1 Like