Float/Number Error

I’m trying to create an automation which sends the current outdoor temperature to a thermostat. I receive an error saying expected float for dictionary value @ data['value']

YAML configuration:

device_id: 07dfa26accf367c648f6cbeab1b3e312
domain: number
entity_id: 61be168ab07d186c1ef6652c969ac416
type: set_value
value: {{ states('sensor.openweathermap_temperature') }}

I’ve tested a few templates in the developer tools template editor:
{{ states('sensor.openweathermap_temperature') }} returns number
{{ states('sensor.openweathermap_temperature') | float }} returns number
{{ float(states('sensor.openweathermap_temperature')) }} returns number

According to the error message value needs to be a float but it is getting a number. I’m not sure how to fix this.

device_id: 07dfa26accf367c648f6cbeab1b3e312
domain: number
entity_id: 61be168ab07d186c1ef6652c969ac416
type: set_value
value: "{{ states('sensor.openweathermap_temperature') | float }}"

I’ve tried that already. Same error message. Adding the quotes doesn’t fix it either

That is how you template a float.
Since you didn’t give us more than that then we can’t possibly know what is the issue.
We don’t even know what the device is or what value you are trying to set

Edit…
You can’t template a device action make it a normal action

The device is TH1123ZB. That page details how to set the outdoor temperature.

- id: 'Auto_Publish_Outdoor_Temprature'
  alias: Auto_Publish_Outdoor_Temprature
  description: Automatically Publish the outdoor temperature to thermostats
  trigger:
  - entity_id: sensor.outdoor_temprature_sensor
    platform: state
  condition: []
  action:
  - data:
      payload: '{{ states(''sensor.outdoor_temprature_sensor'') | string }}'
      topic: zigbee2mqtt/<FRIENDLY_NAME>/set/thermostat_outdoor_temperature
    service: mqtt.publish

What is the difference between a device action and normal action?

Device actions are not templateable.
Other actions are.
You can’t use single quotes. I’m fairly sure it has to be double

Here is my current config

That’s a device action. Use Other Actions / Perform Action instead.

I got it working with this

action: mqtt.publish
metadata: {}
data:
  topic: zigbee2mqtt/bedroom_matt_thermostat/set/thermostat_outdoor_temperature
  payload: "{{ states('sensor.openweathermap_temperature') }}"

I’m just wondering why I have to manually use MQTT and not exposed entities in the automation.

Because, by design, a sensor entity’s value is read-only. It’s value is controlled exclusively by its integration.

For example, your phone battery’s charge level would be represent by a sensor entity. It would be unusual to allow manually forcing the sensor’s value to be anything other than the battery’s true value. That’s why there’s no dedicated sensor.set_value action.

Zigbee2MQTT acts as a translator, converting a physical device’s parameters into MQTT topics and payloads. Those payloads can be used any number of different ways (not just by Home Assistant) so it allows you to change them.