How to create a forecast entity from a weather report in .xml?

I’ve been trying since last night, I managed to get something, look here:
image

I used this code for the Weather which draws data from the other sensors I had created (it translates the written weather from the local weather service, the other data such as temperature, humidity, pressure and wind are from my weather station). I don’t know if it’s the most correct solution, but for now it works. I was unable to do the same for the forecasts for the following days, I will continue to search and will also read your documentation hoping it can help me with the codes. Thank you

weather:
  - platform: template
    name: ARPAV Weather
    condition_template: >
      {% set condition_text = states('sensor.arpav_cielo0') %}
      {% if 'Nuvoloso' in condition_text %}
        cloudy
      {% elif 'Coperto' in condition_text %}
        cloudy
      {% elif 'Grandine' in condition_text %}
        hail
      {% elif 'Soleggiato' in condition_text %}
        sunny
      {% elif 'Sereno o poco nuvoloso' in condition_text %}
        partlycloudy
      {% elif 'Pioggia' in condition_text %}
        rainy
      {% elif 'Nebbia' in condition_text %}
        fog
      {% else %}
        unknown
      {% endif %}
    temperature_template: "{{ states('sensor.giardino_temperature') }}"
    humidity_template: "{{ states('sensor.giardino_humidity') }}"
    pressure_template: "{{ states('sensor.cucina_pressure') }}"
    wind_speed_template: "{{ states('sensor.anemometro_wind_strength') }}"
    wind_bearing_template: "{{ states('sensor.anemometro_direction') }}"
1 Like

This will pull out the second number from "max 10/12 C" so you can use it as an actual number:

    temperature_template: "{{ (states('sensor.arpav_temperatura0').split('/')[1])|select('in','-0123456789.,')|join|replace(',','.') }}"
    temperature_unit: "°C"

Change the [1] for [0] if you want to use the first number instead. It should work even if the XML source includes decimal points or commas.

1 Like

I had posted a wrong code, now corrected, I actually use the data from my weather station for the current temperature, and not “max 10/12 C”, but your code will certainly help me for the forecast data. Which I haven’t yet managed to integrate into the weather entity

I would like to try to do everything well as you did, starting from the recovery of the data with REST. Would you like to help me? I don’t have an API key as you wrote in your code.Is the same possible?

I calmly managed to configure the current weather situation,
I found all the symbols and created a code that converts the text of the symbol with the weather forecast

but I didn’t understand how to insert the following days
image
this is my code:

weather:
  - platform: template
    name: ARPAV Weather
    condition_template: >
      {% set condition_text = states('sensor.arpav_simbolo0') %}
      {% if 'b6.png' in condition_text or
            'b7.png' in condition_text or
            'b8.png' in condition_text or
            'b9.png' in condition_text or
            'b10.png' in condition_text %}
        pouring
      {% elif 'a1N' in condition_text %}
        clear-night
      {% elif 'a4' in condition_text or
              'a5' in condition_text or
              'a6' in condition_text %}
        cloudy
      {% elif 'a3' in condition_text %}
        partlycloudy
      {% elif 'f1.png' in condition_text or
              'f2.png' in condition_text or
              'f3.png' in condition_text or
              'f4.png' in condition_text %}
        fog
      {% elif 'c1.png' in condition_text or
              'c2.png' in condition_text or
              'c3.png' in condition_text or
              'c5.png' in condition_text or
              'c6.png' in condition_text or
              'c7.png' in condition_text or
              'c8.png' in condition_text or
              'c9.png' in condition_text or
              'c10.png' in condition_text %}
        lightning-rainy
      {% elif 'b1.png' in condition_text or
              'b2.png' in condition_text or
              'b3.png' in condition_text or
              'b4.png' in condition_text or
              'b5.png' in condition_text %}
        rainy
      {% elif 'd1.png' in condition_text or
              'd2.png' in condition_text or
              'd3.png' in condition_text or
              'd4.png' in condition_text or
              'd5.png' in condition_text or
              'd6.png' in condition_text or
              'd7.png' in condition_text or
              'd8.png' in condition_text or
              'd9.png' in condition_text or
              'd10.png' in condition_text %}
        snowy
      {% elif 'e1.png' in condition_text or
              'e2.png' in condition_text or
              'e3.png' in condition_text or
              'e4.png' in condition_text or
              'e5.png' in condition_text or
              'e6.png' in condition_text or
              'e7.png' in condition_text or
              'e8.png' in condition_text or
              'e9.png' in condition_text or
              'e10.png' in condition_text %}
        snowy-rainy
      {% elif 'a1' in condition_text or
              'a2' in condition_text %}
        sunny
      {% else %}
        unknown
      {% endif %}
    temperature_template: "{{ states('sensor.giardino_temperature') }}"
    humidity_template: "{{ states('sensor.giardino_humidity') }}"
    pressure_template: "{{ states('sensor.cucina_pressure') }}"
    wind_speed_template: "{{ states('sensor.anemometro_wind_strength') }}"
    wind_bearing_template: "{{ states('sensor.anemometro_direction') }}"


