Control thermostat using external temperature sensor

I am trying to set the measured temperature of a zigbee themostatic valve for a radiator (POPZ701721) with the value obtained from an external temperature sensor (Aqara T1).

I want to make this an automation that runs every X minutes.

I have the following code:

alias: Test_set_temperature
description: "Test script to set ambient temperature"
triggers:
  - trigger: time_pattern   # For testing, to be changed later.
    seconds: "59"
conditions: []
actions:
  - device_id: 4094bfe7542efb78f48d904cdc6610cc   
    domain: number
    entity_id: 948625cdda07412b2866dcf882828a32
    type: set_value
    value: {{ states('sensor.woonkamer_temperatuur')}}

But when I try to run save the automation I get the following error:

Message malformed: expected float for dictionary value @ data[‘value’]

I have tried casting the value to a float value: {{ states('sensor.woonkamer_temperatuur')|float}}, but I get the same error.

I also tried sending the value to my phone in a message, this does work, I get a message with the temperature in Celcius:

  - device_id: a8d0ae82e05bd72c0d321463a04e56a5
    alias: Stijn_telefoon
    domain: mobile_app
    type: notify
    message: Test
    title: "Temperatuur: {{ states('sensor.woonkamer_temperatuur') }}"

How can I use the value of sensor.woonkamer_temperatuur to set the value of the thermostat valve?

I’m sorry for the noob question, I have experience with python, but I just can’t seem to wrap my head around how home assistant yaml is supposed to work…

At least some of these apply:

  • Single-line templates must be quoted (ref)
  • Device actions don’t support templates (ref)
  • Need to cast a string state to a float with |float(0)
1 Like

Thank you @Troon :partying_face: :partying_face: :partying_face:!

I had no idea what templates were, but with the links you provided I figured out how to use them! I was wondering why i had those ugly unreadable device/entity_id’s instead of clean names.
The working code looks like:

alias: Test_set_temperature
description: Test script to set ambient temperature
triggers:
  - trigger: time_pattern
    seconds: "59"
conditions: []
actions:
  - action: number.set_value # the actual setting
    data:
      value: "{{states('sensor.woonkamer_temperatuur')}}"
    target:
      entity_id: number.kantoor_thermostaat_external_temperature_sensor
  - action: notify.mobile_app_pixel_6a # For debugging
    data:
      message: "Test: {{states('sensor.woonkamer_temperatuur')}}"

(What helped me in figuring out if my code was working was using the developer tools → actions pane)