Day/night detection is used in sensor.yaml to select the appropriate
weather icon (e.g. 'sunny' vs 'night'). The previous if condition
did not work for the weather_condition_x states, when the _now state
was in a different part of the day/night cycle.
This commit should fix this issue, as long as weather_condition_x is
not too far in the future (not more than one day or night phase).
Additional bug fix:
- fix an indentation bug in weatherman.yaml
I didn't notice a bug in my nigh time symbol check to make the Moon symbols appear after Sun set. Turns out when the Sun has set, the original code was checking the setting of the FOLLOWING day, so the condition was never met, so night time symbols during night were reverting to day time.
This update checks if Sun has set or not, and checks for appropriate rising or setting times depending if Sun has set or not.
(future update would be to swap out Sun rising and setting times with Sun dusk and dawn times, as a bright Sun icon for 8pm (here in UK in summer) looks odd when it is getting dark, meh, maybe?! ¯\_(ツ)_/¯
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(!!) :)