I have already created all the sensors with the forecasts for the next few days, but I don’t understand how to insert them into weather. Can you help me? Thanks, and I apologize again if I’m not able

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.

thank you so much for your patience in trying to help me, but I’m so unprepared that I can’t make a mistake, I stop even before. :slight_smile: maybe it’s time to abandon and use an already existing weather. Maybe too complex for me. I’m only sorry for having created a thousand sensors, but not being able to use them in some way :slight_smile:

1 Like

Ciao Diego,
I would like to have the same sensors from ARPAV…
Can you help me?

Maybe in private session and in italian.

Grazie

C’ho rinunciato… Non sono arrivato a concludere la cosa. Non sono riuscito a creare una entità meteo come volevo

Cosa ti mancava?
Ho visto che eri riuscito ad estrarre tutto; i dati li avevi tutti, giusto?

I tried in February, then I gave up. Now I’m trying again, and the rests from the XML it’s. I always get stuck in the forecast of the future day.
I’m stuck here:

weather:
  - platform: template

    name: Meteo ARPAV
    condition_template: "{{ states('sensor.arpav_simbolo0') }}"
    temperature_template: "{{ states('sensor.arpav_temperatura0') }}"
    humidity_template: "{{ states('sensor.giardino_umidita') }}"
    

I did not understand how to format and where to insert that part that you indicated to me in the previous post:

[
  {
    "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
  }
]

Have the rest temperature sensors, forecasts, precipitation and even a description as a text, but I think they are all useless things, only the forecasts and temperatures should serve.

I have the forecast for the next 5 half days (day 1 morning - evening day 2 morning - evening day 3) then two full days. This will be feasible to align it by comparing the current date with the date of the REST sensor, but it will be a future modification to be given. First I need to figure out how to fix them

You don’t "insert that code " — you have to build the data structure from the available forecast data. Look again at my post:

… where I build the hourly forecast data structure in the template weather entity:

  forecast_hourly_template: >
    {% from 'met_office_codes.jinja' import code2ha %}
    {% from 'direction.jinja' import dir %}
    {% set dh = state_attr('sensor.local_datahub_hourly','timeSeries') %}
    {% set ns = namespace(forecast=[]) %}
    {% for ts in dh -%}
      {% if ts['time']|as_datetime > now() %}
        {% set tsd = { 'datetime': (ts['time']|as_datetime).isoformat(),
                       'condition': code2ha(ts['significantWeatherCode']),
                       'precipitation_probability': ts['probOfPrecipitation'],
                       'wind_bearing': dir(ts['windDirectionFrom10m']),
                       'humidity': ts['screenRelativeHumidity'],
                       'pressure': ts['mslp'],
                       'uv_index': ts['uvIndex'],
                       'temperature': ts['screenTemperature']|round(0),
                       'apparent_temperature': ts['feelsLikeTemperature']|round(0),
                       'wind_speed': ts['windSpeed10m']|round(0) } -%}
        {% set ns.forecast = ns.forecast + [tsd] -%}
      {% endif %}
    {% endfor %}
    {{ ns.forecast }}

You need to do the same to get whatever your input looks like into the same structure.

1 Like

@Troon I read everything and did a lot of tests, but my inexperience and my bad relationship with English are perhaps making me go the wrong way.
I didn’t understand, but in the end your method creates a weather entity, or creates a sensor with the same data, but not exactly a weather entity? just to understand, because I’m reading everywhere that the weather forecast entity is not supported, so I don’t understand

It creates a Template Weather entity, which should be the same as a “real” weather entity. Here’s what mine looks like:

1 Like

But in this way, will you not be able to use cards already made specifically for correct weather entities? I’m trying to understand🧐

Yes you will.

I have a very long file in package called arpav.yaml.
I was hoping to have arrived at a good point, look, a part that downloads the bulletins, then rest to extract all the data, all the available sensors, a working arpav weather entity with the current forecasts, but nothing, for future forecasts I can’t figure out how to create that part of the code.

