#openhasp:
plate1:
  objects:
    - obj: "p0b2"
      properties:
        "text": '{{ states("sensor.ecowitt_temp")| float | round(1) }}°C'
    - obj: "p0b1" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.ecowitt_tempin")| float | round(1)}}°C'
    #page 1 sensor:
    - obj: "p1b11" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.temp_fumee")| float | round(1) }}°C'
    - obj: "p1b13" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.temp_depart_chauffage")| float | round(1) }}°C'

    #page 1 light:

    - obj: "p1b1" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.lumieres_couloir") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.lumieres_couloir", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.lumieres_couloir"

    - obj: "p1b2" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.applique_salon") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.applique_salon", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.applique_salon"

    - obj: "p1b3" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.applique_cuisine") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.applique_cuisine", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.applique_cuisine"

    - obj: "p1b4" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.lumieres_escaliers") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.lumieres_escaliers", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.lumieres_escaliers"

    - obj: "p1b7" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.eclairage_bois") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.eclairage_bois", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.eclairage_bois"
    - obj: "p1b8" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.yeelight_color4_0x15771126") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.yeelight_color4_0x15771126", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.yeelight_color4_0x15771126"

    - obj: "p1b9" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("switch.kc868_a8_d758d0_d758d0_lumiere_comble_kc") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("switch.kc868_a8_d758d0_d758d0_lumiere_comble_kc", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.kc868_a8_d758d0_d758d0_lumiere_comble_kc"
    #page 2 light
    - obj: "p2b21" # Light brightness
      properties:
        "val": "{{ state_attr('light.applique_salon', 'brightness') if state_attr('light.applique_salon', 'brightness') != None else 0 }}"
      event:
        "changed":
          - service: light.turn_on
            data:
              entity_id: light.applique_salon
              brightness: "{{ val }}"
        "up":
          - service: light.turn_on
            data:
              entity_id: light.applique_salon
              brightness: "{{ val }}"
    - obj: "p2b23" # Light brightness
      properties:
        "val": "{{ state_attr('light.lumieres_plafond', 'brightness') if state_attr('light.lumieres_plafond', 'brightness') != None else 0 }}"
      event:
        "changed":
          - service: light.turn_on
            data:
              entity_id: light.lumieres_plafond
              brightness: "{{ val }}"
        "up":
          - service: light.turn_on
            data:
              entity_id: light.lumieres_plafond
              brightness: "{{ val }}"
    - obj: "p2b25" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("light.eclairage_bois") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("light.eclairage_bois", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "light.eclairage_bois"

    #thermostat
    - obj: "p3b20" # arc slider
      properties:
        "val": >
          {% if state_attr('climate.salon','temperature') is not none %}
          {{ state_attr('climate.salon','temperature') | int * 10 }}
          {%- endif %}
        "min": >
          {% if state_attr('climate.salon','min_temp') is not none %}
          {{ state_attr('climate.salon','min_temp') | int * 10 }}
          {%- endif %}
        "max": >
          {% if state_attr('climate.salon','max_temp') is not none %}
          {{ state_attr('climate.salon','max_temp') | int * 10 }}
          {%- endif %}
        "opacity": "{{ 60 if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 255 }}"
        "click": "{{ 'false' if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 'true' }}"
        "line_color1": >
          {% if is_state('climate.salon', 'cool') %}
          {{ "#346beb" }}
          {%-elif is_state('climate.salon', 'heat_cool') %}
          {{ "#34bdeb" }}
          {%-elif is_state('climate.salon', 'heat') %}
          {{ "#eb3434" }}
          {%-elif is_state('climate.salon', 'dry') %}
          {{ "#ebeb34" }}
          {%-elif is_state('climate.salon', 'fan_only') %}
          {{ "#34eb77" }}
          {%-else %}
          {{ "#9f96b0" }}
          {% endif %}
      event:
        "changed":
          - service: climate.set_temperature
            target:
              entity_id: climate.salon
            data:
              temperature: "{{ val | int / 10 }}"
        "up":
          - service: climate.set_temperature
            target:
              entity_id: climate.salon
            data:
              temperature: "{{ val | int / 10 }}"

    - obj: "p3b21" # gauge current temp
      properties:
        "val": >
          {% if not (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) %}
          {{ states('climate.salon') | float (default=0) * 10 }}
          {%- endif %}
        "min": >
          {% if state_attr('climate.salon','min_temp') is not none %}
          {{ state_attr('climate.salon','min_temp') | int * 10 }}
          {%- endif %}
        "max": >
          {% if state_attr('climate.salon','max_temp') is not none %}
          {{ state_attr('climate.salon','max_temp') | int * 10 }}
          {%- endif %}
        "critical_value": >
          {% if state_attr('climate.salon','max_temp') is not none %}
          {{ state_attr('climate.salon','max_temp') | int * 10 + 1 }}
          {%- endif %}
        "label_count": >
          {% if state_attr('climate.salon','max_temp') is not none %}
          {{ state_attr('climate.salon','max_temp') | int - state_attr('climate.salon','min_temp') | int + 1 }}
          {%- endif %}
        "line_count": >
          {% if state_attr('climate.salon','max_temp') is not none %}
          {{ (state_attr('climate.salon','max_temp') | int - state_attr('climate.salon','min_temp') | int) * 2 + 1 }}
          {%- endif %}
        "opacity": "{{ 60 if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 255 }}"

    - obj: "p3b23" # label current temp (and +/- with short/long touch)
      properties:
        "text": >
          {% if (is_state('sensor.ecowitt_tempin','unavailable') or is_state('sensor.ecowitt_tempin','unknown')) %}
          {{ "--.-" }}
          {%-else %}
          {{ states('sensor.ecowitt_tempin') | round(1,default=0) }}
          {%- endif %}
        "click": "{{ 'false' if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 'true' }}"
        "opacity": "{{ 60 if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 255 }}"
      event:
        "up":
          - service: climate.set_temperature
            target:
              entity_id: climate.salon
            data:
              temperature: "{{ state_attr('climate.salon','temperature') + state_attr('climate.salon','target_temp_step') | float(default=1)}}"
        "long":
          - service: climate.set_temperature
            target:
              entity_id: climate.salon
            data:
              temperature: "{{ state_attr('climate.salon','temperature') - state_attr('climate.salon','target_temp_step') | float(default=1)}}"

    - obj: "p3b25" # label target temp
      properties:
        "text": >
          {% if state_attr('climate.salon','temperature') is not none %}
          {{ state_attr('climate.salon','temperature') }}
          {%- endif %}
        "opacity": "{{ 60 if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 255 }}"

    - obj: "p3b41" # on/off switch
      properties:
        "val": "{{ 0 if (is_state('climate.salon', 'off') or is_state('climate.salon', 'unavailable')) else 1 }}"
        "click": "{{ 'false' if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 'true' }}"
        "opacity": "{{ 60 if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 255 }}"
      event:
        "down":
          - service_template: >
              {% if val == 0 -%}
              climate.turn_on
              {% else -%}
              climate.turn_off
              {% endif -%}
            entity_id: "climate.salon"

    - obj: "p3b30" # tab dots
      event:
        "changed":
          - service: openhasp.command
            target:
              entity_id: openhasp.your_plate
            data:
              keyword: p3b26.text
              parameters: >
                {% if val == 0 %}
                {{ "#000000 \u2022# #909090 \u2022# #909090 \u2022#" | e }}
                {%-elif val == 1 %}
                {{ "#909090 \u2022# #000000 \u2022# #909090 \u2022#" | e }}
                {%-elif val == 2 %}
                {{ "#909090 \u2022# #909090 \u2022# #000000 \u2022#" | e }}
                {% endif %}

    - obj: "p3b42" # dropdown with fan_modes
      properties:
        "options": >
          {% if state_attr('climate.salon','fan_modes') is not none %}{%for mode in state_attr('climate.salon','fan_modes')%}
          {%- if mode == 'auto' -%}
          Automatic{{"\n"|e}}
          {%- elif mode == 'low' -%}
          Low{{"\n"|e}}
          {%- elif mode == 'medium' -%}
          Medium{{"\n"|e}}
          {%- elif mode == 'high' -%}
          High{{"\n"|e}}
          {%- elif mode == 'turbo' -%}
          Turbo{{"\n"|e}}
          {%- endif -%}
          {%-if not loop.last%}{%-endif%}{%-endfor%}{% endif %}
        "click": "{{ 'false' if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 'true' }}"
        "val": >
          {% if not (is_state('climate.salon','unavailable')) %}{%for mode in state_attr('climate.salon','fan_modes')%}
          {{loop.index -1 if mode == state_attr('climate.salon','fan_mode') }}
          {%-endfor%}{% endif %}
      event:
        "changed":
          - service: climate.set_fan_mode
            target:
              entity_id: climate.salon
            data:
              fan_mode: >
                {% if text == "Automatic" -%}
                auto
                {% elif text == 'Low' -%}
                low
                {% elif text == 'Medium' -%}
                medium
                {% elif text == 'High' -%}
                high
                {% elif text == 'Turbo' -%}
                turbo
                {% endif -%}

    - obj: "p3b43" # dropdown with hvac_modes
      properties:
        "options": >
          {% if state_attr('climate.salon','hvac_modes') is not none %}{%for mode in state_attr('climate.salon','hvac_modes')%}
          {%- if mode == 'off' -%}
          Off{{"\n"|e}}
          {%- elif mode == 'heat' -%}
          Heating{{"\n"|e}}
          {%- elif mode == 'cool' -%}
          Cooling{{"\n"|e}}
          {%- elif mode == 'heat_cool' -%}
          Heat/Cool{{"\n"|e}}
          {%- elif mode == 'dry' -%}
          Drying{{"\n"|e}}
          {%- elif mode == 'fan_only' -%}
          Fan only{{"\n"|e}}
          {%- else -%}
          On{{"\n"|e}}
          {%- endif -%}
          {%-if not loop.last%}{%-endif%}{%-endfor%}{% endif %}
        "click": "{{ 'false' if (is_state('climate.salon','unavailable') or is_state('climate.salon','unknown')) else 'true' }}"
        "val": >
          {% if not (is_state('climate.salon','unavailable')) %}{%for mode in state_attr('climate.salon','hvac_modes')%}
          {{loop.index -1 if mode == states('climate.salon') }}
          {%-endfor%}{% endif %}
      event:
        "changed":
          - service: climate.set_hvac_mode
            target:
              entity_id: climate.salon
            data:
              hvac_mode: >
                {% if text == "Off" -%}
                off
                {% elif text == 'Heating' -%}
                heat
                {% elif text == 'Cooling' -%}
                cool
                {% elif text == 'Heat/Cool' -%}
                heat_cool
                {% elif text == 'Drying' -%}
                dry
                {% elif text == 'Fan only' -%}
                fan_only
                {% endif -%}
    # solar page4
    - obj: "p4b41" # light-switch toggle button
      properties:
        "val": '{{ 1 if states("switch.relay_inverter_1") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("switch.relay_inverter_1", "on") else "\uE335" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.relay_inverter_1"

    - obj: "p4b43" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.pv_power_3") }}W'
    - obj: "p4b45" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.tacsolar_power") }}W'
    - obj: "p4b47" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.power_compteur") }}W'
    - obj: "p4b49" # temperature label on all pages
      properties:
        "text": '{{ states("sensor.battery_state_of_charge_2") }}%'

    # weather section
    - obj: "p5b14" # Icon
      properties:
        "src": "{{ 'L:/w-128-' + states('weather.openweathermap') + '.png' if not is_state('weather.openweathermap','unavailable') }}"

    - obj: "p5b15" # Current date (adjust format to your needs)
      properties:
        "text": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          {%- set day = (states.weather.openweathermap.last_changed).strftime('%w') %}
          {%- set days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] %}
          {{- days[ day | int -1 ] }} {{ (states.weather.openweathermap.last_changed).strftime('%m. %d. ') }}
          {% endif -%}

    - obj: "p5b16" # Current temp (you can use your own outdoor temp sensor if you have one)
      properties:
        "text": "{{ state_attr('weather.openweathermap','temperature') |string + '°C' if not is_state('weather.openweathermap','unavailable') }}" # or "{{ states('sensor.your_own_temp_sensor') if not is_state('sensor.your_own_temp_sensor','unavailable') else '--' }}°C"

    - obj: "p5b17" # Current weather condition
      properties:
        "text": >
          {% if is_state('weather.openweathermap','clear-night') -%}
          Clear night
          {% elif is_state('weather.openweathermap','cloudy') -%}
          Cloudy
          {% elif is_state('weather.openweathermap','fog') -%}
          Fog
          {% elif is_state('weather.openweathermap','hail') -%}
          Hail
          {% elif is_state('weather.openweathermap','lightning') -%}
          Lightning
          {% elif is_state('weather.openweathermap','lightning-rainy') -%}
          Thunderstorms
          {% elif is_state('weather.openweathermap','partlycloudy') -%}
          Partly cloudy
          {% elif is_state('weather.openweathermap','pouring') -%}
          Pouring rain
          {% elif is_state('weather.openweathermap','rainy') -%}
          Rainy
          {% elif is_state('weather.openweathermap','snowy') -%}
          Snowy
          {% elif is_state('weather.openweathermap','snowy-rainy') -%}
          Snowy-rainy
          {% elif is_state('weather.openweathermap','sunny') -%}
          Sunny
          {% elif is_state('weather.openweathermap','windy') -%}
          Windy
          {% elif is_state('weather.openweathermap','windy-variant') -%}
          Windy
          {% elif is_state('weather.openweathermap','exceptional') -%}
          Exceptional
          {% elif is_state('weather.openweathermap','unavailable') -%}
          (not available)
          {% else -%}
          {{ states('weather.openweathermap') }}
          {% endif -%}

    - obj: "p5b10" # tab dots - MAKE SURE YOU UPDATE THIS ONE!!
      event:
        "changed":
          - service: openhasp.command
            target:
              entity_id: openhasp.your_plate
            data:
              keyword: p5b19.text
              parameters: >
                {% if val == 0 %}
                {{ "#000000 \u2022# #909090 \u2022#" | e }}
                {%-elif val == 1 %}
                {{ "#909090 \u2022# #000000 \u2022#" | e }}
                {% endif %}

    - obj: "p5b21" # Forecast time +1h
      properties:
        "text": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          {%- set update = states('sensor.date') %}
          {%- set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
          {%- set event = as_timestamp(strptime(state_attr('weather.openweathermap','forecast')[1]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set delta = ((event - midnight) // 86400) | int %}
          {%- if delta == 0 %}
          Today
          {%- elif delta == 1 %}
          Tomorrow
          {%- endif %}
          {{- event | timestamp_custom(" %-I %p") }}
          {%- endif %}

    - obj: "p5b22" # Forecast temp +1h
      properties:
        "text": "{{ state_attr('weather.openweathermap','forecast')[1]['temperature'] if not is_state('weather.openweathermap','unavailable') else '-' }}"

    - obj: "p5b23" # Forecast condition +1h
      properties:
        "src": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          L:/w-32-{{ state_attr('weather.openweathermap','forecast')[1]['condition'] }}.png
          {%- endif %}

    - obj: "p5b31" # Forecast time +2h (using Dawn/Morn etc instead of Today/Tomorrow)
      properties:
        "text": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          {%- set hour = as_timestamp(strptime(state_attr('weather.openweathermap','forecast')[3]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) | timestamp_custom("%-H") | int %}
          {%- if 4 <= hour < 6 %}
          Dawning
          {%- elif 6 <= hour < 9 %}
          Morning
          {%- elif 9 <= hour < 12 %}
          Forenoon
          {%- elif 12 <= hour < 18 %}
          Afternoon
          {%- elif 18 <= hour < 23 %}
          Evening
          {%- elif 23 <= hour or hour < 4 %}
          Night
          {%- endif %}
          {{- " " + hour |string + " o'clock" }}
          {%- endif %}

    - obj: "p5b32" # Forecast temp +2h
      properties:
        "text": "{{ state_attr('weather.openweathermap','forecast')[3]['temperature'] if not is_state('weather.openweathermap','unavailable') else '-' }}"

    - obj: "p5b33" # Forecast condition +2h
      properties:
        "src": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          L:/w-32-{{ state_attr('weather.openweathermap','forecast')[3]['condition'] }}.png
          {%- endif %}

    - obj: "p5b41" # Forecast time +4h
      properties:
        "text": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          {%- set update = states('sensor.date') %}
          {%- set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
          {%- set event = as_timestamp(strptime(state_attr('weather.openweathermap','forecast')[6]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set delta = ((event - midnight) // 86400) | int %}
          {%- if delta == 0 %}
          Today
          {%- elif delta == 1 %}
          Tomorrow
          {%- endif %}
          {{- event | timestamp_custom(" %-I %p") }}
          {%- endif %}

    - obj: "p5b42" # Forecast temp +4h
      properties:
        "text": "{{ state_attr('weather.openweathermap','forecast')[6]['temperature'] if not is_state('weather.openweathermap','unavailable') else '-' }}"

    - obj: "p5b43" # Forecast condition +4h
      properties:
        "src": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          L:/w-32-{{ state_attr('weather.openweathermap','forecast')[6]['condition'] }}.png
          {%- endif %}

    - obj: "p5b51" # Forecast time +8h
      properties:
        "text": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          {%- set update = states('sensor.date') %}
          {%- set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
          {%- set event = as_timestamp(strptime(state_attr('weather.openweathermap','forecast')[12]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set delta = ((event - midnight) // 86400) | int %}
          {%- if delta == 0 %}
          Today
          {%- elif delta == 1 %}
          Tomorrow
          {%- endif %}
          {{- event | timestamp_custom(" %-I %p") }}
          {%- endif %}

    - obj: "p5b52" # Forecast temp +8h
      properties:
        "text": "{{ state_attr('weather.openweathermap','forecast')[12]['temperature'] if not is_state('weather.openweathermap','unavailable') else '-' }}"

    - obj: "p5b53" # Forecast condition +8h
      properties:
        "src": >
          {%- if not is_state('weather.openweathermap','unavailable') %}
          L:/w-32-{{ state_attr('weather.openweathermap','forecast')[12]['condition'] }}.png
          {%- endif %}

    - obj: "p5b61" # Forecast date +1d
      properties:
        "text": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          {%- set now = as_timestamp(strptime(state_attr('weather.bessamorel','forecast')[0]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set day = now | timestamp_custom("%w") %}
          {%- set days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] %}
          {{ days[ day | int -1 ] }}{{- now | timestamp_custom(" %d") }}
          {%- endif %}

    - obj: "p5b62" # Forecast temp min +1d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[0]['templow'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b63" # Forecast temp max +1d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[0]['temperature'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b64" # Forecast condition +1d
      properties:
        "src": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          L:/w-32-{{ state_attr('weather.bessamorel','forecast')[0]['condition'] }}.png
          {%- endif %}

    - obj: "p5b71" # Forecast date +2d
      properties:
        "text": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          {%- set now = as_timestamp(strptime(state_attr('weather.bessamorel','forecast')[1]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set day = now | timestamp_custom("%w") %}
          {%- set days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] %}
          {{ days[ day | int -1 ] }}{{- now | timestamp_custom(" %d") }}
          {%- endif %}

    - obj: "p5b72" # Forecast temp min +2d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[1]['templow'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b73" # Forecast temp max +2d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[1]['temperature'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b74" # Forecast condition +2d
      properties:
        "src": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          L:/w-32-{{ state_attr('weather.bessamorel','forecast')[1]['condition'] }}.png
          {%- endif %}

    - obj: "p5b81" # Forecast date +3d
      properties:
        "text": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          {%- set now = as_timestamp(strptime(state_attr('weather.bessamorel','forecast')[2]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set day = now | timestamp_custom("%w") %}
          {%- set days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] %}
          {{ days[ day | int -1 ] }}{{- now | timestamp_custom(" %d") }}
          {%- endif %}

    - obj: "p5b82" # Forecast temp min +3d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[2]['templow'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b83" # Forecast temp max +3d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[2]['temperature'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b84" # Forecast condition +3d
      properties:
        "src": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          L:/w-32-{{ state_attr('weather.bessamorel','forecast')[2]['condition'] }}.png
          {%- endif %}

    - obj: "p5b91" # Forecast date +4d
      properties:
        "text": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          {%- set now = as_timestamp(strptime(state_attr('weather.bessamorel','forecast')[3]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set day = now | timestamp_custom("%w") %}
          {%- set days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] %}
          {{ days[ day | int -1 ] }}{{- now | timestamp_custom(" %d") }}
          {%- endif %}

    - obj: "p5b92" # Forecast temp min +4d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[3]['templow'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b93" # Forecast temp max +4d
      properties:
        "text": "{{ state_attr('weather.bessamorel','forecast')[3]['temperature'] if not is_state('weather.bessamorel','unavailable') else '-' }}"

    - obj: "p5b94" # Forecast condition +4d
      properties:
        "src": >
          {%- if not is_state('weather.bessamorel','unavailable') %}
          L:/w-32-{{ state_attr('weather.bessamorel','forecast')[3]['condition'] }}.png
          {%- endif %}
