mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Pass requestor_uuid to bond API calls (#144128)
This commit is contained in:
parent
a6131b3ebf
commit
a15a3c12d5
@ -5,7 +5,7 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import ClientError, ClientResponseError, ClientTimeout
|
from aiohttp import ClientError, ClientResponseError, ClientTimeout
|
||||||
from bond_async import Bond, BPUPSubscriptions, start_bpup
|
from bond_async import Bond, BPUPSubscriptions, RequestorUUID, start_bpup
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -49,6 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: BondConfigEntry) -> bool
|
|||||||
token=token,
|
token=token,
|
||||||
timeout=ClientTimeout(total=_API_TIMEOUT),
|
timeout=ClientTimeout(total=_API_TIMEOUT),
|
||||||
session=async_get_clientsession(hass),
|
session=async_get_clientsession(hass),
|
||||||
|
requestor_uuid=RequestorUUID.HOME_ASSISTANT,
|
||||||
)
|
)
|
||||||
hub = BondHub(bond, host)
|
hub = BondHub(bond, host)
|
||||||
try:
|
try:
|
||||||
|
@ -8,7 +8,7 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import ClientConnectionError, ClientResponseError
|
from aiohttp import ClientConnectionError, ClientResponseError
|
||||||
from bond_async import Bond
|
from bond_async import Bond, RequestorUUID
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigEntryState, ConfigFlow, ConfigFlowResult
|
||||||
@ -34,7 +34,12 @@ TOKEN_SCHEMA = vol.Schema({})
|
|||||||
|
|
||||||
async def async_get_token(hass: HomeAssistant, host: str) -> str | None:
|
async def async_get_token(hass: HomeAssistant, host: str) -> str | None:
|
||||||
"""Try to fetch the token from the bond device."""
|
"""Try to fetch the token from the bond device."""
|
||||||
bond = Bond(host, "", session=async_get_clientsession(hass))
|
bond = Bond(
|
||||||
|
host,
|
||||||
|
"",
|
||||||
|
session=async_get_clientsession(hass),
|
||||||
|
requestor_uuid=RequestorUUID.HOME_ASSISTANT,
|
||||||
|
)
|
||||||
response: dict[str, str] = {}
|
response: dict[str, str] = {}
|
||||||
with contextlib.suppress(ClientConnectionError):
|
with contextlib.suppress(ClientConnectionError):
|
||||||
response = await bond.token()
|
response = await bond.token()
|
||||||
@ -45,7 +50,10 @@ async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[st
|
|||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
bond = Bond(
|
bond = Bond(
|
||||||
data[CONF_HOST], data[CONF_ACCESS_TOKEN], session=async_get_clientsession(hass)
|
data[CONF_HOST],
|
||||||
|
data[CONF_ACCESS_TOKEN],
|
||||||
|
session=async_get_clientsession(hass),
|
||||||
|
requestor_uuid=RequestorUUID.HOME_ASSISTANT,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
hub = BondHub(bond, data[CONF_HOST])
|
hub = BondHub(bond, data[CONF_HOST])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user