Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wind direction value format? #196

Closed
thehijacker opened this issue Apr 25, 2021 · 6 comments · Fixed by #200
Closed

Wind direction value format? #196

thehijacker opened this issue Apr 25, 2021 · 6 comments · Fixed by #200
Assignees
Labels
bug Something isn't working

Comments

@thehijacker
Copy link

Is your feature request related to a problem? Please describe.
I am collecting wind speed from custom made wind station. I calculate wind direction inside the collection algorithm. It is displayed in HA with compass card but no translation language is working. I suspect bad value format.

Describe the solution you'd like
I wish to display wind direction in my language (Slovenian).

Describe alternatives you've considered
Well I need to know in what format must the wind direction entity be. Currently I store string value (W, S, E, N, SW, ...). Maybe it must be numeric (degrees)?.

Additional context
Here is the code that will calculate wind direction:

if(dirpin > 2.60 &&  dirpin < 2.70 ){
    wd = "E";
  }
  if(dirpin > 1.60 &&  dirpin < 1.70 ){
    wd = "SE";
  }
  if(dirpin > 0.30 &&  dirpin < 0.40 ){
    wd = "N";
  }
  if(dirpin > 0.60 &&  dirpin < 0.70 ){
    wd = "SW";
  }
  if(dirpin > 0.96 &&  dirpin < 1.06 ){
    wd = "W";
  }
  if(dirpin > 2.10 &&  dirpin < 2.20 ){
    wd = "NW";
  }
  if(dirpin > 3.15 &&  dirpin < 3.25 ){
    wd = "N";
  }
  if(dirpin > 2.95 &&  dirpin < 3.05 ){
    wd = "NE";
  }

Assembled my weather station by this guide:

https://tysonpower.de/blog/esp8266-weather-station

image

@thehijacker thehijacker changed the title Wind speed value format? Wind direction value format? Apr 25, 2021
@tomvanswam
Copy link
Owner

You should be able to use

  • numeric (in degrees, not radians or some other fancy system), the degrees can be positive or negative, they get calculated back to 0 to 360 degrees
  • string with numeric value inside. 'NE 90' will get parsed to 90 degrees
  • string, in english N, E, S and W, with up to 3 characters precision so NNE would work

So your string should work, however i might messed something up with the translation part.

What language do you have configured for the compass-card?

I'll have a look if I can find something broken.

@tomvanswam tomvanswam self-assigned this Apr 25, 2021
@tomvanswam tomvanswam added the bug Something isn't working label Apr 25, 2021
@thehijacker
Copy link
Author

I now send degree from 0 to 360 and string presentation and define it as sensor. In one I get N, S,... and with one I get value from 0 to 360. I still see only English translation. But only when direction is in degrees. If character they are in English only. Might be bug?

@thehijacker
Copy link
Author

Maybe when defining sensors I need to define also value format? What I have so far:

  - platform: mqtt
    state_topic: 'weather_station/sensors'
    name: "Weather Station Wind Degree 2"
    value_template: '{{ value_json.winddegree2 | is_defined }}'
    expire_after: 21600 # 6 hours

  - platform: mqtt
    state_topic: 'weather_station/sensors'
    name: "Weather Station Wind Direction 2"
    value_template: '{{ value_json.winddirection2 | is_defined }}'
    expire_after: 21600 # 6 hours

When displaying this in compass card I get:

image

YAML code of this view:

cards:
  - cards:
      - class: top-level-graph
        type: 'custom:compass-card'
        indicator_sensors:
          - sensor: sensor.weather_station_wind_degree_2
            indicator:
              dynamic_style:
                sensor: sensor.weather_station_wind_speed
                bands:
                  - from_value: 0
                    color: '#039BE5'
                  - from_value: 10
                    color: '#0da035'
                  - from_value: 20
                    color: '#e0b400'
                  - from_value: 30
                    color: '#e45e65'
              type: arrow_outward
        value_sensors:
          - sensor: sensor.weather_station_wind_speed
        compass:
          north:
            show: false
        header:
          title:
            value: Degree
          icon:
            value: 'mdi:weather-windy'
            color: red
            dynamic_style:
              sensor: sensor.weather_station_wind_speed
              bands:
                - from_value: 0
                  color: green
                - from_value: 3
                  color: yellow
                - from_value: 6
                  color: orange
                - from_value: 8
                  color: red
                - from_value: 11
                  color: purple
        style: 'ha-card { height: 100%; }'
        language: sl
      - type: 'custom:compass-card'
        indicator_sensors:
          - sensor: sensor.weather_station_wind_direction_2
        value_sensors:
          - sensor: sensor.weather_station_wind_speed
        header:
          title:
            value: Textual direction
        language: sl
    type: horizontal-stack
  - type: entities
    entities:
      - entity: sensor.weather_station_wind_degree_2
      - entity: sensor.weather_station_wind_direction_2
type: vertical-stack

Let me know if you need any more additional data.

Thank you.

@tomvanswam
Copy link
Owner

tomvanswam commented Apr 25, 2021

Ok I see, I misread your initial question (should not check this stuff when on mobile).

You want the SV to show for both sensors, and it only shows when using numeric degrees sensor and not when using string sensor.
The sting sensor does show the indicator at the correct position, so that's ok, however the NE does not get translated. That's most likely a bug.
Will try to fix that this week.

Nice weather station guide btw. I'll have to look into that when my 433MHz station breakes down.

@thehijacker
Copy link
Author

Exactly. When entity is numeric degrees (0-360) sensor it will show translated string, but when it is string sensor it will not translate it.

One more question. When using numeric degrees sensor I also get in between values like NNW:

image

Is there an option to show only main 8 sides (N, NE, E, SE, S, SW, W and NW)?

@tomvanswam tomvanswam mentioned this issue Apr 26, 2021
@tomvanswam tomvanswam linked a pull request Apr 26, 2021 that will close this issue
@tomvanswam
Copy link
Owner

tomvanswam commented Apr 26, 2021

When using a sensor with a numeric state there is no option to only show the main 8 directions.

When using a sensor with a string state (as you started off with) you're in control yourself (but more than 16 is not possible).

If you would like this config option added as a feature, please add a new feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants