#How to create a numeric sensor from a string value?

3 messages · Page 1 of 1 (latest)

raw thistle
#

I have a few The Things Network (TTN) integrations. TTN entities always have a string value, even thought they might represent for example Celsium degrees. As a result, it shows up as shown on the screenshot, instead of a time-series chart or similar. I'd like recode the values in a more "natural"/native format. I tried adding the following snippet to my configuration.yaml:

sensor:
- platform: template
    sensors:
      templom_9_compost_temp_temperature_fixed:
        unique_id: templom_9_compost_temp_temperature_fixed
        device_class: temperature
        unit_of_measurement: "°C"
        value_template: float(sensor.templom_9_compost_temp_temperature)

While the above is valid YAML, the templom_9_compost_temp_temperature_fixed does not show any value.

How can I recode the string value as a temperature?

frozen trench
#

Set the state class to measurement

#

Also your value template needs to be "{{... }}" to get recognised