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

Hello,

I created a small notification for my heater. In the notification it will display the current temperature, when I click on “run” I will recieve the notifications on my phone without a problem.

But when I save the automation, I will get the following error: Message malformed: extra keys not allowed @ data[‘for’]

This are my notifications:


Because the only thing the Run command does is execute the automation’s actions. It doesn’t exercise the automation’s trigger or condition.

Where are you using the for option in your automation? It’s not present in either of the screenshots you posted.

Post the entire automation in YAML format (not as a screenshot).

Reference

FAQ Guideline 11 - Format it properly.
FAQ Guideline 14 - Screenshots

I’m not using the “for” anywhere I think. Only for the duration of 5 sec. But I removed it and still the same error, here is the full automation:

description: “”
mode: single
trigger:

  • type: temperature
    platform: device
    device_id: 7d98dd9c356c20a7bf3ae8bf80aca0ba
    entity_id: 07639b74138799c4c7f0cfbcde4defcc
    domain: sensor
    below: 18
    id: It’s Cold
  • type: temperature
    platform: device
    device_id: 7d98dd9c356c20a7bf3ae8bf80aca0ba
    entity_id: 07639b74138799c4c7f0cfbcde4defcc
    domain: sensor
    above: 18.4
    id: It’s hot Enough
  • platform: device
    device_id: 7d98dd9c356c20a7bf3ae8bf80aca0ba
    domain: climate
    entity_id: 21c4ead024196e05ecf529f021636d0a
    type: hvac_mode_changed
    to: heat
    id: Heating On Notification
    for:
    hours: 0
    minutes: 0
    seconds: 5
  • platform: device
    device_id: 7d98dd9c356c20a7bf3ae8bf80aca0ba
    domain: climate
    entity_id: 21c4ead024196e05ecf529f021636d0a
    type: hvac_mode_changed
    to: “off”
    id: Heating Off Notification
    for:
    hours: 0
    minutes: 0
    seconds: 5
    condition:
    action:
  • choose:
    • conditions:
      • condition: trigger
        id:
        • It’s Cold
          sequence:
      • service: climate.set_temperature
        metadata: {}
        data:
        temperature: 18.5
        hvac_mode: heat
        target:
        entity_id: climate.woonkamer
    • conditions:
      • condition: trigger
        id:
        • It’s hot Enough
          sequence:
      • service: climate.set_hvac_mode
        metadata: {}
        data:
        hvac_mode: “off”
        target:
        entity_id: climate.woonkamer
    • conditions:
      • condition: trigger
        id:
        • Heating On Notification
          sequence:
      • service: notify.notify
        metadata: {}
        data:
        message: Home Assistant Notifications
        title: >-
        Heater has turned on.:fire: Current temperature is
        {{state_attr(‘climate.woonkamer’, ‘current_temperature’)}} °C
    • conditions:
      • condition: trigger
        id:
        • Heating Off Notification
          sequence:
      • service: notify.notify
        metadata: {}
        data:
        message: Home Assistant Notification
        title: >-
        Heater has turn off.:fire: Current temperature is
        {{state_attr(‘climate.woonkamer’, ‘current_temperature’)}} °C
        alias: :black_circle: Turn On And :radio_button: Turn Off •:fire:Keep House Warm

Please read the links that Taras provided and then edit your reply so we can read it.

1 Like

I am having the same issue. Here is a picture of the automation, with the error at the top left:

Post the entire YAML as correctly-formatted code.

It’s possible that the device trigger doesn’t support for. Recommend changing to an entity-based state trigger.

Yes, this is the fix. I used an entity-based state trigger, and the duration worked