mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-23 01:08:55 +02:00
Added entity category support
This commit is contained in:
parent
448483da22
commit
274de8c6fd
2 changed files with 32 additions and 1 deletions
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
)
|
||||
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
|
||||
from .const import (
|
||||
|
@ -51,6 +52,7 @@ ATTR_UNIT_ATTR = "unit_attr"
|
|||
ATTR_GROUP = "group"
|
||||
ATTR_PATH = "data_path"
|
||||
ATTR_ATTR = "data_attr"
|
||||
ATTR_CTGR = "entity_category"
|
||||
|
||||
SENSOR_TYPES = {
|
||||
"system_temperature": {
|
||||
|
@ -115,6 +117,7 @@ SENSOR_TYPES = {
|
|||
ATTR_GROUP: "System",
|
||||
ATTR_PATH: "resource",
|
||||
ATTR_ATTR: "uptime",
|
||||
ATTR_CTGR: EntityCategory.DIAGNOSTIC,
|
||||
},
|
||||
"system_cpu-load": {
|
||||
ATTR_DEVICE_CLASS: None,
|
||||
|
@ -366,6 +369,11 @@ class MikrotikControllerSensor(SensorEntity):
|
|||
self._device_class = None
|
||||
self._state = None
|
||||
|
||||
if ATTR_CTGR in self._type:
|
||||
self._entity_category = self._type[ATTR_CTGR]
|
||||
else:
|
||||
self._entity_category = None
|
||||
|
||||
if ATTR_ICON in self._type:
|
||||
self._icon = self._type[ATTR_ICON]
|
||||
else:
|
||||
|
@ -401,6 +409,14 @@ class MikrotikControllerSensor(SensorEntity):
|
|||
|
||||
return None
|
||||
|
||||
@property
|
||||
def entity_category(self) -> str:
|
||||
"""Return entity category"""
|
||||
if self._entity_category:
|
||||
return self._entity_category
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
"""Return the device class."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue