Round system monitor load averages to 2 decimal digits (#27558)

On a Raspberry Pi 3, Python 3.7.4:

  # python3 -c "import os; print(os.getloadavg())"
  (0.2724609375, 0.3505859375, 0.3515625)
This commit is contained in:
Ville Skyttä 2019-10-23 18:57:51 +03:00 committed by Paulus Schoutsen
parent 4d8539e151
commit 7431e26752

View File

@ -218,8 +218,8 @@ class SystemMonitorSensor(Entity):
dt_util.utc_from_timestamp(psutil.boot_time()) dt_util.utc_from_timestamp(psutil.boot_time())
).isoformat() ).isoformat()
elif self.type == "load_1m": elif self.type == "load_1m":
self._state = os.getloadavg()[0] self._state = round(os.getloadavg()[0], 2)
elif self.type == "load_5m": elif self.type == "load_5m":
self._state = os.getloadavg()[1] self._state = round(os.getloadavg()[1], 2)
elif self.type == "load_15m": elif self.type == "load_15m":
self._state = os.getloadavg()[2] self._state = round(os.getloadavg()[2], 2)