diff --git a/homeassistant/components/triggercmd/__init__.py b/homeassistant/components/triggercmd/__init__.py index f58b2b481d4..3c1a2c855d0 100644 --- a/homeassistant/components/triggercmd/__init__.py +++ b/homeassistant/components/triggercmd/__init__.py @@ -8,6 +8,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.helpers import httpx_client from .const import CONF_TOKEN @@ -20,9 +21,12 @@ type TriggercmdConfigEntry = ConfigEntry[ha.Hub] async def async_setup_entry(hass: HomeAssistant, entry: TriggercmdConfigEntry) -> bool: """Set up TRIGGERcmd from a config entry.""" + hass_client = httpx_client.get_async_client(hass) hub = ha.Hub(entry.data[CONF_TOKEN]) - - status_code = await client.async_connection_test(entry.data[CONF_TOKEN]) + await hub.async_init(hass_client) + status_code = await client.async_connection_test( + entry.data[CONF_TOKEN], hass_client + ) if status_code != 200: raise ConfigEntryNotReady diff --git a/homeassistant/components/triggercmd/config_flow.py b/homeassistant/components/triggercmd/config_flow.py index 48c4eacfd5a..e796e836abf 100644 --- a/homeassistant/components/triggercmd/config_flow.py +++ b/homeassistant/components/triggercmd/config_flow.py @@ -12,6 +12,7 @@ import voluptuous as vol from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError +from homeassistant.helpers import httpx_client from .const import CONF_TOKEN, DOMAIN @@ -32,8 +33,9 @@ async def validate_input(hass: HomeAssistant, data: dict) -> str: if not token_data["id"]: raise InvalidToken + hass_client = httpx_client.get_async_client(hass) try: - await client.async_connection_test(data[CONF_TOKEN]) + await client.async_connection_test(data[CONF_TOKEN], hass_client) except Exception as e: raise TRIGGERcmdConnectionError from e else: diff --git a/homeassistant/components/triggercmd/manifest.json b/homeassistant/components/triggercmd/manifest.json index a0ee4eaf63e..1083c82e5be 100644 --- a/homeassistant/components/triggercmd/manifest.json +++ b/homeassistant/components/triggercmd/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/triggercmd", "integration_type": "hub", "iot_class": "cloud_polling", - "requirements": ["triggercmd==0.0.27"] + "requirements": ["triggercmd==0.0.36"] } diff --git a/homeassistant/components/triggercmd/switch.py b/homeassistant/components/triggercmd/switch.py index e03ff333751..ae7b0d4beec 100644 --- a/homeassistant/components/triggercmd/switch.py +++ b/homeassistant/components/triggercmd/switch.py @@ -82,5 +82,6 @@ class TRIGGERcmdSwitch(SwitchEntity): "params": params, "sender": "Home Assistant", }, + self._switch.hub.httpx_client, ) _LOGGER.debug("TRIGGERcmd trigger response: %s", r.json()) diff --git a/requirements_all.txt b/requirements_all.txt index cb2da54b814..1b2e97a9a5b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2978,7 +2978,7 @@ tplink-omada-client==1.4.4 transmission-rpc==7.0.3 # homeassistant.components.triggercmd -triggercmd==0.0.27 +triggercmd==0.0.36 # homeassistant.components.twinkly ttls==1.8.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 6c5bb5e37ec..d6274305e26 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2452,7 +2452,7 @@ tplink-omada-client==1.4.4 transmission-rpc==7.0.3 # homeassistant.components.triggercmd -triggercmd==0.0.27 +triggercmd==0.0.36 # homeassistant.components.twinkly ttls==1.8.3