chunkysteveo / OpenEPaperLink-HA-Weatherman

Wetherman EPaper display using OpenEPaperLink and the HA Integration
37 stars 4 forks source link

TypeError: '>' not supported between instances of 'NoneType' and 'int' #22

Closed CrazyCoder closed 7 months ago

CrazyCoder commented 7 months ago

Stopped working after HA 2024.4 update.

Error: Error rendering data template: TypeError: '>' not supported between instances of 'NoneType' and 'int'
service: open_epaper_link.drawcustom
data:
  dry-run: false
  background: white
  rotate: 0
  payload:
    - type: icon
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''moon_phase'') | string }}'
      x: 85
      'y': 1
      size: 18
      color: black
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_temp_0') | string }}{{
        state_attr('sensor.weatherman_data_tag','temperature_unit') }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 125
      'y': 47
      size: 18
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_0') >
        severe_temp_low else 'red' }}
      anchor: mt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_0') | string
        }}
      x: 108
      'y': 13
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_0') in
        severe_weather else 'black' }}
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_temp_1') | string }}{{
        state_attr('sensor.weatherman_data_tag','temperature_unit') }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 174
      'y': 47
      size: 18
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_1') >
        severe_temp_low else 'red' }}
      anchor: mt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_1') | string
        }}
      x: 157
      'y': 13
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_1') in
        severe_weather else 'black' }}
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_temp_2') | string }}{{
        state_attr('sensor.weatherman_data_tag','temperature_unit') }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 223
      'y': 47
      size: 18
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_2') >
        severe_temp_low else 'red' }}
      anchor: mt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_2') | string
        }}
      x: 206
      'y': 13
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_2') in
        severe_weather else 'black' }}
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_temp_3') | string }}{{
        state_attr('sensor.weatherman_data_tag','temperature_unit') }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 272
      'y': 47
      size: 18
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_3') >
        severe_temp_low else 'red' }}
      anchor: mt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_3') | string
        }}
      x: 255
      'y': 13
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_3') in
        severe_weather else 'black' }}
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_4'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 122
      'y': 111
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_4') >
        severe_temp_low else 'red' }}
      anchor: rt
    - type: text
      value: /
      font: ../../media/GothamRnd-Bold.ttf
      x: 125
      'y': 112
      size: 14
      color: black
      anchor: mt
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_4_low'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 128
      'y': 118
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_4_low') >
        severe_temp_low else 'red' }}
      anchor: lt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_4') | string
        }}
      x: 108
      'y': 78
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_4') in
        severe_weather else 'black' }}
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_5'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 171
      'y': 111
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_5') >
        severe_temp_low else 'red' }}
      anchor: rt
    - type: text
      value: /
      font: ../../media/GothamRnd-Bold.ttf
      x: 174
      'y': 112
      size: 14
      color: black
      anchor: mt
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_5_low'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 177
      'y': 118
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_5_low') >
        severe_temp_low else 'red' }}
      anchor: lt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_5') | string
        }}
      x: 157
      'y': 78
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_5') in
        severe_weather else 'black' }}
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_6'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 220
      'y': 111
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_6') >
        severe_temp_low else 'red' }}
      anchor: rt
    - type: text
      value: /
      font: ../../media/GothamRnd-Bold.ttf
      x: 223
      'y': 112
      size: 14
      color: black
      anchor: mt
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_6_low'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 226
      'y': 118
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_6_low') >
        severe_temp_low else 'red' }}
      anchor: lt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_6') | string
        }}
      x: 206
      'y': 78
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_6') in
        severe_weather else 'black' }}
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_7'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 269
      'y': 111
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_7') >
        severe_temp_low else 'red' }}
      anchor: rt
    - type: text
      value: /
      font: ../../media/GothamRnd-Bold.ttf
      x: 272
      'y': 112
      size: 14
      color: black
      anchor: mt
    - type: text
      value: '{{ state_attr(''sensor.weatherman_data_tag'',''wm_temp_7_low'') | string }}'
      font: ../../media/GothamRnd-Bold.ttf
      x: 275
      'y': 118
      size: 14
      color: >-
        {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_7_low') >
        severe_temp_low else 'red' }}
      anchor: lt
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_7') | string
        }}
      x: 255
      'y': 78
      size: 34
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_7') in
        severe_weather else 'black' }}
    - type: text
      value: >-
        {{ '%0.2d' | format(state_attr('sensor.weatherman_data_tag','wm_time_0')
        | int) | string | upper }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 125
      'y': 2
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ '%0.2d' | format(state_attr('sensor.weatherman_data_tag','wm_time_1')
        | int) | string | upper }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 174
      'y': 2
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ '%0.2d' | format(state_attr('sensor.weatherman_data_tag','wm_time_2')
        | int) | string | upper }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 223
      'y': 2
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ '%0.2d' | format(state_attr('sensor.weatherman_data_tag','wm_time_3')
        | int) | string | upper }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 272
      'y': 2
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_time_4') | string | upper
        }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 125
      'y': 67
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_time_5') | string | upper
        }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 174
      'y': 67
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_time_6') | string | upper
        }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 223
      'y': 67
      size: 12
      color: black
      anchor: mt
    - type: text
      value: >-
        {{ state_attr('sensor.weatherman_data_tag','wm_time_7') | string | upper
        }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 272
      'y': 67
      size: 12
      color: black
      anchor: mt
    - type: line
      fill: black
      width: 1
      x_start: 125
      y_start: 64
      x_end: 272
      y_end: 64
    - type: text
      value: >-
        {{ states('sensor.average_outside_temperature') | round | int(0) }}{{
        state_attr('sensor.weatherman_data_tag','temperature_unit') }}
      font: ../../media/GothamRnd-Bold.ttf
      x: 52
      'y': 94
      size: 38
      anchor: mt
      color: >-
        {{'black' if states('sensor.average_outside_temperature') | round >
        severe_temp_low else 'red' }}
    - type: icon
      value: >-
        weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_now') |
        string }}
      x: 6
      'y': 2
      size: 92
      color: >-
        {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_now') in
        severe_weather else 'black' }}
