Don't update systemmonitor static boot time timestamp (#45165)

This commit is contained in:
Esben Damgaard 2021-01-21 12:35:37 +01:00 committed by GitHub
parent 1f66457a34
commit 25adc6dd4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,9 +316,11 @@ class SystemMonitorSensor(Entity):
else:
self._state = None
elif self.type == "last_boot":
self._state = dt_util.as_local(
dt_util.utc_from_timestamp(psutil.boot_time())
).isoformat()
# Only update on initial setup
if self._state is None:
self._state = dt_util.as_local(
dt_util.utc_from_timestamp(psutil.boot_time())
).isoformat()
elif self.type == "load_1m":
self._state = round(os.getloadavg()[0], 2)
elif self.type == "load_5m":