##############################################################
#                                                            #
#                       BINARY_SENSOR                        #
#                                                            #
##############################################################

# diventa ON quanto c'è nuovo bollettino, serve per visualizzazione su scheda
binary_sensor:
  - platform: template
    sensors:
      arpav_nuovo_bollettino:
        entity_id: input_boolean.arpav_nuovo_bollettino
        device_class: update
        value_template: "{{ is_state('input_boolean.arpav_nuovo_bollettino', 'on') }}"
        icon_template: >-
          {% if is_state('input_boolean.arpav_nuovo_bollettino', 'on') %}
            mdi:information-variant
          {% else %}
            mdi:information-outline
          {% endif %}

##############################################################
#                                                            #
#                       SENSORI                              #
#                                                            #
##############################################################

sensor:
# seleziona l'ID dell zona per i sensor restful
  - platform: template
    sensors:
      arpav_zona_id:
        entity_id: input_select.arpav_zona
        icon_template: mdi:target
        value_template: >-
          {% set zona = states('input_select.arpav_zona') %}
          {% if zona == "Dolomiti Nord-Est" %} 0
          {% elif zona == "Dolomiti Sud-Ovest" %} 1
          {% elif zona == "Belluno e Prealpi orientali" %} 2
          {% elif zona == "Prealpi centrali" %} 3
          {% elif zona == "Pedemontana orientale" %} 4
          {% elif zona == "Treviso e pianura orientale" %} 5
          {% elif zona == "Veneziano orientale" %} 6
          {% elif zona == "Prealpi occidentali" %} 7
          {% elif zona == "Vicenza e pedemontana" %} 8
          {% elif zona == "Padova e pianura centrale" %} 9
          {% elif zona == "Venezia e laguna" %} 10
          {% elif zona == "Delta del Po" %} 11
          {% elif zona == "Rovigo e pianura meridionale" %} 12
          {% elif zona == "Verona e pedemontana" %} 13
          {% elif zona == "Area del Garda" %} 14
          {% elif zona == "Litorale nord" %} 15
          {% elif zona == "Litorale centrale" %} 16
          {% else%} 17
          {% endif %}
          
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: ARPAV Bollettino Aggiornamento
    value_template: >
      {% set data_ora = value_json.previsioni.data_aggiornamento['@date'] | default(None) %}
      {% if data_ora is not none %}
        {% set data = data_ora.split(' alle ')[0] %}
        {% set ora = data_ora.split(' alle ')[1].replace('.', ':') %}
        {% set anno_corrente = now().year %}
        {% if data.count('/') == 2 %}
          {{ strptime(data ~ ' ' ~ ora, '%d/%m/%Y %H:%M').strftime('%Y-%m-%dT%H:%M:%S') }}
        {% else %}
          {{ strptime(data ~ '/' ~ anno_corrente ~ ' ' ~ ora, '%d/%m/%Y %H:%M').strftime('%Y-%m-%dT%H:%M:%S') }}
        {% endif %}
      {% else %}
        "nessuno"
      {% endif %}
    scan_interval: 600
      
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: ARPAV Bollettino Emissione
    value_template: >
      {% set data_ora = value_json.previsioni.data_emissione['@date'] %}
      {% set data = data_ora.split(' alle ')[0] %}
      {% set ora = data_ora.split(' alle ')[1].replace('.', ':') %}
      {% set anno_corrente = now().year %}
      {% if data.count('/') == 2 %}
        {{ strptime(data ~ ' ' ~ ora, '%d/%m/%Y %H:%M').strftime('%Y-%m-%dT%H:%M:%S') }}
      {% else %}
        {{ strptime(data ~ '/' ~ anno_corrente ~ ' ' ~ ora, '%d/%m/%Y %H:%M').strftime('%Y-%m-%dT%H:%M:%S') }}
      {% endif %}
    scan_interval: 600

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_zona
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int]['@name']  }}"
    scan_interval: 600
    
