Initialize sun with correct values. (#7559)
* Initialize sun with unknown values. Initial values should be `unknown` instead of `0`. Otherwise on HA restart the value of `0` is pushed to metrics databases (graphite/influx/recorder). * Update sun position before emitting initial update * Simplify based on armills comment. * Use provided time for calculation.pull/7571/head
parent
fdb7371256
commit
4a3048b370
|
@ -62,7 +62,7 @@ class Sun(Entity):
|
|||
self._state = self.next_rising = self.next_setting = None
|
||||
self.next_dawn = self.next_dusk = None
|
||||
self.next_midnight = self.next_noon = None
|
||||
self.solar_elevation = self.solar_azimuth = 0
|
||||
self.solar_elevation = self.solar_azimuth = None
|
||||
|
||||
async_track_utc_time_change(hass, self.timer_update, second=30)
|
||||
|
||||
|
@ -124,6 +124,7 @@ class Sun(Entity):
|
|||
@callback
|
||||
def point_in_time_listener(self, now):
|
||||
"""Run when the state of the sun has changed."""
|
||||
self.update_sun_position(now)
|
||||
self.update_as_of(now)
|
||||
self.hass.async_add_job(self.async_update_ha_state())
|
||||
|
||||
|
|
Loading…
Reference in New Issue