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

Hello, I have the following issue with my Automation. When run it, I get:

extra keys not allowed @ data[‘temperature’]

Can you help me to solve this issue?

The Automation is as follows:

description: ""
trigger:
  - platform: time
    at: input_datetime.invoer_tijd_test
condition: []
action:
    - service: number.set_value
      data:
        device_id: fef2fb734ec32de89ee7c1e125e243c2
        temperature: 17.0   
mode: single```

And the return I get:
Uitgevoerd op: 8 december 2024 om 19:55:04
Fout: extra keys not allowed @ data['temperature']
Resultaat:
params:
  domain: number
  service: set_value
  service_data:
    device_id: fef2fb734ec32de89ee7c1e125e243c2
    temperature: 17
  target: {}
running_script: false
1
2
3
4
⌄
data:
  device_id: fef2fb734ec32de89ee7c1e125e243c2
  temperature: 17
action: number.set_value

You can’t set the temperature of a number entity.

What is that device?

That is smo40:
entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1

Then:

action:
  - service: number.set_value
    data:
      value: 17
    target:
      entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1

or in current version (action > actions, service > action):

actions:
  - action: number.set_value
    data:
      value: 17
    target:
      entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1

Either that, or you need to call climate.set_temperature on your climate entity.

Thanx for the information!
I will try the suggestions.

This works for me, but I get: running_script: false:

‘’'actions:

  • data:
    value: 15
    target:
    entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1
    action: number.set_value’‘’

That’s normal — the script isn’t running when you look.

Ok. I am happy that the issue is solved.

Hi Troon,
The problem with the extra keys is solved. The situation is that the Temperature is set immidiatly when I start the automation. What I like is that the Temperature is set at the set time. Do you have a solution for that?

Please post the correctly-formatted YAML for the automation as it stands now.

What do you mean by “when I start the automation”?

When I start the entitycard:
‘’‘type: entity
entity: automation.verwarming_aan_op_gegeven_tijd
name: verw aan op tijd’‘’

Automation:
‘’'alias: Verwarming aan op gegeven tijd
description: “”
trigger:

  • platform: time
    at: input_datetime.invoer_tijd_test
    condition:
    action:
  • service: number.set_value
    data:
    value: 15
    target:
    entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1
    mode: single’‘’

alias: Verwarming aan op gegeven tijd

trigger:
  - platform: time
    at: input_datetime.invoer_tijd_test
condition: []
action:
  - service: number.set_value
    data:
      value: 15
    target:
      entity_id: number.smo_40_room_sensor_set_point_value_heating_climate_system_1
mode: single