Use enum sensor device class in HomeKit Controller (#83109)
This commit is contained in:
parent
46500beefc
commit
a4a80f367b
5 changed files with 92 additions and 26 deletions
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from aiohomekit.model import Accessory, Transport
|
||||
from aiohomekit.model.characteristics import Characteristic, CharacteristicsTypes
|
||||
|
@ -46,8 +45,6 @@ from .connection import HKDevice
|
|||
from .entity import CharacteristicEntity, HomeKitEntity
|
||||
from .utils import folded_name
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomeKitSensorEntityDescription(SensorEntityDescription):
|
||||
|
@ -299,16 +296,35 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
|
|||
CharacteristicsTypes.THREAD_NODE_CAPABILITIES: HomeKitSensorEntityDescription(
|
||||
key=CharacteristicsTypes.THREAD_NODE_CAPABILITIES,
|
||||
name="Thread Capabilities",
|
||||
device_class="homekit_controller__thread_node_capabilities",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
format=thread_node_capability_to_str,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=[
|
||||
"border_router_capable",
|
||||
"full",
|
||||
"minimal",
|
||||
"none",
|
||||
"router_eligible",
|
||||
"sleepy",
|
||||
],
|
||||
translation_key="thread_node_capabilities",
|
||||
),
|
||||
CharacteristicsTypes.THREAD_STATUS: HomeKitSensorEntityDescription(
|
||||
key=CharacteristicsTypes.THREAD_STATUS,
|
||||
name="Thread Status",
|
||||
device_class="homekit_controller__thread_status",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
format=thread_status_to_str,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=[
|
||||
"border_router",
|
||||
"child",
|
||||
"detached",
|
||||
"disabled",
|
||||
"joining",
|
||||
"leader",
|
||||
"router",
|
||||
],
|
||||
translation_key="thread_status",
|
||||
),
|
||||
CharacteristicsTypes.VENDOR_NETATMO_NOISE: HomeKitSensorEntityDescription(
|
||||
key=CharacteristicsTypes.VENDOR_NETATMO_NOISE,
|
||||
|
|
|
@ -69,5 +69,30 @@
|
|||
"button9": "Button 9",
|
||||
"button10": "Button 10"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"thread_node_capabilities": {
|
||||
"state": {
|
||||
"border_router_capable": "Border Router Capable",
|
||||
"full": "Full End Device",
|
||||
"minimal": "Minimal End Device",
|
||||
"none": "None",
|
||||
"router_eligible": "Router Eligible End Device",
|
||||
"sleepy": "Sleepy End Device"
|
||||
}
|
||||
},
|
||||
"thread_status": {
|
||||
"state": {
|
||||
"border_router": "Border Router",
|
||||
"child": "Child",
|
||||
"detached": "Detached",
|
||||
"disabled": "Disabled",
|
||||
"joining": "Joining",
|
||||
"leader": "Leader",
|
||||
"router": "Router"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"state": {
|
||||
"homekit_controller__thread_node_capabilities": {
|
||||
"border_router_capable": "Border Router Capable",
|
||||
"router_eligible": "Router Eligible End Device",
|
||||
"full": "Full End Device",
|
||||
"minimal": "Minimal End Device",
|
||||
"sleepy": "Sleepy End Device",
|
||||
"none": "None"
|
||||
},
|
||||
"homekit_controller__thread_status": {
|
||||
"border_router": "Border Router",
|
||||
"leader": "Leader",
|
||||
"router": "Router",
|
||||
"child": "Child",
|
||||
"joining": "Joining",
|
||||
"detached": "Detached",
|
||||
"disabled": "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,5 +69,30 @@
|
|||
"single_press": "\"{subtype}\" pressed"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"thread_node_capabilities": {
|
||||
"state": {
|
||||
"border_router_capable": "Border Router Capable",
|
||||
"full": "Full End Device",
|
||||
"minimal": "Minimal End Device",
|
||||
"none": "None",
|
||||
"router_eligible": "Router Eligible End Device",
|
||||
"sleepy": "Sleepy End Device"
|
||||
}
|
||||
},
|
||||
"thread_status": {
|
||||
"state": {
|
||||
"border_router": "Border Router",
|
||||
"child": "Child",
|
||||
"detached": "Detached",
|
||||
"disabled": "Disabled",
|
||||
"joining": "Joining",
|
||||
"leader": "Leader",
|
||||
"router": "Router"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": "HomeKit Controller"
|
||||
}
|
|
@ -57,6 +57,16 @@ async def test_nanoleaf_nl55_setup(hass):
|
|||
friendly_name="Nanoleaf Strip 3B32 Thread Capabilities",
|
||||
unique_id="00:00:00:00:00:00_1_31_115",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
capabilities={
|
||||
"options": [
|
||||
"border_router_capable",
|
||||
"full",
|
||||
"minimal",
|
||||
"none",
|
||||
"router_eligible",
|
||||
"sleepy",
|
||||
]
|
||||
},
|
||||
state="border_router_capable",
|
||||
),
|
||||
EntityTestInfo(
|
||||
|
@ -64,6 +74,17 @@ async def test_nanoleaf_nl55_setup(hass):
|
|||
friendly_name="Nanoleaf Strip 3B32 Thread Status",
|
||||
unique_id="00:00:00:00:00:00_1_31_117",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
capabilities={
|
||||
"options": [
|
||||
"border_router",
|
||||
"child",
|
||||
"detached",
|
||||
"disabled",
|
||||
"joining",
|
||||
"leader",
|
||||
"router",
|
||||
]
|
||||
},
|
||||
state="border_router",
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue