Add Glances sensors dynamically (#28639)

* Add temp_sensors to glances dynamically

* unsub from updates when sensor is disabled

* dynamicall add sensors

* change "device_name" to "mnt_point"

* remove unnecessary logging

* update sensor.py

* update test_config_flow.py

* remove commented code
This commit is contained in:
Rami Mosleh 2020-02-11 01:02:14 +02:00 committed by GitHub
parent d55846c33a
commit c66106ee98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 152 additions and 86 deletions

View file

@ -14,23 +14,23 @@ DATA_UPDATED = "glances_data_updated"
SUPPORTED_VERSIONS = [2, 3]
SENSOR_TYPES = {
"disk_use_percent": ["Disk used percent", "%", "mdi:harddisk"],
"disk_use": ["Disk used", "GiB", "mdi:harddisk"],
"disk_free": ["Disk free", "GiB", "mdi:harddisk"],
"memory_use_percent": ["RAM used percent", "%", "mdi:memory"],
"memory_use": ["RAM used", "MiB", "mdi:memory"],
"memory_free": ["RAM free", "MiB", "mdi:memory"],
"swap_use_percent": ["Swap used percent", "%", "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_use_percent": ["CPU used", "%", "mdi:memory"],
"cpu_temp": ["CPU Temp", TEMP_CELSIUS, "mdi:thermometer"],
"docker_active": ["Containers active", "", "mdi:docker"],
"docker_cpu_use": ["Containers CPU used", "%", "mdi:docker"],
"docker_memory_use": ["Containers RAM used", "MiB", "mdi:docker"],
"disk_use_percent": ["fs", "used percent", "%", "mdi:harddisk"],
"disk_use": ["fs", "used", "GiB", "mdi:harddisk"],
"disk_free": ["fs", "free", "GiB", "mdi:harddisk"],
"memory_use_percent": ["mem", "RAM used percent", "%", "mdi:memory"],
"memory_use": ["mem", "RAM used", "MiB", "mdi:memory"],
"memory_free": ["mem", "RAM free", "MiB", "mdi:memory"],
"swap_use_percent": ["memswap", "Swap used percent", "%", "mdi:memory"],
"swap_use": ["memswap", "Swap used", "GiB", "mdi:memory"],
"swap_free": ["memswap", "Swap free", "GiB", "mdi:memory"],
"processor_load": ["load", "CPU load", "15 min", "mdi:memory"],
"process_running": ["processcount", "Running", "Count", "mdi:memory"],
"process_total": ["processcount", "Total", "Count", "mdi:memory"],
"process_thread": ["processcount", "Thread", "Count", "mdi:memory"],
"process_sleeping": ["processcount", "Sleeping", "Count", "mdi:memory"],
"cpu_use_percent": ["cpu", "CPU used", "%", "mdi:memory"],
"sensor_temp": ["sensors", "Temp", TEMP_CELSIUS, "mdi:thermometer"],
"docker_active": ["docker", "Containers active", "", "mdi:docker"],
"docker_cpu_use": ["docker", "Containers CPU used", "%", "mdi:docker"],
"docker_memory_use": ["docker", "Containers RAM used", "MiB", "mdi:docker"],
}