You need to build a forecast list object that matches the format shown here:
Mine looks like this (truncated to two items, not all data entries are needed):
[
{
"datetime": "2024-03-01T12:00:00+00:00",
"is_daytime": true,
"condition": "pouring",
"humidity": 86,
"pressure": 98675,
"temperature": 6,
"templow": 3,
"precipitation_probability": 59,
"wind_speed": 6
},
{
"datetime": "2024-03-02T00:00:00+00:00",
"is_daytime": false,
"condition": "cloudy",
"humidity": 92,
"pressure": 98996,
"temperature": 4,
"templow": 3,
"precipitation_probability": 28,
"wind_speed": 3
}
]
You need to build a forecast_twice_daily_template
that creates that structure from your sensors in the same sort of way I did in mine.
You’ll need to work out how to get a nice ISO-formatted timestamp and is_daytime
boolean from your date field. Here’s an attempt, mapping is_daytime
to the afternoon:
{% set input = "sab 2 marzo pomeriggio" %}
{% set w, d, m, t = input.split() %}
{% set mn = ['gennaio','febbraio','marzo','aprile','maggio','giugno','luglio',
'agosto','settembre','ottobre','novembre','dicembre'].index(m)+1 %}
{% set ts = "%d-%02d-%02dT%02d" % (now().year + (1 if mn < now().month else 0), mn, d|int, 12 if t == "pomeriggio" else 0) %}
{{ { "time": (ts|as_datetime).isoformat(),
"is_daytime": t == "pomeriggio" } }}
but the later forecasts in that XML are full-day only so you’ll need to treat those separately.
For each of the data items, you’ll need to transform the XML output into the correct format, so dropping units to leave just a number etc.
Lots of work, I’m afraid.