From f0b38757a9264c6733904bc6e4dc735fe9bb4556 Mon Sep 17 00:00:00 2001 From: AmadeoAlex <68441479+amadeo-alex@users.noreply.github.com> Date: Thu, 18 Sep 2025 22:20:16 +0200 Subject: [PATCH 1/2] removed requirement for MQTT integration to be configured --- custom_components/hass_agent/__init__.py | 37 +++--------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 973bc7c..50de5e7 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -49,35 +49,6 @@ async def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device sw_version=new_device_info["device"]["sw_version"], ) -async def async_wait_for_mqtt_client(hass: HomeAssistant) -> bool: - """Wait for the MQTT client to become available. - Waits when mqtt set up is in progress, - It is not needed that the client is connected. - Returns True if the mqtt client is available. - Returns False when the client is not available. - """ - if not mqtt_config_entry_enabled(hass): - return False - - entry = hass.config_entries.async_entries(DOMAIN)[0] - if entry.state == ConfigEntryState.LOADED: - return True - - state_reached_future: asyncio.Future[bool] - if DATA_MQTT_AVAILABLE not in hass.data: - hass.data[DATA_MQTT_AVAILABLE] = state_reached_future = asyncio.Future() - else: - state_reached_future = hass.data[DATA_MQTT_AVAILABLE] - if state_reached_future.done(): - return state_reached_future.result() - - try: - async with async_timeout.timeout(AVAILABILITY_TIMEOUT): - # Await the client setup or an error state was received - return await state_reached_future - except asyncio.TimeoutError: - return False - async def handle_apis_changed(hass: HomeAssistant, entry: ConfigEntry, apis): _logger.debug("api changed for: %s", entry.unique_id) if apis is not None: @@ -253,10 +224,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.http.register_view(MediaPlayerThumbnailView(hass)) # Make sure MQTT integration is enabled and the client is available - if not await mqtt.async_wait_for_mqtt_client(hass): - _logger.error("MQTT integration is not available") - return False - + # if not await mqtt.async_wait_for_mqtt_client(hass): + # _logger.error("MQTT integration is not available") + # return False + # async def _handle_reload(service): # """Handle reload service call.""" # _logger.info("Service %s.reload called: reloading integration", DOMAIN) From 9b38eb97d7b798fc418abbddb0d45ef615111504 Mon Sep 17 00:00:00 2001 From: AmadeoAlex <68441479+amadeo-alex@users.noreply.github.com> Date: Thu, 18 Sep 2025 22:22:45 +0200 Subject: [PATCH 2/2] removed commented out code --- custom_components/hass_agent/__init__.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 50de5e7..b95616f 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -223,28 +223,4 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.http.register_view(MediaPlayerThumbnailView(hass)) - # Make sure MQTT integration is enabled and the client is available - # if not await mqtt.async_wait_for_mqtt_client(hass): - # _logger.error("MQTT integration is not available") - # return False - - # async def _handle_reload(service): - # """Handle reload service call.""" - # _logger.info("Service %s.reload called: reloading integration", DOMAIN) - - # current_entries = hass.config_entries.async_entries(DOMAIN) - - # reload_tasks = [ - # hass.config_entries.async_reload(entry.entry_id) - # for entry in current_entries - # ] - - # await asyncio.gather(*reload_tasks) - - # hass.services.async_register( - # DOMAIN, - # SERVICE_RELOAD, - # _handle_reload, - # ) - return True