# Prima Mezza Giornata
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_simbolo0
    value_template: >
      {% set url = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0].previsione[0]['@value'] | default('Valore non disponibile') %}
      {% if url != 'Valore non disponibile' %}
        {% set file_name = url.split('/')[-1].replace('.png', '') %}
        {% if file_name == 'a1N' %}
          clear-night
        {% elif file_name in ['a4', 'a5', 'a6'] %}
          cloudy
        {% elif file_name in ['f1', 'f2', 'f3', 'f4'] %}
          fog
        {% elif file_name in ['c1', 'c2', 'c3', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10'] %}
          lightning-rainy
        {% elif file_name == 'a3' %}
          partlycloudy
        {% elif file_name in ['b6', 'b7', 'b8', 'b9', 'b10'] %}
          pouring
        {% elif file_name in ['b1', 'b2', 'b3', 'b4', 'b5'] %}
          rainy
        {% elif file_name in ['d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'd10'] %}
          snowy
        {% elif file_name in ['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'e10'] %}
          snowy-rainy
        {% elif file_name in ['a1', 'a2'] %}
          sunny
        {% else %}
          "Condizione sconosciuta"
        {% endif %}
      {% else %}
        "Valore non disponibile"
      {% endif %}
    scan_interval: 600

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_data0
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0]['@data'] | default('Valore non disponibile') }}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_cielo0
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0].previsione[1]['@value'] | default('Valore non disponibile') }}"
    scan_interval: 600
    
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_temperatura0
    value_template: >
      {%- set temp_string = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0].previsione[2]['@value'] -%}
      {%- set numbers = temp_string | regex_findall('\\d+') -%}
      {%- if numbers | length == 2 -%}
        {{ ((numbers[0] | int + numbers[1] | int) / 2) | round(0) }}
      {%- elif numbers | length == 1 -%}
        {{ numbers[0] | int }}
      {%- else -%}
        Valore non disponibile
      {%- endif -%}
    scan_interval: 600
    unit_of_measurement: "°C"
    device_class: temperature

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_precipitazioni0
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0].previsione[3]['@value'] | default('Valore non disponibile') }}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_probabilita0
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[0].previsione[4]['@value'] | default('Valore non disponibile') }}"
    scan_interval: 600

# Seconda Mezza Giornata
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_simbolo1
    value_template: >
      {% set url = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1].previsione[0]['@value'] | default('Valore non disponibile') %}
      {% if url != 'Valore non disponibile' %}
        {% set file_name = url.split('/')[-1].replace('.png', '') %}
        {% if file_name == 'a1N' %}
          clear-night
        {% elif file_name in ['a4', 'a5', 'a6'] %}
          cloudy
        {% elif file_name in ['f1', 'f2', 'f3', 'f4'] %}
          fog
        {% elif file_name in ['c1', 'c2', 'c3', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10'] %}
          lightning-rainy
        {% elif file_name == 'a3' %}
          partlycloudy
        {% elif file_name in ['b6', 'b7', 'b8', 'b9', 'b10'] %}
          pouring
        {% elif file_name in ['b1', 'b2', 'b3', 'b4', 'b5'] %}
          rainy
        {% elif file_name in ['d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'd10'] %}
          snowy
        {% elif file_name in ['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'e10'] %}
          snowy-rainy
        {% elif file_name in ['a1', 'a2'] %}
          sunny
        {% else %}
          "Condizione sconosciuta"
        {% endif %}
      {% else %}
        "Valore non disponibile"
      {% endif %}
    scan_interval: 600

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_data1
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1]['@data'] }}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_cielo1
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1].previsione[1]['@value'] }}"
    scan_interval: 600
    
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_temperatura1
    value_template: >
      {%- set temp_string = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1].previsione[2]['@value'] -%}
      {%- set numbers = temp_string | regex_findall('\\d+') -%}
      {%- if numbers | length == 2 -%}
        {{ ((numbers[0] | int + numbers[1] | int) / 2) | round(0) }}
      {%- elif numbers | length == 1 -%}
        {{ numbers[0] | int }}
      {%- else -%}
        Valore non disponibile
      {%- endif -%}
    scan_interval: 600
    unit_of_measurement: "°C"
    device_class: temperature

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_precipitazioni1
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1].previsione[3]['@value']}}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_probabilita1
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[1].previsione[4]['@value']}}"
    scan_interval: 600
    
