From dcea222fc9ab71eb4753daaebe79ba5d0e4d7da4 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:36:48 -0700 Subject: [PATCH 01/19] Update __init__.py --- custom_components/hass_agent/__init__.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 73f81c8..313293d 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -13,7 +13,13 @@ ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ID, CONF_NAME, CONF_URL, Platform +from homeassistant.const import ( + CONF_ID, + CONF_NAME, + CONF_URL, + Platform, + SERVICE_RELOAD, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery @@ -205,4 +211,18 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup(hass: HomeAssistant, config) -> bool: hass.http.register_view(MediaPlayerThumbnailView(hass)) + + 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) + return True From 1e883b8ede0f5862dee3d9eae0e6bded8835b392 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Thu, 28 Mar 2024 23:15:43 -0700 Subject: [PATCH 02/19] Update __init__.py Modify to add SERVICE_RELOAD --- custom_components/hass_agent/__init__.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 313293d..12388c3 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -5,6 +5,7 @@ import requests from .views import MediaPlayerThumbnailView from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.typing import ConfigType from homeassistant.components.mqtt.models import ReceiveMessage from homeassistant.components.mqtt.subscription import ( async_prepare_subscribe_topics, @@ -25,6 +26,10 @@ from .const import DOMAIN +DOMAIN = "hass_agent" + +FOLDER = "hass_agent" + PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] _logger = logging.getLogger(__name__) @@ -209,20 +214,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return unload_ok -async def async_setup(hass: HomeAssistant, config) -> bool: +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.http.register_view(MediaPlayerThumbnailView(hass)) - - 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.register(DOMAIN, SERVICE_RELOAD) return True From 03f45eb1adfc73d39bb52ea3479f8dff67379b0b Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:27:44 -0700 Subject: [PATCH 03/19] Update __init__.py Another try at async_setup... --- custom_components/hass_agent/__init__.py | 37 +++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 12388c3..5edcf3f 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -1,19 +1,25 @@ """The HASS.Agent integration.""" from __future__ import annotations + +import asyncio +from collections.abc import Coroutine +from contextlib import suppress import json import logging +from pathlib import Path import requests +from typing import Any, cast from .views import MediaPlayerThumbnailView -from homeassistant.helpers import device_registry as dr -from homeassistant.helpers.typing import ConfigType + +import voluptuous as vol + +from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.components.mqtt.models import ReceiveMessage from homeassistant.components.mqtt.subscription import ( async_prepare_subscribe_topics, async_subscribe_topics, async_unsubscribe_topics, ) - -from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_ID, CONF_NAME, @@ -21,20 +27,22 @@ Platform, SERVICE_RELOAD, ) -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, ServiceCall, async_get_hass +from homeassistant.helpers import device_registry as dr from homeassistant.helpers import discovery +from homeassistant.helpers.service import async_register_admin_service +from homeassistant.helpers.typing import ConfigType +from homeassistant.util import slugify from .const import DOMAIN DOMAIN = "hass_agent" - FOLDER = "hass_agent" PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] _logger = logging.getLogger(__name__) - def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info): device_registry = dr.async_get(hass) device_registry.async_get_or_create( @@ -46,7 +54,6 @@ def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info) sw_version=new_device_info["device"]["sw_version"], ) - async def handle_apis_changed(hass: HomeAssistant, entry: ConfigEntry, apis): if apis is not None: @@ -105,7 +112,6 @@ async def handle_apis_changed(hass: HomeAssistant, entry: ConfigEntry, apis): hass.data[DOMAIN][entry.entry_id]["loaded"]["notifications"] = False - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up HASS.Agent from a config entry.""" @@ -176,7 +182,6 @@ def updated(message: ReceiveMessage): return True - async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" @@ -213,9 +218,15 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return unload_ok - async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) - hass.services.register(DOMAIN, SERVICE_RELOAD) - + + async def reload_config(_: ServiceCall) -> None: + """Reload configuration.""" + await process_config(await async_integration_yaml_config(hass, DOMAIN)) + + await process_config(config) + async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, reload_config) + return True From 1068d304574054fcacfcb0d7ba48498d40601efc Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:41:20 -0700 Subject: [PATCH 04/19] Update __init__.py Removed await process_config(config) --- custom_components/hass_agent/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 5edcf3f..c83d41c 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -226,7 +226,6 @@ async def reload_config(_: ServiceCall) -> None: """Reload configuration.""" await process_config(await async_integration_yaml_config(hass, DOMAIN)) - await process_config(config) async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, reload_config) return True From 0a05843f97bb56a1bbaf06040df6e7e369da0b72 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:01:49 -0700 Subject: [PATCH 05/19] Update __init__.py reload_config not working --- custom_components/hass_agent/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index c83d41c..48c6e18 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -222,10 +222,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) - async def reload_config(_: ServiceCall) -> None: +# async def reload_config(_: ServiceCall) -> None: """Reload configuration.""" - await process_config(await async_integration_yaml_config(hass, DOMAIN)) +# await process_config(await async_integration_yaml_config(hass, DOMAIN)) - async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, reload_config) + async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD) return True From 8d112927def72c94835a655140d5db02d0d98434 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 13:56:48 -0700 Subject: [PATCH 06/19] Update __init__.py Another try... --- custom_components/hass_agent/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 48c6e18..ba93445 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -39,7 +39,7 @@ DOMAIN = "hass_agent" FOLDER = "hass_agent" -PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] +PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.] _logger = logging.getLogger(__name__) @@ -222,10 +222,19 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) -# async def reload_config(_: ServiceCall) -> None: + async def reload_config(_: ServiceCall) -> None: """Reload configuration.""" -# await process_config(await async_integration_yaml_config(hass, DOMAIN)) + _LOGGER.info("Service %s.reload called: reloading integration", DOMAIN) + current_entries = hass.config_entries.async_entries(DOMAIN) - async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD) + reload_tasks = [ + hass.config_entries.async_reload(entry.entry_id) + for entry in current_entries + ] + + await asyncio.gather(*reload_tasks) +# await process_config(await async_setup_entry(hass, DOMAIN)) + + async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, reload_config) return True From 9bf5dff18d2dc90ea48389b39da53adc2f22c164 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:18:35 -0700 Subject: [PATCH 07/19] Update __init__.py Another try... --- custom_components/hass_agent/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index ba93445..99457ad 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -233,8 +233,11 @@ async def reload_config(_: ServiceCall) -> None: ] await asyncio.gather(*reload_tasks) -# await process_config(await async_setup_entry(hass, DOMAIN)) - async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, reload_config) + hass.helpers.service.async_register_admin_service( + DOMAIN, + SERVICE_RELOAD, + _handle_reload, + ) return True From be6b22bc269b1f4fdc409e2fe2e14485fa6b7029 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:51:56 -0700 Subject: [PATCH 08/19] Update __init__.py Fixed typo in PLATFORMS: --- custom_components/hass_agent/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 99457ad..7d757da 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -39,7 +39,7 @@ DOMAIN = "hass_agent" FOLDER = "hass_agent" -PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.] +PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] _logger = logging.getLogger(__name__) From 4f4ac43946ab1c050bbc32e24cef4ab1d7c03c88 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:56:33 -0700 Subject: [PATCH 09/19] Update __init__.py Unexpected indent line 227: _LOGGER.info --- custom_components/hass_agent/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 7d757da..34573fc 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -224,7 +224,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def reload_config(_: ServiceCall) -> None: """Reload configuration.""" - _LOGGER.info("Service %s.reload called: reloading integration", DOMAIN) + _LOGGER.info("Service %s.reload called: reloading integration", DOMAIN) current_entries = hass.config_entries.async_entries(DOMAIN) reload_tasks = [ From 55f892c0bcb871040264f85fec912e2001a8cf49 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:08:02 -0700 Subject: [PATCH 10/19] Update __init__.py Added async def _handle_reload --- custom_components/hass_agent/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 34573fc..4a24291 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -222,9 +222,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) - async def reload_config(_: ServiceCall) -> None: - """Reload configuration.""" + 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 = [ From bf37d2b990329416d76b839935bcaddefbd14c20 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:13:07 -0700 Subject: [PATCH 11/19] Update __init__.py Changed _logger = logging.getLogger(__name__) to _LOGGER = logging.getLogger(__name__) --- custom_components/hass_agent/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 4a24291..9791dac 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -41,7 +41,7 @@ PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] -_logger = logging.getLogger(__name__) +_LOGGER = logging.getLogger(__name__) def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info): device_registry = dr.async_get(hass) From b92335ccec7c0769716a870233a709fa72d43a06 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:34:28 -0700 Subject: [PATCH 12/19] Update __init__.py Line 161 - Try: return requests.get(f"{url}/info", timeout=60) --- custom_components/hass_agent/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 9791dac..14b7824 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -132,7 +132,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if url is not None: def get_device_info(): - return requests.get(f"{url}/info", timeout=10) + return requests.get(f"{url}/info", timeout=60) response = await hass.async_add_executor_job(get_device_info) From 7288d4d455b471e12fffbd05c7d81adeb53196e9 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:24:07 -0700 Subject: [PATCH 13/19] Update __init__.py Line 42 - Try: PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.MQTT] --- custom_components/hass_agent/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 14b7824..9b31d62 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -39,7 +39,7 @@ DOMAIN = "hass_agent" FOLDER = "hass_agent" -PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] +PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.MQTT] _LOGGER = logging.getLogger(__name__) @@ -222,6 +222,16 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) + """Set up the MQTT state feed.""" + # Make sure MQTT is available and the entry is loaded +# if not hass.config_entries.async_entries( +# mqtt.DOMAIN +# ) or not await hass.config_entries.async_wait_component( +# hass.config_entries.async_entries(mqtt.DOMAIN)[0] +# ): +# _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 4565e6e734b47df8a797889372920b5d8c43174f Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:34:50 -0700 Subject: [PATCH 14/19] Update __init__.py Add async def async_wait_for_mqtt_client(hass: HomeAssistant) --- custom_components/hass_agent/__init__.py | 46 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 9b31d62..453dac5 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -39,7 +39,7 @@ DOMAIN = "hass_agent" FOLDER = "hass_agent" -PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.MQTT] +PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER] _LOGGER = logging.getLogger(__name__) @@ -54,6 +54,35 @@ def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info) 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): if apis is not None: @@ -222,16 +251,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up hass_agent integration.""" hass.http.register_view(MediaPlayerThumbnailView(hass)) - """Set up the MQTT state feed.""" - # Make sure MQTT is available and the entry is loaded -# if not hass.config_entries.async_entries( -# mqtt.DOMAIN -# ) or not await hass.config_entries.async_wait_component( -# hass.config_entries.async_entries(mqtt.DOMAIN)[0] -# ): -# _LOGGER.error("MQTT integration is not available") -# return False - + # 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) From c5e7095b7dfb42d4dcfe3812b6b8cec083bd15bb Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:51:28 -0700 Subject: [PATCH 15/19] Update __init__.py Line 17 - Try: from homeassistant.components import mqtt --- custom_components/hass_agent/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 453dac5..8e55d2e 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -11,9 +11,10 @@ from typing import Any, cast from .views import MediaPlayerThumbnailView -import voluptuous as vol +#import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.components import mqtt from homeassistant.components.mqtt.models import ReceiveMessage from homeassistant.components.mqtt.subscription import ( async_prepare_subscribe_topics, @@ -24,6 +25,8 @@ CONF_ID, CONF_NAME, CONF_URL, + DATA_MQTT, + DATA_MQTT_AVAILABLE, Platform, SERVICE_RELOAD, ) From cd33511c4a738ddd4c05e7ab3e8775727a1a5b4c Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:54:46 -0700 Subject: [PATCH 16/19] Update __init__.py ImportError: cannot import name 'DATA_MQTT' from 'homeassistant.const' --- custom_components/hass_agent/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 8e55d2e..b1e59bf 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -25,8 +25,8 @@ CONF_ID, CONF_NAME, CONF_URL, - DATA_MQTT, - DATA_MQTT_AVAILABLE, +# DATA_MQTT, +# DATA_MQTT_AVAILABLE, Platform, SERVICE_RELOAD, ) From 0eb00dc40d988a1dff88c11989e73a0b09377492 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:52:25 -0700 Subject: [PATCH 17/19] Update __init__.py - Added reload service - Make sure MQTT integration is enabled and the client is available --- custom_components/hass_agent/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index b1e59bf..4ccaf0f 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -11,8 +11,6 @@ from typing import Any, cast from .views import MediaPlayerThumbnailView -#import voluptuous as vol - from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.components import mqtt from homeassistant.components.mqtt.models import ReceiveMessage @@ -25,8 +23,6 @@ CONF_ID, CONF_NAME, CONF_URL, -# DATA_MQTT, -# DATA_MQTT_AVAILABLE, Platform, SERVICE_RELOAD, ) From 2a312b5dd68dbce2c2849967c7801ee72b752085 Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Thu, 9 May 2024 13:02:59 -0700 Subject: [PATCH 18/19] Update __init__.py Changed 'def' to 'async def' Changed 'update_device_info' to 'await update_device_info' --- custom_components/hass_agent/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/hass_agent/__init__.py b/custom_components/hass_agent/__init__.py index 4ccaf0f..917c56c 100644 --- a/custom_components/hass_agent/__init__.py +++ b/custom_components/hass_agent/__init__.py @@ -42,7 +42,7 @@ _LOGGER = logging.getLogger(__name__) -def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info): +async def update_device_info(hass: HomeAssistant, entry: ConfigEntry, new_device_info): device_registry = dr.async_get(hass) device_registry.async_get_or_create( config_entry_id=entry.entry_id, @@ -181,12 +181,12 @@ def get_device_info(): sub_state = hass.data[DOMAIN][entry.entry_id]["internal_mqtt"] - def updated(message: ReceiveMessage): + async def updated(message: ReceiveMessage): payload = json.loads(message.payload) cached = hass.data[DOMAIN][entry.entry_id]["apis"] apis = payload["apis"] - update_device_info(hass, entry, payload) + await update_device_info(hass, entry, payload) if cached != apis: hass.async_create_task(handle_apis_changed(hass, entry, apis)) From ed40f44201c687873e0c4afd0b3663910d87a6ab Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Thu, 9 May 2024 13:05:07 -0700 Subject: [PATCH 19/19] Update manifest.json Version 2024.5.0 --- custom_components/hass_agent/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hass_agent/manifest.json b/custom_components/hass_agent/manifest.json index 658fe62..d9054f1 100644 --- a/custom_components/hass_agent/manifest.json +++ b/custom_components/hass_agent/manifest.json @@ -1,7 +1,7 @@ { "domain": "hass_agent", "name": "HASS.Agent", - "version": "2022.11.9", + "version": "2024.5.0", "config_flow": true, "documentation": "https://github.com/LAB02-Research/HASS.Agent-Integration", "issue_tracker": "https://github.com/LAB02-Research/HASS.Agent-Integration/issues",