target:
  entity_id:
    - open_epaper_link.0000021EE4583B13

Also noticed this error in the logs:

Template variable error: 'None' has no attribute 'split' when rendering '{% set cond_moon = state_attr('sensor.moon_phase', 'icon') %} {{ cond_moon.split('mdi:')[1] }}'
svenove commented 7 months ago

I believe this is already fixed in the latest version: https://github.com/chunkysteveo/OpenEPaperLink-HA-Weatherman/blob/main/ha-configuration.yaml

CrazyCoder commented 7 months ago

Oh, thanks, quite a lot of changes. Will merge into my config and report back.

CrazyCoder commented 7 months ago

Now getting this:

Error: Non valid icon used: weather-clear-night
      - type: icon
        value: weather-clear-night
        x: 206
        'y': 78
        size: 34
        color: black

Forecast:

chrome_2024-04-05_11-01-17

Happens with 2.9 tag automation (automation-2.9.yaml).

Trigger in configuration.yaml:

  - trigger:
      platform: time_pattern
      minutes: "/15"
    action:
      - service: weather.get_forecasts
        target:
          entity_id: weather.home
        data:
          type: hourly
        response_variable: weather_home_hourly
      - service: weather.get_forecasts
        target:
          entity_id: weather.home
        data:
          type: daily
        response_variable: weather_home_daily   
    sensor:
      - name: Weatherman Data Tag
        state: "{{ now().isoformat() }}"
        attributes:
          moon_phase: >
            {% set cond_moon = states('sensor.moon_phase') %}
            {{ "moon-" + cond_moon | replace("_", "-") }}
          sun_next_rising: >
            {{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_custom('%-I:%M %p') }}
          sun_next_setting: >
            {{ as_timestamp(state_attr("sun.sun", "next_setting")) | timestamp_custom('%-I:%M %p') }}  
          temperature_unit: "{{ state_attr('weather.home','temperature_unit') }}"
          wind_speed_unit: "{{ state_attr('weather.home','wind_speed_unit') }}"
          precipitation_unit: "{{ state_attr('weather.home','precipitation_unit') }}"  
          pressure_unit: "{{ state_attr('weather.home','pressure_unit') }}"
          wm_cond_now: >
            {% set cond_now = states('weather.home') %}
            {% if cond_now == 'partlycloudy' %}{% set cond_now = 'partly-cloudy' %}{% endif %}
            {% if cond_now == 'clear-night' %}{% set cond_now = 'night' %}{% endif %}
            {% if states('sun.sun') == 'below_horizon' %}
                {% if cond_now == 'sunny' %} night {% elif cond_now == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %}
            {% else %}
                {{ cond_now }}
            {% endif %}
          wm_temp_now: >
            {{ state_attr('weather.home','temperature') }}  
          wm_wind_speed_now: >
            {{ state_attr('weather.home','wind_speed') | round }}
          wm_wind_dir_now: >
            {{ state_attr('weather.home','wind_bearing') | round }}    
          wm_dew_point_now: >
            {{ state_attr('weather.home','dew_point') }}
          wm_humidity_now: >
            {{ state_attr('weather.home','humidity') }}
          wm_cloud_coverage_now: >
            {{ state_attr('weather.home','cloud_coverage') }}
          wm_pressure_now: >
            {{ state_attr('weather.home','pressure') }}  
          wm_cond_0: >
            {% set cond0 = weather_home_hourly['weather.home']['forecast'][0].condition %}
            {% if cond0 == 'partlycloudy' %}{% set cond0 = 'partly-cloudy' %}{% endif %}
            {% if cond0 == 'clear-night' %}{% set cond0 = 'night' %}{% endif %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond0_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][0].datetime) %}
            {% if states('sun.sun') == 'above_horizon' and cond0_time > next_setting %}
                {% if cond0 == 'sunny' %} night {% elif cond0 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
            {% elif states('sun.sun') == 'below_horizon' and cond0_time < next_rising %}
                {% if cond0 == 'sunny' %} night {% elif cond0 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}    
            {% else %}
                {{ cond0 }}
            {% endif %}
          wm_temp_0: >
            {{ weather_home_hourly['weather.home']['forecast'][0].temperature | round }}
          wm_precipitation_0: >
            {{ weather_home_hourly['weather.home']['forecast'][0].precipitation }}
          wm_wind_speed_0: >
            {{ weather_home_hourly['weather.home']['forecast'][0].wind_speed | round }}
          wm_wind_dir_0: >
            {{ weather_home_hourly['weather.home']['forecast'][0].wind_bearing | round }}
          wm_time_0: >
            {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][0].datetime) | timestamp_custom('%H') | int }}
          wm_cond_1: >
            {% set cond1 = weather_home_hourly['weather.home']['forecast'][1].condition %}
            {% if cond1 == 'partlycloudy' %}{% set cond1 = 'partly-cloudy' %}{% endif %}
            {% if cond1 == 'clear-night' %}{% set cond1 = 'night' %}{% endif %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond1_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][1].datetime) %}
            {% if states('sun.sun') == 'above_horizon' and cond1_time > next_setting %}
                {% if cond1 == 'sunny' %} night {% elif cond1 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %}
            {% elif states('sun.sun') == 'below_horizon' and cond1_time < next_rising %}
                {% if cond1 == 'sunny' %} night {% elif cond1 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %}
            {% else %}
                {{ cond1 }}
            {% endif %}
          wm_temp_1: >
            {{ weather_home_hourly['weather.home']['forecast'][1].temperature | round }}
          wm_precipitation_1: >
            {{ weather_home_hourly['weather.home']['forecast'][1].precipitation }}
          wm_wind_speed_1: >
            {{ weather_home_hourly['weather.home']['forecast'][1].wind_speed | round }}
          wm_wind_dir_1: >
            {{ weather_home_hourly['weather.home']['forecast'][1].wind_bearing | round }}
          wm_time_1: >
            {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][1].datetime) | timestamp_custom('%H') | int }}
          wm_cond_2: >
            {% set cond2 = weather_home_hourly['weather.home']['forecast'][2].condition %}
            {% if cond2 == 'partlycloudy' %}{% set cond2 = 'partly-cloudy' %}{% endif %}
            {% if cond2 == 'clear-night' %}{% set cond2 = 'night' %}{% endif %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond2_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][2].datetime) %}
            {% if states('sun.sun') == 'above_horizon' and cond2_time > next_setting %}
                {% if cond2 == 'sunny' %} night {% elif cond2 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %}
            {% elif states('sun.sun') == 'below_horizon' and cond2_time < next_rising %}
                {% if cond2 == 'sunny' %} night {% elif cond2 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %}
            {% else %}
                {{ cond2 }}
            {% endif %}
          wm_temp_2: >
            {{ weather_home_hourly['weather.home']['forecast'][2].temperature | round }}
          wm_precipitation_2: >
            {{ weather_home_hourly['weather.home']['forecast'][2].precipitation }}
          wm_wind_speed_2: >
            {{ weather_home_hourly['weather.home']['forecast'][2].wind_speed | round }}
          wm_wind_dir_2: >
            {{ weather_home_hourly['weather.home']['forecast'][2].wind_bearing | round }}
          wm_time_2: >
            {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][2].datetime) | timestamp_custom('%H') | int }}
          wm_cond_3: >
            {% set cond3 = weather_home_hourly['weather.home']['forecast'][3].condition %}
            {% if cond3 == 'partlycloudy' %}{% set cond3 = 'partly-cloudy' %}{% endif %}
            {% if cond3 == 'clear-night' %}{% set cond3 = 'night' %}{% endif %}
            {% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
            {% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
            {% set cond3_time = as_timestamp(weather_home_hourly['weather.home']['forecast'][3].datetime) %}
            {% if states('sun.sun') == 'above_horizon' and cond3_time > next_setting %}
                {% if cond3 == 'sunny' %} night {% elif cond3 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %}
            {% elif states('sun.sun') == 'below_horizon' and cond3_time < next_rising %}
                {% if cond3 == 'sunny' %} night {% elif cond3 == 'partly-cloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %}
            {% else %}
                {{ cond3 }}
            {% endif %}
          wm_temp_3: >
            {{ weather_home_hourly['weather.home']['forecast'][3].temperature | round }}
          wm_precipitation_3: >
            {{ weather_home_hourly['weather.home']['forecast'][3].precipitation }}
          wm_wind_speed_3: >
            {{ weather_home_hourly['weather.home']['forecast'][3].wind_speed | round }}
          wm_wind_dir_3: >
            {{ weather_home_hourly['weather.home']['forecast'][3].wind_bearing | round }}
          wm_time_3: >
            {{ as_timestamp(weather_home_hourly['weather.home']['forecast'][3].datetime) | timestamp_custom('%H') | int }}
          wm_cond_4: >
            {% set cond4 = weather_home_daily['weather.home']['forecast'][1].condition %}
            {% if cond4 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond4 }} {% endif %}
          wm_temp_4: >
            {{ weather_home_daily['weather.home']['forecast'][1].temperature | round }}
          wm_precipitation_4: >
            {{ weather_home_daily['weather.home']['forecast'][1].precipitation }}
          wm_temp_4_low: >
            {{ weather_home_daily['weather.home']['forecast'][1].templow | round }}
          wm_wind_speed_4: >
            {{ weather_home_daily['weather.home']['forecast'][1].wind_speed | round }}
          wm_wind_dir_4: >
            {{ weather_home_daily['weather.home']['forecast'][1].wind_bearing | round }}
          wm_time_4: >
            {{ "%s" % (["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][as_timestamp(weather_home_daily['weather.home']['forecast'][1].datetime) | timestamp_custom('%w') | int]) }}
          wm_cond_5: >
            {% set cond5 = weather_home_daily['weather.home']['forecast'][2].condition %}
            {% if cond5 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond5 }} {% endif %}
          wm_temp_5: >
            {{ weather_home_daily['weather.home']['forecast'][2].temperature | round }}
          wm_precipitation_5: >
            {{ weather_home_daily['weather.home']['forecast'][2].precipitation }}
          wm_temp_5_low: >
            {{ weather_home_daily['weather.home']['forecast'][2].templow | round }}
          wm_wind_speed_5: >
            {{ weather_home_daily['weather.home']['forecast'][2].wind_speed | round }}
          wm_wind_dir_5: >
            {{ weather_home_daily['weather.home']['forecast'][2].wind_bearing | round }}
          wm_time_5: >
            {{ "%s" % (["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][as_timestamp(weather_home_daily['weather.home']['forecast'][2].datetime) | timestamp_custom('%w') | int]) }}
          wm_cond_6: >
            {% set cond6 = weather_home_daily['weather.home']['forecast'][3].condition %}
            {% if cond6 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond6 }} {% endif %}
          wm_temp_6: >
            {{ weather_home_daily['weather.home']['forecast'][3].temperature | round }}
          wm_precipitation_6: >
            {{ weather_home_daily['weather.home']['forecast'][3].precipitation }}
          wm_temp_6_low: >
            {{ weather_home_daily['weather.home']['forecast'][3].templow | round }}
          wm_wind_speed_6: >
            {{ weather_home_daily['weather.home']['forecast'][3].wind_speed | round }}
          wm_wind_dir_6: >
            {{ weather_home_daily['weather.home']['forecast'][3].wind_bearing | round }}
          wm_time_6: >
            {{ "%s" % (["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][as_timestamp(weather_home_daily['weather.home']['forecast'][3].datetime) | timestamp_custom('%w') | int]) }}  
          wm_cond_7: >
            {% set cond7 = weather_home_daily['weather.home']['forecast'][4].condition %}
            {% if cond7 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond7 }} {% endif %}
          wm_temp_7: >
            {{ weather_home_daily['weather.home']['forecast'][4].temperature | round }}
          wm_precipitation_7: >
            {{ weather_home_daily['weather.home']['forecast'][4].precipitation }}
          wm_temp_7_low: >
            {{ weather_home_daily['weather.home']['forecast'][4].templow | round }}
          wm_wind_speed_7: >
            {{ weather_home_daily['weather.home']['forecast'][4].wind_speed | round }}
          wm_wind_dir_7: >
            {{ weather_home_daily['weather.home']['forecast'][4].wind_bearing | round }}
          wm_time_7: >
            {{ "%s" % (["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][as_timestamp(weather_home_daily['weather.home']['forecast'][4].datetime) | timestamp_custom('%w') | int]) }}
          wm_cond_8: >
            {% set cond8 = weather_home_daily['weather.home']['forecast'][5].condition %}
            {% if cond8 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond8 }} {% endif %}
          wm_temp_8: >
            {{ weather_home_daily['weather.home']['forecast'][5].temperature | round }}
          wm_temp_8_low: >
            {{ weather_home_daily['weather.home']['forecast'][5].templow | round }}    
          wm_precipitation_8: >
            {{ weather_home_daily['weather.home']['forecast'][5].precipitation }}
          wm_wind_speed_8: >
            {{ weather_home_daily['weather.home']['forecast'][5].wind_speed | round }}
          wm_wind_dir_8: >
            {{ weather_home_daily['weather.home']['forecast'][5].wind_bearing | round }}
          wm_time_8: >
            {{ "%s" % (["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][as_timestamp(weather_home_daily['weather.home']['forecast'][5].datetime) | timestamp_custom('%w') | int]) }}

Full automation YAML:

alias: Epaper - Weatherman - 2.9"
description: ""
trigger:
  - platform: time_pattern
    minutes: /58
condition:
  - condition: time
    after: "5:39:00"
    before: "01:00:00"
action:
  - service: open_epaper_link.drawcustom
    data:
      dry-run: false
      background: white
      rotate: 0
      payload:
        - type: icon
          value: "{{ state_attr('sensor.weatherman_data_tag','moon_phase') | string }}"
          x: 85
          "y": 1
          size: 18
          color: black
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_0') | string
            }}{{ state_attr('sensor.weatherman_data_tag','temperature_unit') }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 125
          "y": 47
          size: 18
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_0') >
            severe_temp_low else 'red' }}
          anchor: mt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_0') |
            string }}
          x: 108
          "y": 13
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_0') in
            severe_weather else 'black' }}
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_1') | string
            }}{{ state_attr('sensor.weatherman_data_tag','temperature_unit') }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 174
          "y": 47
          size: 18
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_1') >
            severe_temp_low else 'red' }}
          anchor: mt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_1') |
            string }}
          x: 157
          "y": 13
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_1') in
            severe_weather else 'black' }}
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_2') | string
            }}{{ state_attr('sensor.weatherman_data_tag','temperature_unit') }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 223
          "y": 47
          size: 18
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_2') >
            severe_temp_low else 'red' }}
          anchor: mt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_2') |
            string }}
          x: 206
          "y": 13
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_2') in
            severe_weather else 'black' }}
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_3') | string
            }}{{ state_attr('sensor.weatherman_data_tag','temperature_unit') }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 272
          "y": 47
          size: 18
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_3') >
            severe_temp_low else 'red' }}
          anchor: mt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_3') |
            string }}
          x: 255
          "y": 13
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_3') in
            severe_weather else 'black' }}
        - type: text
          value: "{{ state_attr('sensor.weatherman_data_tag','wm_temp_4') | string }}"
          font: ../../media/GothamRnd-Bold.ttf
          x: 122
          "y": 111
          size: 14
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_4') >
            severe_temp_low else 'red' }}
          anchor: rt
        - type: text
          value: /
          font: ../../media/GothamRnd-Bold.ttf
          x: 125
          "y": 112
          size: 14
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_4_low') | string
            }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 128
          "y": 118
          size: 14
          color: >-
            {{'black' if
            state_attr('sensor.weatherman_data_tag','wm_temp_4_low') >
            severe_temp_low else 'red' }}
          anchor: lt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_4') |
            string }}
          x: 108
          "y": 78
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_4') in
            severe_weather else 'black' }}
        - type: text
          value: "{{ state_attr('sensor.weatherman_data_tag','wm_temp_5') | string }}"
          font: ../../media/GothamRnd-Bold.ttf
          x: 171
          "y": 111
          size: 14
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_5') >
            severe_temp_low else 'red' }}
          anchor: rt
        - type: text
          value: /
          font: ../../media/GothamRnd-Bold.ttf
          x: 174
          "y": 112
          size: 14
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_5_low') | string
            }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 177
          "y": 118
          size: 14
          color: >-
            {{'black' if
            state_attr('sensor.weatherman_data_tag','wm_temp_5_low') >
            severe_temp_low else 'red' }}
          anchor: lt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_5') |
            string }}
          x: 157
          "y": 78
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_5') in
            severe_weather else 'black' }}
        - type: text
          value: "{{ state_attr('sensor.weatherman_data_tag','wm_temp_6') | string }}"
          font: ../../media/GothamRnd-Bold.ttf
          x: 220
          "y": 111
          size: 14
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_6') >
            severe_temp_low else 'red' }}
          anchor: rt
        - type: text
          value: /
          font: ../../media/GothamRnd-Bold.ttf
          x: 223
          "y": 112
          size: 14
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_6_low') | string
            }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 226
          "y": 118
          size: 14
          color: >-
            {{'black' if
            state_attr('sensor.weatherman_data_tag','wm_temp_6_low') >
            severe_temp_low else 'red' }}
          anchor: lt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_6') |
            string }}
          x: 206
          "y": 78
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_6') in
            severe_weather else 'black' }}
        - type: text
          value: "{{ state_attr('sensor.weatherman_data_tag','wm_temp_7') | string }}"
          font: ../../media/GothamRnd-Bold.ttf
          x: 269
          "y": 111
          size: 14
          color: >-
            {{'black' if state_attr('sensor.weatherman_data_tag','wm_temp_7') >
            severe_temp_low else 'red' }}
          anchor: rt
        - type: text
          value: /
          font: ../../media/GothamRnd-Bold.ttf
          x: 272
          "y": 112
          size: 14
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_temp_7_low') | string
            }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 275
          "y": 118
          size: 14
          color: >-
            {{'black' if
            state_attr('sensor.weatherman_data_tag','wm_temp_7_low') >
            severe_temp_low else 'red' }}
          anchor: lt
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_7') |
            string }}
          x: 255
          "y": 78
          size: 34
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_7') in
            severe_weather else 'black' }}
        - type: text
          value: >-
            {{ '%0.2d' |
            format(state_attr('sensor.weatherman_data_tag','wm_time_0') | int) |
            string | upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 125
          "y": 2
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ '%0.2d' |
            format(state_attr('sensor.weatherman_data_tag','wm_time_1') | int) |
            string | upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 174
          "y": 2
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ '%0.2d' |
            format(state_attr('sensor.weatherman_data_tag','wm_time_2') | int) |
            string | upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 223
          "y": 2
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ '%0.2d' |
            format(state_attr('sensor.weatherman_data_tag','wm_time_3') | int) |
            string | upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 272
          "y": 2
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_time_4') | string |
            upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 125
          "y": 67
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_time_5') | string |
            upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 174
          "y": 67
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_time_6') | string |
            upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 223
          "y": 67
          size: 12
          color: black
          anchor: mt
        - type: text
          value: >-
            {{ state_attr('sensor.weatherman_data_tag','wm_time_7') | string |
            upper }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 272
          "y": 67
          size: 12
          color: black
          anchor: mt
        - type: line
          fill: black
          width: 1
          x_start: 125
          y_start: 64
          x_end: 272
          y_end: 64
        - type: text
          value: >-
            {{ states('sensor.average_outside_temperature') | round | int(0)
            }}{{ state_attr('sensor.weatherman_data_tag','temperature_unit') }}
          font: ../../media/GothamRnd-Bold.ttf
          x: 52
          "y": 94
          size: 38
          anchor: mt
          color: >-
            {{'black' if states('sensor.average_outside_temperature') | round >
            severe_temp_low else 'red' }}
        - type: icon
          value: >-
            weather-{{ state_attr('sensor.weatherman_data_tag','wm_cond_now') |
            string }}
          x: 6
          "y": 2
          size: 92
          color: >-
            {{'red' if state_attr('sensor.weatherman_data_tag','wm_cond_now') in
            severe_weather else 'black' }}
    target:
      entity_id:
        - open_epaper_link.0000021EE4583B13
variables:
  severe_weather:
    - fog
    - hail
    - lightning
    - lightning-rainy
    - pouring
    - snowy
    - snowy-rainy
    - windy
    - windy-variant
    - exceptional
  severe_temp_low: 3
mode: restart
chunkysteveo commented 7 months ago

The night time icons have changed for met.no as well since last year. I'd recommend starting with a fresh sensor template and fresh automations. It's working on all my tags sizes with the latest version of HA without any issues.

CrazyCoder commented 7 months ago

I started with a fresh template, but it doesn't work for some reason. I did not have this problem before HA update. My templates are posted above, and as you can see, there are only minor changes for 24h format compared to what is available in this repository.

I did diff them to double-check. Any idea why the icon name is not replaced?

CrazyCoder commented 7 months ago

@chunkysteveo I think I know where the problem is. You fix the clear-night icon for weather_home_hourly conditions, but for weather_home_daily you did not add the code for that.

Here the code is correct:

          wm_cond_3: >
            {% set cond3 = weather_home_hourly['weather.home']['forecast'][3].condition %}
            {% if cond3 == 'partlycloudy' %}{% set cond3 = 'partly-cloudy' %}{% endif %}
            {% if cond3 == 'clear-night' %}{% set cond3 = 'night' %}{% endif %}

Below, you fix only partlycloudy, but not clear-night:

          wm_cond_4: >
            {% set cond4 = weather_home_daily['weather.home']['forecast'][1].condition %}
            {% if cond4 == 'partlycloudy' %} partly-cloudy {% else %} {{ cond4 }} {% endif %}

The same issue for wm_cond_5...8.

It just happened that my weather has triggered this bug. See the picture of the weather conditions I posted above. Some days show the clear night icon for some reason. This could be HA weather bug as it doesn't seem correct to show night icons for the next several-day weather forecast.

chunkysteveo commented 7 months ago

Ohhh, I wonder.... so now the template sensor asks for the daily forecast at the same time as the hourly. Originally the daily forecast was just given, and was for 12 noon, so never a night-clear. I wonder if the daily forecast request takes into account the time of day, and not 12 noon?

....investigating!

CrazyCoder commented 7 months ago

It's 09:30 in the morning now, but the daily forecast still shows nigh icons for April 9 to 11:

chrome_2024-04-06_09-29-28
chunkysteveo commented 7 months ago

Hmmm, I see your screenshot and your daily forecast icons are night time icons further down the week, that makes no sense, unless you're at the South Pole???! I've checked my daily forecast call and it's still showing as noon time.

I can fix it by adding in the icon check fix, for night for daily forecast - but that's just me putting a plaster over it.... I wonder why or how your daily forecast is showing moons?

My forecast card still shows 'suns' for clear night conditions, which I think is still an ongoing issue with the HA weather card?

Life's too short though... I'll just add in the icon fix later today to cover any daily forecast that says it's night time!!! 🤣

CrazyCoder commented 7 months ago

Thanks! I also filed a bug at https://github.com/home-assistant/core/issues/115035.

chunkysteveo commented 7 months ago

Awesome! There's something odd going on for sure!! You're not at the South Pole i guess either...??!! 🤣🤣🥶

chunkysteveo commented 7 months ago

Hey @CrazyCoder - i've updated https://github.com/chunkysteveo/OpenEPaperLink-HA-Weatherman/blob/main/ha-configuration.yaml with the fixes to check for any night time based conditions for the daily forecasts while and after they fix that bug... if they do... "belts and braces" to check for all events - I am guessing South Pole and Northern areas (Norway, Canada, etc) could legitimately get night time conditions during the day, who knows....?! At least it will work for them 👍

If you're happy with the updates, please let me know and close off this issue?!

Steve

CrazyCoder commented 7 months ago

Thanks. Applied the fixes and it updates again. I can live with night icons for daily forecast until it's fixed in HA core. Feel free to close.