From dfa2c218e4afdf21ae332b67df1c77caff9ca507 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sat, 8 Feb 2025 22:00:36 +0100 Subject: [PATCH] Explicitly pass in the config_entry in verisure coordinator (#137879) explicitly pass in the config_entry in coordinator --- .../components/verisure/alarm_control_panel.py | 4 ++-- homeassistant/components/verisure/binary_sensor.py | 6 +++--- homeassistant/components/verisure/camera.py | 2 +- homeassistant/components/verisure/coordinator.py | 11 ++++++++--- homeassistant/components/verisure/lock.py | 4 ++-- homeassistant/components/verisure/sensor.py | 4 ++-- homeassistant/components/verisure/switch.py | 2 +- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index 5f34b587163..2b9ae7b60b6 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -49,14 +49,14 @@ class VerisureAlarm( name="Verisure Alarm", manufacturer="Verisure", model="VBox", - identifiers={(DOMAIN, self.coordinator.entry.data[CONF_GIID])}, + identifiers={(DOMAIN, self.coordinator.config_entry.data[CONF_GIID])}, configuration_url="https://mypages.verisure.com", ) @property def unique_id(self) -> str: """Return the unique ID for this entity.""" - return self.coordinator.entry.data[CONF_GIID] + return self.coordinator.config_entry.data[CONF_GIID] async def _async_set_arm_state( self, state: str, command_data: dict[str, str | dict[str, str]] diff --git a/homeassistant/components/verisure/binary_sensor.py b/homeassistant/components/verisure/binary_sensor.py index 542ee3485ce..94a44550d47 100644 --- a/homeassistant/components/verisure/binary_sensor.py +++ b/homeassistant/components/verisure/binary_sensor.py @@ -62,7 +62,7 @@ class VerisureDoorWindowSensor( manufacturer="Verisure", model="Shock Sensor Detector", identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", ) @@ -104,7 +104,7 @@ class VerisureEthernetStatus( @property def unique_id(self) -> str: """Return the unique ID for this entity.""" - return f"{self.coordinator.entry.data[CONF_GIID]}_ethernet" + return f"{self.coordinator.config_entry.data[CONF_GIID]}_ethernet" @property def device_info(self) -> DeviceInfo: @@ -113,7 +113,7 @@ class VerisureEthernetStatus( name="Verisure Alarm", manufacturer="Verisure", model="VBox", - identifiers={(DOMAIN, self.coordinator.entry.data[CONF_GIID])}, + identifiers={(DOMAIN, self.coordinator.config_entry.data[CONF_GIID])}, configuration_url="https://mypages.verisure.com", ) diff --git a/homeassistant/components/verisure/camera.py b/homeassistant/components/verisure/camera.py index 70cd436d24c..7f49f917d83 100644 --- a/homeassistant/components/verisure/camera.py +++ b/homeassistant/components/verisure/camera.py @@ -75,7 +75,7 @@ class VerisureSmartcam(CoordinatorEntity[VerisureDataUpdateCoordinator], Camera) manufacturer="Verisure", model="SmartCam", identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", ) diff --git a/homeassistant/components/verisure/coordinator.py b/homeassistant/components/verisure/coordinator.py index 930d862257b..5165ddc6d3d 100644 --- a/homeassistant/components/verisure/coordinator.py +++ b/homeassistant/components/verisure/coordinator.py @@ -25,10 +25,11 @@ from .const import CONF_GIID, DEFAULT_SCAN_INTERVAL, DOMAIN, LOGGER class VerisureDataUpdateCoordinator(DataUpdateCoordinator): """A Verisure Data Update Coordinator.""" + config_entry: ConfigEntry + def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: """Initialize the Verisure hub.""" self.imageseries: list[dict[str, str]] = [] - self.entry = entry self._overview: list[dict] = [] self.verisure = Verisure( @@ -40,7 +41,11 @@ class VerisureDataUpdateCoordinator(DataUpdateCoordinator): ) super().__init__( - hass, LOGGER, name=DOMAIN, update_interval=DEFAULT_SCAN_INTERVAL + hass, + LOGGER, + config_entry=entry, + name=DOMAIN, + update_interval=DEFAULT_SCAN_INTERVAL, ) async def async_login(self) -> bool: @@ -55,7 +60,7 @@ class VerisureDataUpdateCoordinator(DataUpdateCoordinator): return False await self.hass.async_add_executor_job( - self.verisure.set_giid, self.entry.data[CONF_GIID] + self.verisure.set_giid, self.config_entry.data[CONF_GIID] ) return True diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index 87f5c53880e..16c69ecf2e2 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -81,7 +81,7 @@ class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEnt manufacturer="Verisure", model="Lockguard Smartlock", identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", ) @@ -109,7 +109,7 @@ class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEnt @property def code_format(self) -> str: """Return the configured code format.""" - digits = self.coordinator.entry.options.get( + digits = self.coordinator.config_entry.options.get( CONF_LOCK_CODE_DIGITS, DEFAULT_LOCK_CODE_DIGITS ) return f"^\\d{{{digits}}}$" diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 4f6e6b3d3c5..77a576caad8 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -72,7 +72,7 @@ class VerisureThermometer( manufacturer="Verisure", model=DEVICE_TYPE_NAME.get(device_type, device_type), identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", ) @@ -122,7 +122,7 @@ class VerisureHygrometer( manufacturer="Verisure", model=DEVICE_TYPE_NAME.get(device_type, device_type), identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", ) diff --git a/homeassistant/components/verisure/switch.py b/homeassistant/components/verisure/switch.py index e0238097e01..838e0222087 100644 --- a/homeassistant/components/verisure/switch.py +++ b/homeassistant/components/verisure/switch.py @@ -57,7 +57,7 @@ class VerisureSmartplug(CoordinatorEntity[VerisureDataUpdateCoordinator], Switch manufacturer="Verisure", model="SmartPlug", identifiers={(DOMAIN, self.serial_number)}, - via_device=(DOMAIN, self.coordinator.entry.data[CONF_GIID]), + via_device=(DOMAIN, self.coordinator.config_entry.data[CONF_GIID]), configuration_url="https://mypages.verisure.com", )