I am trying to create an Helpers type “Template” with the goal of converting a value from km/h to m/s, which means that I need to divide an entity with 3.6.
I am choosing “Template a sensor” and choosing/writting the following:
Name: Wind
State template: {{ states(‘sensor.are_wind_speed’ / 3.6) |round(1)}}
Unit of measurement: m/s
Device class: Wind speed
State class: Measurement
When I am ready and open my helpers “Wind”, I don’t get any value, just “Unavailable”.
Has anyone any idea about what I am doing wrong?
Thank’s!
This is the nasty smart quote feature some editors have (mac, ipad, etc.). They change plain quotes in curly ones. They look nice but don’t work in code. Change the qurly quotes to plain ’ quotes and you should be fine.
And check your keyboard settings where you edited the template, and turn the smart quotes feature off. It will bite you more then it will help you.
Just FYI, if your wind speed sensor has the correct state_class you can change this unit from the UI. No need for a template helper. Click on your entity then: