From ec5765cb4ea2ab69eb01cd11abf57cdc1ba14a0f Mon Sep 17 00:00:00 2001 From: Milkysunshine <78696021+Milkysunshine@users.noreply.github.com> Date: Thu, 8 May 2025 13:33:01 -0400 Subject: [PATCH 1/3] Update smartapp.py Fix for 2025.5 breaking changes --- custom_components/smartthings/smartapp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/smartthings/smartapp.py b/custom_components/smartthings/smartapp.py index 8aab27a..2cfba0d 100644 --- a/custom_components/smartthings/smartapp.py +++ b/custom_components/smartthings/smartapp.py @@ -22,7 +22,7 @@ SubscriptionEntity, ) -from homeassistant.components import webhook +from homeassistant.components import webhook, cloud from homeassistant.const import CONF_WEBHOOK_ID from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -30,6 +30,7 @@ async_dispatcher_connect, async_dispatcher_send, ) +from homeassistant.helpers.storage import Store from homeassistant.helpers.network import NoURLAvailableError, get_url from .const import ( @@ -93,7 +94,7 @@ async def validate_installed_app(api, installed_app_id: str): def validate_webhook_requirements(hass: HomeAssistant) -> bool: """Ensure Home Assistant is setup properly to receive webhooks.""" - if hass.components.cloud.async_active_subscription(): + if cloud.async_active_subscription(hass): return True if hass.data[DOMAIN][CONF_CLOUDHOOK_URL] is not None: return True @@ -209,7 +210,7 @@ async def setup_smartapp_endpoint(hass: HomeAssistant): return # Get/create config to store a unique id for this hass instance. - store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY) + store = Store(hass, STORAGE_VERSION, STORAGE_KEY) config = await store.async_load() if not config: # Create config From a21637dd2581465169d363462b69397edae44b87 Mon Sep 17 00:00:00 2001 From: Milkysunshine <78696021+Milkysunshine@users.noreply.github.com> Date: Thu, 15 May 2025 13:54:49 -0400 Subject: [PATCH 2/3] Update smartapp.py --- custom_components/smartthings/smartapp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/smartthings/smartapp.py b/custom_components/smartthings/smartapp.py index 2cfba0d..fc410fd 100644 --- a/custom_components/smartthings/smartapp.py +++ b/custom_components/smartthings/smartapp.py @@ -108,7 +108,7 @@ def get_webhook_url(hass: HomeAssistant) -> str: Return the cloudhook if available, otherwise local webhook. """ cloudhook_url = hass.data[DOMAIN][CONF_CLOUDHOOK_URL] - if hass.components.cloud.async_active_subscription() and cloudhook_url is not None: + if cloud.async_active_subscription(hass) and cloudhook_url is not None: return cloudhook_url return webhook.async_generate_url(hass, hass.data[DOMAIN][CONF_WEBHOOK_ID]) @@ -230,10 +230,10 @@ async def setup_smartapp_endpoint(hass: HomeAssistant): cloudhook_url = config.get(CONF_CLOUDHOOK_URL) if ( cloudhook_url is None - and hass.components.cloud.async_active_subscription() + and cloud.async_active_subscription(hass) and not hass.config_entries.async_entries(DOMAIN) ): - cloudhook_url = await hass.components.cloud.async_create_cloudhook( + cloudhook_url = await cloud.async_create_cloudhook( config[CONF_WEBHOOK_ID] ) config[CONF_CLOUDHOOK_URL] = cloudhook_url @@ -280,8 +280,8 @@ async def unload_smartapp_endpoint(hass: HomeAssistant): return # Remove the cloudhook if it was created cloudhook_url = hass.data[DOMAIN][CONF_CLOUDHOOK_URL] - if cloudhook_url and hass.components.cloud.async_is_logged_in(): - await hass.components.cloud.async_delete_cloudhook( + if cloudhook_url and cloud.async_is_logged_in(): + await cloud.async_delete_cloudhook( hass.data[DOMAIN][CONF_WEBHOOK_ID] ) # Remove cloudhook from storage From f7a3ed69ead03bc7dc2bf6f363099251e9ca444c Mon Sep 17 00:00:00 2001 From: Milkysunshine <78696021+Milkysunshine@users.noreply.github.com> Date: Thu, 15 May 2025 14:14:31 -0400 Subject: [PATCH 3/3] Update smartapp.py --- custom_components/smartthings/smartapp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/smartthings/smartapp.py b/custom_components/smartthings/smartapp.py index fc410fd..ca62a87 100644 --- a/custom_components/smartthings/smartapp.py +++ b/custom_components/smartthings/smartapp.py @@ -234,7 +234,7 @@ async def setup_smartapp_endpoint(hass: HomeAssistant): and not hass.config_entries.async_entries(DOMAIN) ): cloudhook_url = await cloud.async_create_cloudhook( - config[CONF_WEBHOOK_ID] + hass, config[CONF_WEBHOOK_ID] ) config[CONF_CLOUDHOOK_URL] = cloudhook_url await store.async_save(config) @@ -280,9 +280,9 @@ async def unload_smartapp_endpoint(hass: HomeAssistant): return # Remove the cloudhook if it was created cloudhook_url = hass.data[DOMAIN][CONF_CLOUDHOOK_URL] - if cloudhook_url and cloud.async_is_logged_in(): + if cloudhook_url and cloud.async_is_logged_in(hass): await cloud.async_delete_cloudhook( - hass.data[DOMAIN][CONF_WEBHOOK_ID] + hass, hass.data[DOMAIN][CONF_WEBHOOK_ID] ) # Remove cloudhook from storage store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)