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

.get_forecasts returning uv not uv_index as per documentation #217

Open
homeassistant-fyffehouse opened this issue Apr 8, 2024 · 1 comment

Comments

@homeassistant-fyffehouse

I am using the forecast from the bureau_of_meteorology integration (both daily and hourly) along with my weather station data (ecowitt 2553) to create a weather platform template.

image

The bom integration when calling weather.get_forecasts on it, returns the wrong key for the uv index.

Example:

  • service: weather.get_forecasts
    data:
    type: hourly
    target:
    entity_id: weather.upper_brookfield_hourly
    response_variable: ub_hourly
    sensor:
    • name: Hourly Forecasts for Upper Brookfield
      unique_id: ub_hourly_forecast
      state: "{{ now().isoformat() }}"
      attributes:
      forecast: "{{ ub_hourly['weather.upper_brookfield_hourly'].forecast }}"

returns

weather.upper_brookfield_hourly:
forecast:
- datetime: "2024-04-08T22:00:00+10:00"
condition: sunny
precipitation_probability: 5
wind_bearing: "N"
wind_gust_speed: 15
uv: 0
temperature: 20
wind_speed: 7
precipitation: 0
humidity: 82
...

The correct uv key should be uv_index as per the documentation at https://www.home-assistant.io/integrations/weather/
The response data field is a mapping of called target entities, each containing the forecast field. forecast is a list of forecasted conditions at a given point in time:

The table describes the uv index key as:
uv_index | The UV index. | 3

When using the returned forecast in a weather platform template, the forecast_hourly_template assignment will fail.

from template 'Template<template=({{ state_attr('sensor.hourly_forecasts_for_upper_brookfield','forecast') }}) renders=4>' for attribute '_forecast_hourly' in entity weather.ecowitt_weather_station validation message 'Only valid keys in Forecast are allowed, unallowed keys: ({'uv'}), see Weather documentation https://www.home-assistant.io/integrations/weather/'

A simple regular expression on the data is a work around:
forecast_hourly_template: "{{ state_attr('sensor.hourly_forecasts_for_upper_brookfield','forecast') |regex_replace(find='uv', replace='uv_index', ignorecase=False) }}"

@homeassistant-fyffehouse
Copy link
Author

This might be related to #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant