I just got the Ecobit 720 weather station with Shelly. I am trying to convert the wind direction from degrees to text. I have created a sensor template I got from this thread. My template is in my config yaml:
#Wind Sensor Bearing
Sensor:
- platform: template
sensors:
wind_direction:
value_template: >
{% set direction = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','N'] %}
{% set degree = states('sensor.weather_station_wind_direction')|float %}
{{ direction[((degree+11.25)/22.5)|int] }}
I see that there are a few different ways to create this template but I can’t seem to get any to work. This template does not create a new entity or convert the original entity to text. I’m not sure what I’m doing wrong. Can anyone point me in the right direction?
UPDATE I just pasted the template in the developer template editor and it is returning the proper text for wind direction. I am not sure how to update the actual weather station sensor to show the template output over the degrees.
I’m not 100% sure if it matters, but the integration keys are normally lowercase i.e. sensor: not Sensor:
Did you restart HA after editing configuration.yaml?
Just FYI, that is the old template syntax which will be fully deprecated in a little over 3 months. You will need to convert it to the current syntax by then or set it up in the UI under the Helpers menu.
You don’t. Template sensors do not replace or overwrite their source(s). They are their own entities. If you want to be able to add the new sensor to the weather station device in HA you must set it up through the Helpers menu… YAML configured template entities cannot be added to devices at this time.
Can you point me in the right direction on how to make this in the helper menu? I tried to create a new helper and selected sensor. But pasting the YAML is not the correct way to make it work and I’m not sure what info the helper needs? Like what is the unit of measurement I need to select?
First, erase or comment out the old sensor config and reload Template Entities or Restart HA. This will prevent you from ending up with two of the same sensor.
In the Helper Menu click New Helper, select Template, then Sensor. Then you just put the value from the yaml in their corresponding fields in the Helper config flow. For the configuration above that means you put “Wind Direction” in the Name field and the template in the State field. Neither the Unit of Measurement, Device Class, nor the State Class fields apply to your sensor.