Add an RSSI sensor to the LIFX integration (#80993)
This commit is contained in:
parent
0d4b1866a7
commit
dde763418a
12 changed files with 393 additions and 74 deletions
|
@ -12,8 +12,8 @@ from homeassistant.helpers.entity import EntityCategory
|
|||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, IDENTIFY, RESTART
|
||||
from .coordinator import LIFXUpdateCoordinator
|
||||
from .entity import LIFXEntity
|
||||
from .coordinator import LIFXSensorUpdateCoordinator, LIFXUpdateCoordinator
|
||||
from .entity import LIFXSensorEntity
|
||||
|
||||
RESTART_BUTTON_DESCRIPTION = ButtonEntityDescription(
|
||||
key=RESTART,
|
||||
|
@ -38,20 +38,22 @@ async def async_setup_entry(
|
|||
domain_data = hass.data[DOMAIN]
|
||||
coordinator: LIFXUpdateCoordinator = domain_data[entry.entry_id]
|
||||
async_add_entities(
|
||||
cls(coordinator) for cls in (LIFXRestartButton, LIFXIdentifyButton)
|
||||
cls(coordinator.sensor_coordinator)
|
||||
for cls in (LIFXRestartButton, LIFXIdentifyButton)
|
||||
)
|
||||
|
||||
|
||||
class LIFXButton(LIFXEntity, ButtonEntity):
|
||||
class LIFXButton(LIFXSensorEntity, ButtonEntity):
|
||||
"""Base LIFX button."""
|
||||
|
||||
_attr_has_entity_name: bool = True
|
||||
_attr_should_poll: bool = False
|
||||
|
||||
def __init__(self, coordinator: LIFXUpdateCoordinator) -> None:
|
||||
def __init__(self, coordinator: LIFXSensorUpdateCoordinator) -> None:
|
||||
"""Initialise a LIFX button."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.serial_number}_{self.entity_description.key}"
|
||||
f"{coordinator.parent.serial_number}_{self.entity_description.key}"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue