What does the error "extra keys not allowed @ data['xxxx']..." mean?

This gets asked a lot. Obviously it means there’s something wrong with your yaml, but what?.

The error can point to a variety of things, but you should be able to locate the problem by searching for the key given in the square brackets.

YAML stores each item of data along with a key to identify it. The keys are the words followed by a colon - depending on the editor you’re using they may also be highlighted.

Screenshot 2025-01-18 15.52.00

So if the error is “extra keys not allowed @ data[‘trigger’]” check the triggers in your automation for problems.

Common problems

Syntax errors

The most common issue is incorrect spacing. If a key contains other keys, YAML expects lines to be indented.

This will work - the actions key contains if and then keys, which contain further keys:

actions:
  - if:
      - condition: trigger
        id:
          - detected
    then:
      - target:
          entity_id: switch.all_living_room_lights
        action: switch.turn_on

This will not (because the condition key is not indented):

actions:
  - if:
  - condition: trigger
    id:
      - detected
    then:
      - target:
          entity_id: switch.all_living_room_lights
        action: switch.turn_on

By convention, indentations in HA are two spaces, but any number of spaces will do provided they are all the same.

Lists are another common cause of error. This will work:

service: homeassistant.turn_on
data:
  entity_id:
    - light.one
    - light.two

and this will work:

service: homeassistant.turn_on
data:
  entity_id: light.one, light.two

…but this will not:

service: homeassistant.turn_on
data:
  entity_id:
    light.one
    light.two

…because the list of entities is incorrectly formatted.

Unsupported keys

If you’re editing a script, the trigger: key will generate an error - scripts don’t have triggers. If you’re editing an automation, fields: will do it - automations can’t have fields.

Check your typing!

triggers:
  - tigger: state
    entity_id:
      - input_boolean.away_mode
    to: "on"

The Home Assistant Cookbook - Index

2 Likes