Script: Ecobee Fan: Malformed: extra key not allowed

Hi All,

Goal: Toggle switch for ecobee fan.

What Works: The following raw code works just fine for a “turn on” button but it’s not a toggle switch.

      - type: entities
        entities:
          - type: button
            name: Turn On Ecobee Fan
            icon: mdi:fan
            tap_action:
              action: call-service
              service: climate.set_fan_mode
              service_data:
                entity_id: climate.home
                fan_mode: 'on'

My understanding is that for a toggle switch I’ll need to start with a script to turn on and off the fan. So, I have this script started:

script:
  toggle_ecobee_fan:
    alias: Toggle Ecobee Fan
    sequence:
      - service: climate.set_fan_mode
        data:
          entity_id: climate.home
          fan_mode: 'on'

Error:

Message malformed: extra keys not allowed @ data[‘script’]

Help appreciated. Seems so simple to do, not sure what I’m doing wrong…

How and where did you put the script? Did you use the script UI? If not I would advise to do so. It helps you a lot. Then you can learn from the yaml it produces.

I raw code almost everything…it’s my learning process. As far as where I put it, I did that code in the yaml editor within scripts settings. I think I figured it out (with the help of ChatGPT) but trying to finalize now.

The script editor knows for sure what goes where, chatgpt is just guessing. Neither is you coding, and only one of those helping hands is giving you correct yaml. So if you want to learn from anything, … you know my advice.

But inside scripts.yaml there should no longer be script: on top. That is already done in configuration.yaml.

Develper tool is your friend

then

fix it in yaml mode

then you can paste it in your script this is the way i do ti

The editor in developer tools is a subset of the automation/script editor. The developer tools just uses the action part for one single action, but it cant do building blocks, compound statements, conditions or triggers.

There’s nothing wrong with manual coding if you know what goes where. I do it a lot too. The automation editor can teach you the structure when in doubt. Just switch to raw mode afterward and see what it produced.

Resolve:

Relevant Scripts:

alias: Ecobee Off
sequence:
  - data:
      entity_id: climate.home
      fan_mode: auto
    action: climate.set_fan_mode
description: ""
icon: mdi:fan
alias: Ecobee On
sequence:
  - data:
      entity_id: climate.home
      fan_mode: "on"
    action: climate.set_fan_mode

Connected that to a simple boolean toggle and then here’s my Lovelace raw code:

      - type: custom:button-card
        icon: mdi:lightbulb
        name: Nb lights on
        tap_action:
          action: toggle
          entity: input_boolean.ecobee_fan

Working on modifying that button to a custom button card and integrate it into my overall UX experience.