#wind direction

1 messages · Page 1 of 1 (latest)

orchid prism
#

my wind direction codes in numbers instead of direction any way to change that any help is much appreciated

frank vector
#

Please post what you've tried and your existing sensors. Also post information about what you'd expect each degree to be

orchid prism
#

i have zero idea

azure pagoda
#

With a routine like this, it's better to turn to LLM.
{%- set degrees = states('sensor.your_wind_bearing') | float(0) -%}
{%- set directions = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] -%}
{%- if degrees < 0 or degrees > 360 -%}
Invalid value
{%- else -%}
{%- set index = ((degrees / 22.5) + 0.5) | int % 16 -%}
{{- directions[index] -}}
{%- endif -%}

orchid prism
#

THIS IS WHATI FOUND BUT HAVE NO IDEZA WHAT TO DO TO IMPLIMENT IT

#
  • platform: template
    sensors:
    weather_wind_dir:
    friendly_name: '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.wind_dir')|float %}
    {{ direction[((degree+11.25)/22.5)|int] }}
#

sorry for caps

#

i have zero idea how to impliment any of this

azure pagoda
orchid prism
#

sensor.st_00137020_wind_direction

azure pagoda
orchid prism
#

again i have zero idea on any foundation on how to code this

#

i have zero experience with writing any formula or code i know how to copy and paste into the config file or find somnethign to copy and paste thats as far as i can really figure

frank vector
#

without that info, we can't help

#

literally

#

with numbers, you need a point of reference, otherwise the numbers are meaningless

orchid prism
#

o is north

frank vector
#

alright, then what @azure pagoda posted is what you should use in a template sensor

foggy hazel
#

Go to settings > Devices & Services > Helpers and then press the button to create a new helper

#

Select Template > Template a sensor

orchid prism
#

ok im there

#

fes cani message you direct

foggy hazel
#

paste this in the field for the template:

{% set direction = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','N'] %}
{% set degree = states('sensor.st_00137020_wind_direction') %}
{{ direction[((degree | float + 11.25) / 22.5) | int] if degree | is_number else 'unknown' }}
#

don't set a state class/device class/unit of measurement

foggy hazel
frank vector
foggy hazel
#

wrongly I see now

#

now It should be correct

orchid prism
#

you are a god fes i would like to work with you more would you be open to helping me our if i could direct message you i would pay for your time and knowledge