mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Adds average load to systemmonitor (#5686)
* Adds average load to systemmonitor * split the values in 3 sensors * hound ok
This commit is contained in:
parent
e831a2705e
commit
4aa7f030e8
@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.systemmonitor/
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -38,7 +39,10 @@ SENSOR_TYPES = {
|
||||
'ipv4_address': ['IPv4 address', '', 'mdi:server-network'],
|
||||
'ipv6_address': ['IPv6 address', '', 'mdi:server-network'],
|
||||
'last_boot': ['Last Boot', '', 'mdi:clock'],
|
||||
'since_last_boot': ['Since Last Boot', '', 'mdi:clock']
|
||||
'since_last_boot': ['Since Last Boot', '', 'mdi:clock'],
|
||||
'load_1m': ['Average Load (1m)', '', 'mdi:memory'],
|
||||
'load_5m': ['Average Load (5m)', '', 'mdi:memory'],
|
||||
'load_15m': ['Average Load (15m)', '', 'mdi:memory']
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
@ -164,3 +168,9 @@ class SystemMonitorSensor(Entity):
|
||||
elif self.type == 'since_last_boot':
|
||||
self._state = dt_util.utcnow() - dt_util.utc_from_timestamp(
|
||||
psutil.boot_time())
|
||||
elif self.type == 'load_1m':
|
||||
self._state = os.getloadavg()[0]
|
||||
elif self.type == 'load_5m':
|
||||
self._state = os.getloadavg()[1]
|
||||
elif self.type == 'load_15m':
|
||||
self._state = os.getloadavg()[2]
|
||||
|
Loading…
x
Reference in New Issue
Block a user