Explicitly pass in the config_entry in smarty coordinator (#137944)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-08 21:39:15 +01:00 committed by GitHub
parent 13dbeed5c2
commit b512838d1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -89,7 +89,7 @@ async def _async_import(hass: HomeAssistant, config: ConfigType) -> None:
async def async_setup_entry(hass: HomeAssistant, entry: SmartyConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: SmartyConfigEntry) -> bool:
"""Set up the Smarty environment from a config entry.""" """Set up the Smarty environment from a config entry."""
coordinator = SmartyCoordinator(hass) coordinator = SmartyCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()

View File

@ -22,15 +22,16 @@ class SmartyCoordinator(DataUpdateCoordinator[None]):
software_version: str software_version: str
configuration_version: str configuration_version: str
def __init__(self, hass: HomeAssistant) -> None: def __init__(self, hass: HomeAssistant, config_entry: SmartyConfigEntry) -> None:
"""Initialize.""" """Initialize."""
super().__init__( super().__init__(
hass, hass,
logger=_LOGGER, logger=_LOGGER,
config_entry=config_entry,
name="Smarty", name="Smarty",
update_interval=timedelta(seconds=30), update_interval=timedelta(seconds=30),
) )
self.client = Smarty(host=self.config_entry.data[CONF_HOST]) self.client = Smarty(host=config_entry.data[CONF_HOST])
async def _async_setup(self) -> None: async def _async_setup(self) -> None:
if not await self.hass.async_add_executor_job(self.client.update): if not await self.hass.async_add_executor_job(self.client.update):