From 8b243dbb9f27c0a10b686365a8296d46b191f46f Mon Sep 17 00:00:00 2001 From: David Knowles Date: Sun, 1 Dec 2024 17:44:57 +0000 Subject: [PATCH] Pass an app_id to the Hydrawise API --- homeassistant/components/hydrawise/__init__.py | 5 +++-- homeassistant/components/hydrawise/config_flow.py | 4 ++-- homeassistant/components/hydrawise/const.py | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/hydrawise/__init__.py b/homeassistant/components/hydrawise/__init__.py index 9e402cd49326c..ea5a5801e69e5 100644 --- a/homeassistant/components/hydrawise/__init__.py +++ b/homeassistant/components/hydrawise/__init__.py @@ -7,7 +7,7 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed -from .const import DOMAIN +from .const import APP_ID, DOMAIN from .coordinator import ( HydrawiseMainDataUpdateCoordinator, HydrawiseUpdateCoordinators, @@ -30,7 +30,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b raise ConfigEntryAuthFailed hydrawise = client.Hydrawise( - auth.Auth(config_entry.data[CONF_USERNAME], config_entry.data[CONF_PASSWORD]) + auth.Auth(config_entry.data[CONF_USERNAME], config_entry.data[CONF_PASSWORD]), + app_id=APP_ID, ) main_coordinator = HydrawiseMainDataUpdateCoordinator(hass, hydrawise) diff --git a/homeassistant/components/hydrawise/config_flow.py b/homeassistant/components/hydrawise/config_flow.py index 242763e81e3b7..ec3840b3a21bb 100644 --- a/homeassistant/components/hydrawise/config_flow.py +++ b/homeassistant/components/hydrawise/config_flow.py @@ -13,7 +13,7 @@ from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_PASSWORD, CONF_USERNAME -from .const import DOMAIN, LOGGER +from .const import APP_ID, DOMAIN, LOGGER class HydrawiseConfigFlow(ConfigFlow, domain=DOMAIN): @@ -31,7 +31,7 @@ async def _create_or_update_entry( """Create the config entry.""" # Verify that the provided credentials work.""" - api = client.Hydrawise(auth.Auth(username, password)) + api = client.Hydrawise(auth.Auth(username, password), app_id=APP_ID) try: # Don't fetch zones because we don't need them yet. user = await api.get_user(fetch_zones=False) diff --git a/homeassistant/components/hydrawise/const.py b/homeassistant/components/hydrawise/const.py index 6d846dd612702..beaf450a5867d 100644 --- a/homeassistant/components/hydrawise/const.py +++ b/homeassistant/components/hydrawise/const.py @@ -3,8 +3,12 @@ from datetime import timedelta import logging +from homeassistant.const import __version__ as HA_VERSION + LOGGER = logging.getLogger(__package__) +APP_ID = f"homeassistant-{HA_VERSION}" + DOMAIN = "hydrawise" DEFAULT_WATERING_TIME = timedelta(minutes=15)