Collection of changing entity properties to class attributes - 2 (#51345)
This commit is contained in:
parent
e5dff49440
commit
fcdd8b11a6
24 changed files with 70 additions and 215 deletions
|
@ -32,6 +32,8 @@ def escape_characteristic_name(char_name):
|
|||
class HomeKitEntity(Entity):
|
||||
"""Representation of a Home Assistant HomeKit device."""
|
||||
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, accessory, devinfo):
|
||||
"""Initialise a generic HomeKit device."""
|
||||
self._accessory = accessory
|
||||
|
@ -99,14 +101,6 @@ class HomeKitEntity(Entity):
|
|||
payload = self.service.build_update(characteristics)
|
||||
return await self._accessory.put_characteristics(payload)
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Return False.
|
||||
|
||||
Data update is triggered from HKDevice.
|
||||
"""
|
||||
return False
|
||||
|
||||
def setup(self):
|
||||
"""Configure an entity baed on its HomeKit characteristics metadata."""
|
||||
self.pollable_characteristics = []
|
||||
|
|
|
@ -35,6 +35,8 @@ HA_MODE_TO_HK = {
|
|||
class HomeKitHumidifier(HomeKitEntity, HumidifierEntity):
|
||||
"""Representation of a HomeKit Controller Humidifier."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_HUMIDIFIER
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity cares about."""
|
||||
return [
|
||||
|
@ -45,11 +47,6 @@ class HomeKitHumidifier(HomeKitEntity, HumidifierEntity):
|
|||
CharacteristicsTypes.RELATIVE_HUMIDITY_HUMIDIFIER_THRESHOLD,
|
||||
]
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return the device class of the device."""
|
||||
return DEVICE_CLASS_HUMIDIFIER
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
|
@ -140,6 +137,8 @@ class HomeKitHumidifier(HomeKitEntity, HumidifierEntity):
|
|||
class HomeKitDehumidifier(HomeKitEntity, HumidifierEntity):
|
||||
"""Representation of a HomeKit Controller Humidifier."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_DEHUMIDIFIER
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity cares about."""
|
||||
return [
|
||||
|
@ -151,11 +150,6 @@ class HomeKitDehumidifier(HomeKitEntity, HumidifierEntity):
|
|||
CharacteristicsTypes.RELATIVE_HUMIDITY_DEHUMIDIFIER_THRESHOLD,
|
||||
]
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return the device class of the device."""
|
||||
return DEVICE_CLASS_DEHUMIDIFIER
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
|
|
|
@ -57,6 +57,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
class HomeKitTelevision(HomeKitEntity, MediaPlayerEntity):
|
||||
"""Representation of a HomeKit Controller Television."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_TV
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity cares about."""
|
||||
return [
|
||||
|
@ -70,11 +72,6 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerEntity):
|
|||
CharacteristicsTypes.IDENTIFIER,
|
||||
]
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Define the device class for a HomeKit enabled TV."""
|
||||
return DEVICE_CLASS_TV
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue