Skip to content

Commit 8faeb1f

Browse files
authored
Avoid blocking IO in TRIGGERcmd (#151396)
1 parent edc48e0 commit 8faeb1f

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

homeassistant/components/triggercmd/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from homeassistant.const import Platform
99
from homeassistant.core import HomeAssistant
1010
from homeassistant.exceptions import ConfigEntryNotReady
11+
from homeassistant.helpers import httpx_client
1112

1213
from .const import CONF_TOKEN
1314

@@ -20,9 +21,12 @@
2021

2122
async def async_setup_entry(hass: HomeAssistant, entry: TriggercmdConfigEntry) -> bool:
2223
"""Set up TRIGGERcmd from a config entry."""
24+
hass_client = httpx_client.get_async_client(hass)
2325
hub = ha.Hub(entry.data[CONF_TOKEN])
24-
25-
status_code = await client.async_connection_test(entry.data[CONF_TOKEN])
26+
await hub.async_init(hass_client)
27+
status_code = await client.async_connection_test(
28+
entry.data[CONF_TOKEN], hass_client
29+
)
2630
if status_code != 200:
2731
raise ConfigEntryNotReady
2832

homeassistant/components/triggercmd/config_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
1313
from homeassistant.core import HomeAssistant
1414
from homeassistant.exceptions import HomeAssistantError
15+
from homeassistant.helpers import httpx_client
1516

1617
from .const import CONF_TOKEN, DOMAIN
1718

@@ -32,8 +33,9 @@ async def validate_input(hass: HomeAssistant, data: dict) -> str:
3233
if not token_data["id"]:
3334
raise InvalidToken
3435

36+
hass_client = httpx_client.get_async_client(hass)
3537
try:
36-
await client.async_connection_test(data[CONF_TOKEN])
38+
await client.async_connection_test(data[CONF_TOKEN], hass_client)
3739
except Exception as e:
3840
raise TRIGGERcmdConnectionError from e
3941
else:

homeassistant/components/triggercmd/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"documentation": "https://www.home-assistant.io/integrations/triggercmd",
77
"integration_type": "hub",
88
"iot_class": "cloud_polling",
9-
"requirements": ["triggercmd==0.0.27"]
9+
"requirements": ["triggercmd==0.0.36"]
1010
}

homeassistant/components/triggercmd/switch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ async def trigger(self, params: str):
8282
"params": params,
8383
"sender": "Home Assistant",
8484
},
85+
self._switch.hub.httpx_client,
8586
)
8687
_LOGGER.debug("TRIGGERcmd trigger response: %s", r.json())

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)