From b6bed1dfabdf4ab59727ef5fc6ffb8571172d379 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 14 Mar 2018 07:47:45 +0000 Subject: [PATCH] Report swap in MiB (#13148) It makes sense to report swap and memory in the same unit and MiB is more useful considering Home Assistant may be running on lower end hardware (Raspberry Pi for example) where 100MiB resolution is not adequate. --- homeassistant/components/sensor/systemmonitor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/systemmonitor.py b/homeassistant/components/sensor/systemmonitor.py index 79d5c261b88..2f970796fe1 100644 --- a/homeassistant/components/sensor/systemmonitor.py +++ b/homeassistant/components/sensor/systemmonitor.py @@ -42,8 +42,8 @@ SENSOR_TYPES = { 'process': ['Process', ' ', 'mdi:memory'], 'processor_use': ['Processor use', '%', 'mdi:memory'], 'since_last_boot': ['Since last boot', '', 'mdi:clock'], - 'swap_free': ['Swap free', 'GiB', 'mdi:harddisk'], - 'swap_use': ['Swap use', 'GiB', 'mdi:harddisk'], + 'swap_free': ['Swap free', 'MiB', 'mdi:harddisk'], + 'swap_use': ['Swap use', 'MiB', 'mdi:harddisk'], 'swap_use_percent': ['Swap use (percent)', '%', 'mdi:harddisk'], } @@ -135,9 +135,9 @@ class SystemMonitorSensor(Entity): elif self.type == 'swap_use_percent': self._state = psutil.swap_memory().percent elif self.type == 'swap_use': - self._state = round(psutil.swap_memory().used / 1024**3, 1) + self._state = round(psutil.swap_memory().used / 1024**2, 1) elif self.type == 'swap_free': - self._state = round(psutil.swap_memory().free / 1024**3, 1) + self._state = round(psutil.swap_memory().free / 1024**2, 1) elif self.type == 'processor_use': self._state = round(psutil.cpu_percent(interval=None)) elif self.type == 'process':