# terza Mezza Giornata
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_simbolo2
    value_template: >
      {% set url = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2].previsione[0]['@value'] | default('Valore non disponibile') %}
      {% if url != 'Valore non disponibile' %}
        {% set file_name = url.split('/')[-1].replace('.png', '') %}
        {% if file_name == 'a1N' %}
          clear-night
        {% elif file_name in ['a4', 'a5', 'a6'] %}
          cloudy
        {% elif file_name in ['f1', 'f2', 'f3', 'f4'] %}
          fog
        {% elif file_name in ['c1', 'c2', 'c3', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10'] %}
          lightning-rainy
        {% elif file_name == 'a3' %}
          partlycloudy
        {% elif file_name in ['b6', 'b7', 'b8', 'b9', 'b10'] %}
          pouring
        {% elif file_name in ['b1', 'b2', 'b3', 'b4', 'b5'] %}
          rainy
        {% elif file_name in ['d1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'd10'] %}
          snowy
        {% elif file_name in ['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'e10'] %}
          snowy-rainy
        {% elif file_name in ['a1', 'a2'] %}
          sunny
        {% else %}
          "Condizione sconosciuta"
        {% endif %}
      {% else %}
        "Valore non disponibile"
      {% endif %}
    scan_interval: 600

  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_data2
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2]['@data'] }}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_cielo2
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2].previsione[1]['@value'] }}"
    scan_interval: 600
    
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_temperatura2
    value_template: >
      {%- set temp_string = value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2].previsione[2]['@value'] -%}
      {%- set numbers = temp_string | regex_findall('\\d+') -%}
      {%- if numbers | length == 2 -%}
        {{ ((numbers[0] | int + numbers[1] | int) / 2) | round(0) }}
      {%- elif numbers | length == 1 -%}
        {{ numbers[0] | int }}
      {%- else -%}
        Valore non disponibile
      {%- endif -%}
    scan_interval: 600
    unit_of_measurement: "°C"
    device_class: temperature


  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_precipitazioni2
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2].previsione[3]['@value']}}"
    scan_interval: 600
  - platform: rest
    resource: https://www.arpa.veneto.it/previsioni/it/xml/bollettino_utenti.xml
    name: arpav_probabilita2
    value_template: "{{ value_json.previsioni.meteogrammi.meteogramma[states('sensor.arpav_zona_id')|int].scadenza[2].previsione[4]['@value']}}"
    scan_interval: 600



# Aggiungi i sensori template separatamente
forecast_hourly_template: >
    {% from 'met_office_codes.jinja' import code2ha %}
    {% from 'direction.jinja' import dir %}
    {% set dh = state_attr('sensor.local_datahub_hourly','timeSeries') %}
    {% set ns = namespace(forecast=[]) %}
    {% for ts in dh -%}
      {% if ts['time']|as_datetime > now() %}
        {% set tsd = { 'datetime': (ts['time']|as_datetime).isoformat(),
                       'condition': code2ha(ts['significantWeatherCode']),
                       'precipitation_probability': ts['probOfPrecipitation'],
                       'wind_bearing': dir(ts['windDirectionFrom10m']),
                       'humidity': ts['screenRelativeHumidity'],
                       'pressure': ts['mslp'],
                       'uv_index': ts['uvIndex'],
                       'temperature': ts['screenTemperature']|round(0),
                       'apparent_temperature': ts['feelsLikeTemperature']|round(0),
                       'wind_speed': ts['windSpeed10m']|round(0) } -%}
        {% set ns.forecast = ns.forecast + [tsd] -%}
      {% endif %}
    {% endfor %}
    {{ ns.forecast }}







    
##############################################################
#                                                            #
#                       INPUT                                #
#                                                            #
##############################################################

# memorizza ultimo aggiornamento bollettino
input_text:
  arpav_data_ultimo_aggiornamento:
    name: ARPAV Data Ultimo Aggiornamento

# Diventa ON quando viene emesso un nuovo bollettino o un nuovo aggiornamento
input_boolean:
  arpav_nuovo_bollettino:
    name: ARPAV Nuovo Bollettino

# Selettore Zone presenti nel bollettino. Cambiare initial con la zona preferita
# altrimenti prende la prima della lista
input_select:
  arpav_zona:
    name: ARPAV Zona
    options:
      - "Dolomiti Nord-Est"
      - "Dolomiti Sud-Ovest"
      - "Belluno e Prealpi orientali"
      - "Prealpi centrali"
      - "Pedemontana orientale"
      - "Treviso e pianura orientale"
      - "Veneziano orientale"
      - "Prealpi occidentali"
      - "Vicenza e pedemontana"
      - "Padova e pianura centrale"
      - "Venezia e laguna"
      - "Delta del Po"
      - "Rovigo e pianura meridionale"
      - "Verona e pedemontana"
      - "Area del Garda"
      - "Litorale nord"
      - "Litorale centrale"
      - "Litorale sud"
    icon: mdi:target
    initial: "Padova e pianura centrale"
