Add icons according to sensor types.

This commit is contained in:
Tobias Sauerwein 2017-10-23 07:54:57 +00:00
parent 4fa0119245
commit fdc769abf7
1 changed files with 20 additions and 17 deletions

View File

@ -28,21 +28,21 @@ DEFAULT_PORT = '61208'
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
SENSOR_TYPES = {
'disk_use_percent': ['Disk used', '%'],
'disk_use': ['Disk used', 'GiB'],
'disk_free': ['Disk free', 'GiB'],
'memory_use_percent': ['RAM used', '%'],
'memory_use': ['RAM used', 'MiB'],
'memory_free': ['RAM free', 'MiB'],
'swap_use_percent': ['Swap used', '%'],
'swap_use': ['Swap used', 'GiB'],
'swap_free': ['Swap free', 'GiB'],
'processor_load': ['CPU load', '15 min'],
'process_running': ['Running', 'Count'],
'process_total': ['Total', 'Count'],
'process_thread': ['Thread', 'Count'],
'process_sleeping': ['Sleeping', 'Count'],
'cpu_temp': ['CPU Temp', TEMP_CELSIUS],
'disk_use_percent': ['Disk used', '%', 'mdi:harddisk'],
'disk_use': ['Disk used', 'GiB', 'mdi:harddisk'],
'disk_free': ['Disk free', 'GiB', 'mdi:harddisk'],
'memory_use_percent': ['RAM used', '%', 'mdi:memory'],
'memory_use': ['RAM used', 'MiB', 'mdi:memory'],
'memory_free': ['RAM free', 'MiB', 'mdi:memory'],
'swap_use_percent': ['Swap used', '%', 'mdi:memory'],
'swap_use': ['Swap used', 'GiB', 'mdi:memory'],
'swap_free': ['Swap free', 'GiB', 'mdi:memory'],
'processor_load': ['CPU load', '15 min', 'mdi:memory'],
'process_running': ['Running', 'Count', 'mdi:memory'],
'process_total': ['Total', 'Count', 'mdi:memory'],
'process_thread': ['Thread', 'Count', 'mdi:memory'],
'process_sleeping': ['Sleeping', 'Count', 'mdi:memory'],
'cpu_temp': ['CPU Temp', TEMP_CELSIUS, 'mdi:thermometer'],
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@ -87,10 +87,13 @@ class GlancesSensor(Entity):
@property
def name(self):
"""Return the name of the sensor."""
if self._name is None:
return SENSOR_TYPES[self.type][0]
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return SENSOR_TYPES[self.type][2]
@property
def unit_of_measurement(self):
"""Return the unit the value is expressed in."""