Support HomeKit Controller Thread Provisioning (#87809)
This commit is contained in:
parent
402170d49e
commit
f5a05c1bd2
7 changed files with 220 additions and 4 deletions
|
@ -6,6 +6,7 @@ characteristics that don't map to a Home Assistant feature.
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from aiohomekit.model.characteristics import Characteristic, CharacteristicsTypes
|
||||
|
||||
|
@ -24,6 +25,8 @@ from . import KNOWN_DEVICES
|
|||
from .connection import HKDevice
|
||||
from .entity import CharacteristicEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomeKitButtonEntityDescription(ButtonEntityDescription):
|
||||
|
@ -151,6 +154,29 @@ class HomeKitEcobeeClearHoldButton(CharacteristicEntity, ButtonEntity):
|
|||
await self.async_put_characteristics({key: val})
|
||||
|
||||
|
||||
class HomeKitProvisionPreferredThreadCredentials(CharacteristicEntity, ButtonEntity):
|
||||
"""A button users can press to migrate their HomeKit BLE device to Thread."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
|
||||
def get_characteristic_types(self) -> list[str]:
|
||||
"""Define the homekit characteristics the entity is tracking."""
|
||||
return []
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the device if any."""
|
||||
prefix = ""
|
||||
if name := super().name:
|
||||
prefix = name
|
||||
return f"{prefix} Provision Preferred Thread Credentials"
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
await self._accessory.async_thread_provision()
|
||||
|
||||
|
||||
BUTTON_ENTITY_CLASSES: dict[str, type] = {
|
||||
CharacteristicsTypes.VENDOR_ECOBEE_CLEAR_HOLD: HomeKitEcobeeClearHoldButton,
|
||||
CharacteristicsTypes.THREAD_CONTROL_POINT: HomeKitProvisionPreferredThreadCredentials,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue