#Automation always fails with Message malformed: extra keys not allowed @ data['0'] – how to debug

1 messages · Page 1 of 1 (latest)

shrewd sluice
#

Hi all,

I’m struggling with an automation that always fails to load with this error:

Message malformed: extra keys not allowed @ data['0']

The problem is that Home Assistant does not tell me WHICH key is invalid, so I’m stuck guessing.

Context:

  • Home Assistant Core
  • automations.yaml in YAML mode
  • Other automations in the same file work fine
  • notify.mobile_app_* works in other automations
  • This error appears even when I remove triggers and conditions

This automation fails:

- id: highest_humidity_room_manual_test
  alias: TEST  Highest humidity room (manual)
  mode: single

  actions:
    - action: notify.mobile_app_justy2
      data:
        title: "TEST humidity"
        message: >
          {% set ns = namespace(room='', value=0) %}

          {% set v = states('sensor.adela_humidity') | float(0) %}
          {% if v > ns.value %}{% set ns.room = 'Adela' %}{% set ns.value = v %}{% endif %}

          {% set v = states('sensor.john_humidity') | float(0) %}
          {% if v > ns.value %}{% set ns.room = 'John' %}{% set ns.value = v %}{% endif %}

          {% set v = states('sensor.living_room_humidity') | float(0) %}
          {% if v > ns.value %}{% set ns.room = 'Living room' %}{% set ns.value = v %}{% endif %}

          {% set v = states('sensor.bedroom_humidity') | float(0) %}
          {% if v > ns.value %}{% set ns.room = 'Bedroom' %}{% set ns.value = v %}{% endif %}

          {% set v = states('sensor.storage_humidity') | float(0) %}
          {% if v > ns.value %}{% set ns.room = 'Storage' %}{% set ns.value = v %}{% endif %}

          Result: {{ ns.room }} ({{ ns.value }} %)

Questions:

  1. Is there any way to get MORE DETAILED validation errors than just data['0']?
  2. Is there a recommended way to TEST automations schema-wise before runtime?
  3. Is this error usually caused by:
    • missing required keys (like triggers),
    • mixing old/new automation syntax,
    • or something else entirely?

Any advice on how to debug these schema errors properly would be really appreciated.

naive hearth
#

Are you trying to create an automation without triggers?

shrewd sluice
#

First I tried to create trigger once per hour but now I just wanted to try manual so yea

naive hearth
#

An automation needs a trigger section

#

If you don't want a trigger, you can create a script

shrewd sluice
#

I wanted to have trigger once per hour but when getting errors i wanted to try if trigger isnt the issue :/

naive hearth
#

At least add

  triggers: []
shrewd sluice
#

wellp still getting Message malformed: extra keys not allowed @ data['0'] even after adding ```yaml
triggers: []

naive hearth
#

I've tested it in the GUI (I'm on mobile right now) and I was able to save this automation without issues

alias: TEST – Highest humidity room (manual)
mode: single
triggers: []
actions:
  - action: notify.mobile_app_justy2
    data:
      title: TEST humidity
      message: >
        {% set ns = namespace(room='', value=0) %}

        {% set v = states('sensor.adela_humidity') | float(0) %} {% if v >
        ns.value %}{% set ns.room = 'Adela' %}{% set ns.value = v %}{% endif %}

        {% set v = states('sensor.john_humidity') | float(0) %} {% if v >
        ns.value %}{% set ns.room = 'John' %}{% set ns.value = v %}{% endif %}

        {% set v = states('sensor.living_room_humidity') | float(0) %} {% if v >
        ns.value %}{% set ns.room = 'Living room' %}{% set ns.value = v %}{%
        endif %}

        {% set v = states('sensor.bedroom_humidity') | float(0) %} {% if v >
        ns.value %}{% set ns.room = 'Bedroom' %}{% set ns.value = v %}{% endif
        %}

        {% set v = states('sensor.storage_humidity') | float(0) %} {% if v >
        ns.value %}{% set ns.room = 'Storage' %}{% set ns.value = v %}{% endif
        %}

        Result: {{ ns.room }} ({{ ns.value }} %)
description: ""
shrewd sluice
#

well problem I found was that ```yaml

  • id:
#

However is there any option to detect more from error? like what HA cannot resovle?

naive hearth
#

Looks like this in automations.yaml

- id: '1766346947217'
  alias: TEST  Highest humidity room (manual)
  description: ''
  triggers: []
  actions:
  - action: notify.mobile_app_justy2
    data:
      title: TEST humidity
      message: '{% set ns = namespace(room='''', value=0) %}

        {% set v = states(''sensor.adela_humidity'') | float(0) %} {% if v > ns.value
        %}{% set ns.room = ''Adela'' %}{% set ns.value = v %}{% endif %}

        {% set v = states(''sensor.john_humidity'') | float(0) %} {% if v > ns.value
        %}{% set ns.room = ''John'' %}{% set ns.value = v %}{% endif %}

        {% set v = states(''sensor.living_room_humidity'') | float(0) %} {% if v >
        ns.value %}{% set ns.room = ''Living room'' %}{% set ns.value = v %}{% endif
        %}

        {% set v = states(''sensor.bedroom_humidity'') | float(0) %} {% if v > ns.value
        %}{% set ns.room = ''Bedroom'' %}{% set ns.value = v %}{% endif %}

        {% set v = states(''sensor.storage_humidity'') | float(0) %} {% if v > ns.value
        %}{% set ns.room = ''Storage'' %}{% set ns.value = v %}{% endif %}

        Result: {{ ns.room }} ({{ ns.value }} %)

        '
  mode: single
#

Well data[0] was an indication it was one of the keys on the top level of the automation

shrewd sluice
#

however in automations.yaml you see id but in gui you cannot insert it its bit weird

naive hearth
#

But it looks like a valid id to maybe just not in automations.yaml

#

Oh, you had this code in the YAML editor in the GUI?

#

It was not copied from automations.yaml

#

Then the error was the dash -