Script not working and non helpful error message

Hey all,

I tried to write an automation to set my offset for the termostat automaticaly.
However I get an error when saving “Message malformed: not a valid value for dictionary value @ data[‘type’]”

Here is my Yaml (based on a automation from the visual editor with added pices from here: Tado set offset using separate temperature sensor)

mode: single
variables:
  thermos_temp: "{{ state_attr(climate.tze200_6rdj8dzm_ts0601_thermostat_2, 'current_temperature') | float }}"
  current_offset: "{{ states(number.tze200_6rdj8dzm_ts0601_number_temperature_calibration_2) | float }}"
  actual_temp: "{{ states(sensor.lumi_lumi_sens_temperature) | float }}"
  calculated_offset: "{{ ( ( actual_temp - thermos_temp ) + current_offset ) | round }}"
trigger:
  - platform: device
    device_id: 7edea5c1c3aebdee5dc137a4c85c7d0f
    domain: climate
    entity_id: 712e8ec167f3b4ac9dc8443196cc86cd
    type: current_temperature_changed
condition: []
action:
  - device_id: 7edea5c1c3aebdee5dc137a4c85c7d0f
    domain: number
    entity_id: 0b380c53d0687df2b882e8042a2b83a4
    type: set_value
    value: "{{ calculated_offset }}"

Any hint what’s wrong here?

Not sure if this is the problem or not, but you’re not specific what to round to.

Try:
calculated_offset: "{{ ( ( actual_temp - thermos_temp ) + current_offset ) | round(0) }}"
…if you want a whole number.

Thanks for the repsonse, but I get the same error even when specified.

Have you tried putting that calculation into developer tools / template ?

You can’t add templates to a Device Action so change it to a Service Call.

action:
  - service: number.set_value
    target:
      entity_id: 0b380c53d0687df2b882e8042a2b83a4
    data:
      value: "{{ calculated_offset }}"

For future reference:

Why and how to avoid device_ids in automations and scripts - Community Guides - Home Assistant Community (home-assistant.io)

4 Likes