I want to log the outside temperature to compare it to the power consumed by my heat pump and the internal home temperature. Therefore I created a template sensor with below code:
template:
- sensor:
- name: Outdoor temperature
state: "{{ state_attr('weather.forecast_home','temperature') }}"
unit_of_measurement: '°C'
state_class: measurement
device_class: temperature
This code is working but the output is dot separated xx.x °C instead of comma separated xx,x °C and therefore not showing up as numerical in graphs.
Please see this post. Specifically number 11. People might want to grab your code and test it in their system. They can’t easily do that from a picture.
Your problem is a missing underscore in unit_of_measurement:. The system is ignoring that line, and without a unit of measurement defined, it is assuming non-numeric states.
Sensor None has device class ‘temperature’, state class ‘measurement’ unit ‘°C’ and suggested precision ‘None’ thus indicating it has a numeric value; however, it has the non-numeric value: ‘template: - sensor: - name: Outdoor temperature state: “-1.0”’ (<class ‘str’>)
All the other lines are for when you are editing the YAML configuration manually, not using the UI. They were ending up in the state of your sensor, which you can see in your very first screenshot.