Added temperature sensor #47

This commit is contained in:
tomaae 2020-05-27 20:04:09 +02:00
parent b53c346dc6
commit 9eff454269
4 changed files with 32 additions and 3 deletions

View file

@ -36,7 +36,7 @@ Monitor and control your Mikrotik device from Home Assistant.
* Enable/disable Simple Queue switches
* Mikrotik Accounting traffic sensors per hosts for RX/TX WAN/LAN
* Device tracker for hosts in network
* System sensors (CPU, Memory, HDD)
* System sensors (CPU, Memory, HDD, Temperature)
* Check firmware update
* Execute scripts using switches or services
* Configurable update interval

View file

@ -55,6 +55,7 @@ class MikrotikControllerData:
self.data = {
"routerboard": {},
"resource": {},
"health": {},
"interface": {},
"bridge": {},
"bridge_host": {},
@ -269,6 +270,9 @@ class MikrotikControllerData:
if self.api.connected():
await self.hass.async_add_executor_job(self.get_system_resource)
if self.api.connected():
await self.hass.async_add_executor_job(self.get_system_health)
if self.api.connected():
await self.hass.async_add_executor_job(self.get_script)
@ -637,6 +641,17 @@ class MikrotikControllerData:
],
)
# ---------------------------
# get_system_health
# ---------------------------
def get_system_health(self):
"""Get routerboard data from Mikrotik"""
self.data["health"] = parse_api(
data=self.data["health"],
source=self.api.path("/system/health"),
vals=[{"name": "temperature", "default": "unknown"}],
)
# ---------------------------
# get_system_resource
# ---------------------------

View file

@ -2,7 +2,12 @@
import logging
from homeassistant.const import CONF_NAME, ATTR_ATTRIBUTION, ATTR_DEVICE_CLASS
from homeassistant.const import (
CONF_NAME,
ATTR_ATTRIBUTION,
ATTR_DEVICE_CLASS,
TEMP_CELSIUS,
)
from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -34,6 +39,15 @@ ATTR_PATH = "data_path"
ATTR_ATTR = "data_attr"
SENSOR_TYPES = {
"system_temperature": {
ATTR_DEVICE_CLASS: None,
ATTR_ICON: "mdi:thermometer",
ATTR_LABEL: "Temperature",
ATTR_UNIT: TEMP_CELSIUS,
ATTR_GROUP: "System",
ATTR_PATH: "health",
ATTR_ATTR: "temperature",
},
"system_cpu-load": {
ATTR_DEVICE_CLASS: None,
ATTR_ICON: "mdi:speedometer",

View file

@ -16,7 +16,7 @@ Monitor and control your Mikrotik device from Home Assistant.
* Enable/disable Simple Queue switches
* Mikrotik Accounting traffic sensors per hosts for RX/TX WAN/LAN
* Device tracker for hosts in network
* System sensors (CPU, Memory, HDD)
* System sensors (CPU, Memory, HDD, Temperature)
* Check firmware update
* Execute scripts
* Configurable update interval