##############################################################
#                                                            #
#                       SCRIPT                               #
#                                                            #
##############################################################

script:
  bollettino_popup:
    sequence:
      - service: input_boolean.turn_off
        data: 
          entity_id: input_boolean.arpav_nuovo_bollettino

##############################################################
#                                                            #
#                  AUTOMAZIONI                               #
#                                                            #
##############################################################

automation:
# Mette ON input_boolean.arpav_nuovo_bollettino quando cambia la data rispetto 
# all'ultimo aggiornamento contenuta in input_text.arpav_data_ultimo_aggiornamento
  - id: '1575837712577'
    mode: single
    alias: Aggiornamento bollettino ARPAV
    trigger:
    - platform: template
      value_template: "{{ states('sensor.arpav_bollettino_aggiornamento') != states('input_text.arpav_data_ultimo_aggiornamento') }}" 
    condition: []
    action:
    - data: {}
      entity_id: input_boolean.arpav_nuovo_bollettino
      service: input_boolean.turn_on
    - data_template:
        value: "{{states('sensor.arpav_bollettino_aggiornamento')}}"
      entity_id: input_text.arpav_data_ultimo_aggiornamento
      service: input_text.set_value

# Aggiorna i sensori sensor.arpav_xxxx dopo ogni cambio di stato del selettore input_select.arpav_zona
# e mette ON input_boolean.arpav_nuovo_bollettino
  - id: '1575837712578'
    mode: single 
    alias: aggiorna sensori ARPAV
    trigger:
      platform: state
      entity_id: input_select.arpav_zona
    action:
    -  service: homeassistant.update_entity
       entity_id:
         - sensor.arpav_zona
         - sensor.arpav_data0
         - sensor.arpav_simbolo0
         - sensor.arpav_cielo0
         - sensor.arpav_temperatura0
         - sensor.arpav_precipitazioni0
         - sensor.arpav_probabilita0
         - sensor.arpav_data1
         - sensor.arpav_simbolo1
         - sensor.arpav_cielo1
         - sensor.arpav_temperatura1
         - sensor.arpav_precipitazioni1
         - sensor.arpav_probabilita1
         - sensor.arpav_data2
         - sensor.arpav_simbolo2
         - sensor.arpav_cielo2
         - sensor.arpav_temperatura2
         - sensor.arpav_precipitazioni2
         - sensor.arpav_probabilita2
    - data: {}
      entity_id: input_boolean.arpav_nuovo_bollettino
      service: input_boolean.turn_on


weather:
  - platform: template
    name: Meteo ARPAV
    condition_template: "{{ states('sensor.arpav_simbolo0') }}"
    temperature_template: "{{ states('sensor.arpav_temperatura0') }}"
    humidity_template: "{{ states('sensor.giardino_umidita') }}"

this really escapes me and I don’t understand, I think I’ll have to give up for the second time

forecast_hourly_template: >
    {% from 'met_office_codes.jinja' import code2ha %}
    {% from 'direction.jinja' import dir %}
    {% set dh = state_attr('sensor.local_datahub_hourly','timeSeries') %}
    {% set ns = namespace(forecast=[]) %}
    {% for ts in dh -%}
      {% if ts['time']|as_datetime > now() %}
        {% set tsd = { 'datetime': (ts['time']|as_datetime).isoformat(),
                       'condition': code2ha(ts['significantWeatherCode']),
                       'precipitation_probability': ts['probOfPrecipitation'],
                       'wind_bearing': dir(ts['windDirectionFrom10m']),
                       'humidity': ts['screenRelativeHumidity'],
                       'pressure': ts['mslp'],
                       'uv_index': ts['uvIndex'],
                       'temperature': ts['screenTemperature']|round(0),
                       'apparent_temperature': ts['feelsLikeTemperature']|round(0),
                       'wind_speed': ts['windSpeed10m']|round(0) } -%}
        {% set ns.forecast = ns.forecast + [tsd] -%}
      {% endif %}
    {% endfor %}
    {{ ns.forecast }}

For starters, you need to make a template weather entity. You just copied and pasted what troon wrote into your configuration.

yes exactly, I copied and pasted saying “I don’t understand this thing”. I understand that I have to create a weather template entity, I will still have to study to understand how

How have you created any other template entity? Note your file has other examples of other templates. e.g. your binary sensor starts with

And the template weather documents show:

Yet you just copied and pasted