My wind direction sensor sends the direction in degrees: 0 is North, 45 is North-East, 90 is East and so on untill 315 for North-West. This works fine with below code in configuration.yaml
Now I am struggling to convert the degrees to directions because I would replace the degrees in my card with text like North, North-West, East and so on. Can someone tell me how to do this?
Hi Hans,
this is exactly what Gary does in his answer. So what’s the problem with applying this to your situation? You have to create a template sensor with the code he posted and just replace the entity id “sensor.wind_dir” with the name of your sensor, probably sth like sensor.windrichtung.
Unfortunately, I have too little experience with Home Assistant to set this up properly, so I did not succeed. Because I am more experienced with NodeRED I solved it with a node: https://github.com/bartbutenaers/node-red-contrib-compass The node translates compass degrees to wind directions (text). While I use MQTT this is a perfect solution for my setup.
Can anyone explain to me,
It worked perfectly, until I reinstalled HA, trying to embed the script again, it no longer works! (I am a beginner (I am a beginner)
{% set direction = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','N'] %}
{% set degree = states('sensor.openweathermap_wind_bearing')|float %}
{{ direction[((degree+11.25)/2
A Template Sensor Helper currently supports some but not all of what a Template Sensor can do.
In its current form, the options it offers are meant to handle the majority of basic needs. However if you want to select or template the sensor’s icon, or handle availability, or create attributes, or etc, it doesn’t support those options.
If you are already familiar with creating Template entities in YAML, there’s little advantage for you to switch to using a Template Helper.