Night Time Clear (sunny) and Partly Cloudy Updates

With met.no weather feed to Home Assistant - there's no difference in night time weather and daytime - specifically a clear night and partly clear night. 

A Clear sky is classed as a "sunny" state, even at night. I have added some checks in the HA yaml template to check if the Sun sensor (You need Sun in your Home Assistant install) is state = "below_horizon" and update "sunny" and "partlycloudy" to be "night" and "night-partly-cloudy". This then requests icons in the ESPHome yaml to include the Moon - which makes it look right when you are looking at the display at night, or when the upcoming forecast hours are night time - a clear night sky = the Moon, not the Sun.

Or at least it makes more sense in my eyes to see the Moon icons at night that seeing a clear Sunny day predicted for 2AM(!!) :)
pull/3/head
Stephen Ludgate 2 years ago committed by GitHub
parent 6e268c8bda
commit 5c83360b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,27 +55,52 @@ template:
train_status_canarsie: >
{{ state_attr('sensor.mta_subway_l_service_status', 'direction_statuses').south | upper }}
weather_condition_now: >
{{ states('weather.hourly') }}
{% set cond_now = states('weather.hourly') %}
{% if states('sun.sun') == 'below_horizon' %}
{% if cond_now == 'sunny' %} night {% elif cond_now == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %}
{% else %}
{{ cond_now }}
{% endif %}
weather_condition_0: >
{{ state_attr('weather.hourly', 'forecast')[0].condition }}
{% set cond0 = state_attr('weather.hourly', 'forecast')[0].condition %}
{% if states('sun.sun') == 'below_horizon' %}
{% if cond0 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
{% else %}
{{ cond0 }}
{% endif %}
weather_temperature_0: >
{{ state_attr('weather.hourly', 'forecast')[0].temperature | round }}
weather_timestamp_0: >
{{ as_timestamp(state_attr('weather.hourly', 'forecast')[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[0].datetime) | timestamp_custom('%p') }}
weather_condition_1: >
{{ state_attr('weather.hourly', 'forecast')[1].condition }}
{% set cond1 = state_attr('weather.hourly', 'forecast')[1].condition %}
{% if states('sun.sun') == 'below_horizon' %}
{% if cond1 == 'sunny' %} night {% elif cond1 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %}
{% else %}
{{ cond1 }}
{% endif %}
weather_temperature_1: >
{{ state_attr('weather.hourly', 'forecast')[1].temperature | round }}
weather_timestamp_1: >
{{ as_timestamp(state_attr('weather.hourly', 'forecast')[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[1].datetime) | timestamp_custom('%p') }}
weather_condition_2: >
{{ state_attr('weather.hourly', 'forecast')[2].condition }}
{% set cond2 = state_attr('weather.hourly', 'forecast')[2].condition %}
{% if states('sun.sun') == 'below_horizon' %}
{% if cond2 == 'sunny' %} night {% elif cond2 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %}
{% else %}
{{ cond2 }}
{% endif %}
weather_temperature_2: >
{{ state_attr('weather.hourly', 'forecast')[2].temperature | round }}
weather_timestamp_2: >
{{ as_timestamp(state_attr('weather.hourly', 'forecast')[2].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[2].datetime) | timestamp_custom('%p') }}
weather_condition_3: >
{{ state_attr('weather.hourly', 'forecast')[3].condition }}
{% set cond3 = state_attr('weather.hourly', 'forecast')[3].condition %}
{% if states('sun.sun') == 'below_horizon' %}
{% if cond3 == 'sunny' %} night {% elif cond3 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %}
{% else %}
{{ cond3 }}
{% endif %}
weather_temperature_3: >
{{ state_attr('weather.hourly', 'forecast')[3].temperature | round }}
weather_timestamp_3: >

Loading…
Cancel
Save