I cant get data_template for a calculation of the set temperature on the climate to work

Hey guys,

I’ve searched quite a lot and tried everything but I cant get it to work.

Saving this automation in the gui results in the error message:

Message malformed: required key not provided @ data[‘trigger’]

Hope you can help me!

alias: 'Heating: Set temperature for default mode - Bedroom'
description: ''
trigger:
  - platform: state
    entity_id: input_number.target_temp_bedroom
    for: '00:00:04'
  - platform: state
    entity_id: input_boolean.heating_bedroom
    to: 'true'
    for: '00:00:04'
  - platform: state
    entity_id: input_select.heating_forced_off_weather
    to: 'no'
  - platform: state
    entity_id: input_select.heating_mode_bedroom
    to: default
    for: '00:00:04'
  - platform: state
    entity_id: sensor.temp_sensor_bedroom_temperature
    for: '00:00:04'
  - platform: state
    entity_id: climate.radiator_valve_bedroom
    attribute: local_temperature
    for: '00:00:04'
condition:
  - condition: state
    entity_id: input_boolean.heating_bedroom
    state: 'true'
  - condition: state
    entity_id: input_select.heating_forced_off_weather
    state: 'no'
  - condition: state
    entity_id: input_select.heating_mode_bedroom
    state: 'default'
action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.radiator_valve_bedroom
      temperature: '{{ ((states('input_number.target_temp_bedroom') | float - states('sensor.temp_sensor_bedroom_temperature') | float ) * 2 + state_attr('climate.radiator_valve_bedroom', 'local_temperature') | float) | round(1, "half")}}'
mode: restart

Thanks in advance!

You need to supply a to: state to use for:

There are far more ‘malformed’ things than just what the error message reported.

What is the intended purpose of all of those for: '00:00:04' lines?

Ah okay. I was expecting that this would filter out values which are flipping back and forth.

But I don’t really need those, I guess.

I fixed it myself. Was a bit tired last night :smiley:

So it’s just an issue with the quotation marks :slight_smile:

This is what worked for me in the end:

alias: 'Heating: Set temperature for default mode - Bedroom'
description: ''
trigger:
  - platform: state
    entity_id: input_number.target_temp_bedroom
  - platform: state
    entity_id: input_boolean.heating_bedroom
    to: 'true'
  - platform: state
    entity_id: input_select.heating_forced_off_weather
    to: 'no'
  - platform: state
    entity_id: input_select.heating_mode_bedroom
    to: default
  - platform: state
    entity_id: sensor.temp_sensor_bedroom_temperature
  - platform: state
    entity_id: climate.radiator_valve_bedroom
    attribute: local_temperature
condition:
  - condition: state
    entity_id: input_select.heating_mode_bedroom
    state: default
  - condition: state
    entity_id: input_select.heating_forced_off_weather
    state: 'no'
  - condition: state
    entity_id: input_boolean.heating_bedroom
    state: 'on'
action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.radiator_valve_bedroom
      temperature: >-
        {{ ((states("input_number.target_temp_bedroom") | float -
        states("sensor.temp_sensor_bedroom_temperature") | float ) * 2 +
        state_attr("climate.radiator_valve_bedroom", "local_temperature") |
        float) | round(1, "half")}}
mode: queued
max: 10

I don’t think this will ever trigger,the state of an input_boolean is either ‘on’ or ‘off’, but not ‘true’.

Are you sure? I remember having used for: without to:, but maybe I remember it incorrectly.

1 Like

Seems you are right. This example is from the docs:

In this example, the trigger fires if the state value of the entity remains the same for for the time specified, regardless of the current state value.

automation:
  trigger:
    platform: state
    entity_id: media_player.kitchen
    # The media player remained in its current state for 1 hour
    for: "01:00:00"
1 Like

Came here to say the same thing: input_boolean’s state will never be true.

Try changing the state of input_boolean.heating_bedroom. It can never be true, only on or off, so it will fail to trigger this:

  - platform: state
    entity_id: input_boolean.heating_bedroom
    to: 'true'

Go to Developer Tools > States, find input_boolean.heating_bedroom and look at its current state value. Does it indicate true (or false) or on (or off)?

Screenshot from 2020-12-28 11-44-06

1 Like