Use built in config entry from coordinator in HomeWizard (#102959)

This commit is contained in:
Joost Lekkerkerker 2023-10-29 18:23:48 +01:00 committed by GitHub
parent 94e192db12
commit b7667d44fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 32 deletions

View file

@ -21,7 +21,7 @@ async def async_setup_entry(
"""Set up numbers for device."""
coordinator: HWEnergyDeviceUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
if coordinator.supports_state():
async_add_entities([HWEnergyNumberEntity(coordinator, entry)])
async_add_entities([HWEnergyNumberEntity(coordinator)])
class HWEnergyNumberEntity(HomeWizardEntity, NumberEntity):
@ -35,11 +35,12 @@ class HWEnergyNumberEntity(HomeWizardEntity, NumberEntity):
def __init__(
self,
coordinator: HWEnergyDeviceUpdateCoordinator,
entry: ConfigEntry,
) -> None:
"""Initialize the control number."""
super().__init__(coordinator)
self._attr_unique_id = f"{entry.unique_id}_status_light_brightness"
self._attr_unique_id = (
f"{coordinator.config_entry.unique_id}_status_light_brightness"
)
@homewizard_exception_handler
async def async_set_native_value(self, value: float) -> None: