hung2k
March 9, 2021, 7:39pm
1
Since 2021.3 introducing Template Weather Provider, i want to make a custom weather card base on my local weather station’s api
Below is the weather forecast attribute from openweathermap
forecast:
- datetime: '2021-03-10T04:00:00+00:00'
condition: cloudy
temperature: 21
templow: 19.4
- datetime: '2021-03-11T04:00:00+00:00'
condition: partlycloudy
temperature: 22.7
templow: 18.7
i can’t figure out how to replicate the weather forecast format (multiple array) by using attribute_templates
thanks
123
(Taras)
March 12, 2021, 6:32pm
3
The forecast
atttribute contains a list. Each item in the list contains one day’s worth of weather data.
Paste this into the Template Editor and change the name of the entity to match your openweathermap entity:
{{ state_attr('weather.openweathermap', 'forecast')[0].temperature }}
It will report the value of temperature
from the first (zeroth) item in the forecast
list.
Hellis81
(Hellis81)
March 12, 2021, 6:34pm
4
I believe the question is the other way around.
Have values but how to create the same output (list as attributes).
123
(Taras)
March 12, 2021, 6:40pm
5
If the question is the other way around then the OP should create a template that generates a list in the format required by forecast
.
Challenging to provide more guidance until more information is provided.
hung2k
March 12, 2021, 10:56pm
6
You are right, a couple of values from local weather api to rest sensor but in difficult to create the attribute of weather forecast
hung2k
March 12, 2021, 11:09pm
7
I have a list of rest sensors, e.g.
sensor.forecast_0_date
sensor.forecast_1_date
sensor.forecast_0_temp
sensor.forecast_1_temp
sensor.forecast_0_condition
sensor.forecast_1_condition
but i cant figure out how to use attribute_template to make a whole new weather forecast sensor to match the format as the first post