Fix error in homekit_controller causing some entities to get an incorrect unique id (#53848)
This commit is contained in:
parent
8c5620e74b
commit
73bc62949b
9 changed files with 354 additions and 10 deletions
|
@ -189,11 +189,16 @@ class CharacteristicEntity(HomeKitEntity):
|
|||
the service entity.
|
||||
"""
|
||||
|
||||
def __init__(self, accessory, devinfo, char):
|
||||
"""Initialise a generic single characteristic HomeKit entity."""
|
||||
self._char = char
|
||||
super().__init__(accessory, devinfo)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the ID of this device."""
|
||||
serial = self.accessory_info.value(CharacteristicsTypes.SERIAL_NUMBER)
|
||||
return f"homekit-{serial}-aid:{self._aid}-sid:{self._iid}-cid:{self._iid}"
|
||||
return f"homekit-{serial}-aid:{self._aid}-sid:{self._char.service.iid}-cid:{self._char.iid}"
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
|
|
|
@ -53,9 +53,8 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
|
|||
self._device_class = device_class
|
||||
self._icon = icon
|
||||
self._name = name
|
||||
self._char = char
|
||||
|
||||
super().__init__(conn, info)
|
||||
super().__init__(conn, info, char)
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity is tracking."""
|
||||
|
|
|
@ -254,9 +254,8 @@ class SimpleSensor(CharacteristicEntity, SensorEntity):
|
|||
self._unit = unit
|
||||
self._icon = icon
|
||||
self._name = name
|
||||
self._char = char
|
||||
|
||||
super().__init__(conn, info)
|
||||
super().__init__(conn, info, char)
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity is tracking."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue