Hello ya’ll. Same thing here. Trying to convert wind direction degrees into text. All the code provided here gave me errors and also it looked quite different to the other sensor i had set up in my config. I adapted it to the same format, no errors, bit also no new entity.
What am I doing wrong?
Total noob here, so please bare with me.
Her is my complete config.yaml
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template:
- sensor:
- name: "Technical & Garden | Power"
unit_of_measurement: W
icon: mdi:lightning-bolt
state: >-
{{ (states('sensor.shellyproem50_08f9e0e5c190_em0_power')|float -
states('sensor.shellyproem50_08f9e0e5c190_em1_power')|float )|round(1) }}
- sensor:
- name: "Wind Direction TXT"
icon: mdi:navigation
value_template: >
{% set dir = int(states('sensor.gw2000a_wind_direction') | float %}
{% set navDir = [ 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N' ] %}
{{ navDir[int(dir/22.5)] }}