mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-29 20:14:30 +02:00
parent
d183a67985
commit
1bc901cf9d
2 changed files with 41 additions and 13 deletions
|
@ -107,6 +107,7 @@ class MikrotikControllerData:
|
|||
"routerboard": {},
|
||||
"resource": {},
|
||||
"health": {},
|
||||
"health7": {},
|
||||
"interface": {},
|
||||
"bridge": {},
|
||||
"bridge_host": {},
|
||||
|
@ -1218,11 +1219,25 @@ class MikrotikControllerData:
|
|||
# ---------------------------
|
||||
def get_system_health(self):
|
||||
"""Get routerboard data from Mikrotik"""
|
||||
if self.major_fw_version >= 7:
|
||||
self.data["health7"] = parse_api(
|
||||
data=self.data["health7"],
|
||||
source=self.api.path("/system/health"),
|
||||
key="name",
|
||||
vals=[
|
||||
{"name": "value", "default": "unknown"},
|
||||
],
|
||||
)
|
||||
for uid, vals in self.data["health7"].items():
|
||||
self.data["health"][uid] = vals["value"]
|
||||
|
||||
else:
|
||||
self.data["health"] = parse_api(
|
||||
data=self.data["health"],
|
||||
source=self.api.path("/system/health"),
|
||||
vals=[
|
||||
{"name": "temperature", "default": "unknown"},
|
||||
{"name": "voltage", "default": "unknown"},
|
||||
{"name": "cpu-temperature", "default": "unknown"},
|
||||
{"name": "power-consumption", "default": "unknown"},
|
||||
{"name": "board-temperature1", "default": "unknown"},
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.const import (
|
|||
ATTR_ATTRIBUTION,
|
||||
ATTR_DEVICE_CLASS,
|
||||
TEMP_CELSIUS,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
)
|
||||
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -65,6 +66,16 @@ SENSOR_TYPES = {
|
|||
ATTR_ATTR: "temperature",
|
||||
ATTR_CTGR: None,
|
||||
},
|
||||
"system_voltage": {
|
||||
ATTR_DEVICE_CLASS: SensorDeviceClass.VOLTAGE,
|
||||
ATTR_ICON: "mdi:lightning-bolt",
|
||||
ATTR_LABEL: "Voltage",
|
||||
ATTR_UNIT: ELECTRIC_POTENTIAL_VOLT,
|
||||
ATTR_GROUP: "System",
|
||||
ATTR_PATH: "health",
|
||||
ATTR_ATTR: "voltage",
|
||||
ATTR_CTGR: EntityCategory.DIAGNOSTIC,
|
||||
},
|
||||
"system_cpu-temperature": {
|
||||
ATTR_DEVICE_CLASS: SensorDeviceClass.TEMPERATURE,
|
||||
ATTR_ICON: "mdi:thermometer",
|
||||
|
@ -296,7 +307,9 @@ def update_items(inst, config_entry, mikrotik_controller, async_add_entities, se
|
|||
for sensor in SENSOR_TYPES:
|
||||
if "system_" in sensor:
|
||||
if (
|
||||
mikrotik_controller.data[SENSOR_TYPES[sensor][ATTR_PATH]][
|
||||
SENSOR_TYPES[sensor][ATTR_ATTR]
|
||||
not in mikrotik_controller.data[SENSOR_TYPES[sensor][ATTR_PATH]]
|
||||
or mikrotik_controller.data[SENSOR_TYPES[sensor][ATTR_PATH]][
|
||||
SENSOR_TYPES[sensor][ATTR_ATTR]
|
||||
]
|
||||
== "unknown"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue