mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Use shared httpx client in gogogate2 (#45575)
This commit is contained in:
parent
7dec23d58b
commit
af832e5434
@ -179,7 +179,7 @@ homeassistant/components/gios/* @bieniu
|
||||
homeassistant/components/gitter/* @fabaff
|
||||
homeassistant/components/glances/* @fabaff @engrbm87
|
||||
homeassistant/components/goalzero/* @tkdrob
|
||||
homeassistant/components/gogogate2/* @vangorra
|
||||
homeassistant/components/gogogate2/* @vangorra @bdraco
|
||||
homeassistant/components/google_assistant/* @home-assistant/cloud
|
||||
homeassistant/components/google_cloud/* @lufton
|
||||
homeassistant/components/gpsd/* @fabaff
|
||||
|
@ -6,8 +6,8 @@ from datetime import timedelta
|
||||
import logging
|
||||
from typing import Callable, NamedTuple
|
||||
|
||||
from gogogate2_api import AbstractGateApi, GogoGate2Api, ISmartGateApi
|
||||
from gogogate2_api.common import AbstractDoor, get_door_by_id
|
||||
from ismartgate import AbstractGateApi, GogoGate2Api, ISmartGateApi
|
||||
from ismartgate.common import AbstractDoor, get_door_by_id
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -18,6 +18,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
@ -112,7 +113,7 @@ def get_data_update_coordinator(
|
||||
config_entry_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
if DATA_UPDATE_COORDINATOR not in config_entry_data:
|
||||
api = get_api(config_entry.data)
|
||||
api = get_api(hass, config_entry.data)
|
||||
|
||||
async def async_update_data():
|
||||
try:
|
||||
@ -148,7 +149,7 @@ def sensor_unique_id(
|
||||
return f"{config_entry.unique_id}_{door.door_id}_{sensor_type}"
|
||||
|
||||
|
||||
def get_api(config_data: dict) -> AbstractGateApi:
|
||||
def get_api(hass: HomeAssistant, config_data: dict) -> AbstractGateApi:
|
||||
"""Get an api object for config data."""
|
||||
gate_class = GogoGate2Api
|
||||
|
||||
@ -159,4 +160,5 @@ def get_api(config_data: dict) -> AbstractGateApi:
|
||||
config_data[CONF_IP_ADDRESS],
|
||||
config_data[CONF_USERNAME],
|
||||
config_data[CONF_PASSWORD],
|
||||
httpx_async_client=get_async_client(hass),
|
||||
)
|
||||
|
@ -2,8 +2,8 @@
|
||||
import dataclasses
|
||||
import re
|
||||
|
||||
from gogogate2_api.common import AbstractInfoResponse, ApiError
|
||||
from gogogate2_api.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode
|
||||
from ismartgate.common import AbstractInfoResponse, ApiError
|
||||
from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow
|
||||
@ -55,7 +55,7 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
errors = {}
|
||||
|
||||
if user_input:
|
||||
api = get_api(user_input)
|
||||
api = get_api(self.hass, user_input)
|
||||
try:
|
||||
data: AbstractInfoResponse = await api.async_info()
|
||||
data_dict = dataclasses.asdict(data)
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from gogogate2_api.common import AbstractDoor, DoorStatus, get_configured_doors
|
||||
from ismartgate.common import AbstractDoor, DoorStatus, get_configured_doors
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
DEVICE_CLASS_GARAGE,
|
||||
|
@ -3,8 +3,8 @@
|
||||
"name": "Gogogate2 and iSmartGate",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/gogogate2",
|
||||
"requirements": ["gogogate2-api==3.0.0"],
|
||||
"codeowners": ["@vangorra"],
|
||||
"requirements": ["ismartgate==4.0.0"],
|
||||
"codeowners": ["@vangorra", "@bdraco"],
|
||||
"homekit": {
|
||||
"models": ["iSmartGate"]
|
||||
},
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from itertools import chain
|
||||
|
||||
from gogogate2_api.common import AbstractDoor, get_configured_doors
|
||||
from ismartgate.common import AbstractDoor, get_configured_doors
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -671,9 +671,6 @@ gntp==1.0.3
|
||||
# homeassistant.components.goalzero
|
||||
goalzero==0.1.7
|
||||
|
||||
# homeassistant.components.gogogate2
|
||||
gogogate2-api==3.0.0
|
||||
|
||||
# homeassistant.components.google
|
||||
google-api-python-client==1.6.4
|
||||
|
||||
@ -833,6 +830,9 @@ influxdb==5.2.3
|
||||
# homeassistant.components.iperf3
|
||||
iperf3==0.1.11
|
||||
|
||||
# homeassistant.components.gogogate2
|
||||
ismartgate==4.0.0
|
||||
|
||||
# homeassistant.components.rest
|
||||
jsonpath==0.82
|
||||
|
||||
|
@ -368,9 +368,6 @@ glances_api==0.2.0
|
||||
# homeassistant.components.goalzero
|
||||
goalzero==0.1.7
|
||||
|
||||
# homeassistant.components.gogogate2
|
||||
gogogate2-api==3.0.0
|
||||
|
||||
# homeassistant.components.google
|
||||
google-api-python-client==1.6.4
|
||||
|
||||
@ -462,6 +459,9 @@ influxdb-client==1.14.0
|
||||
# homeassistant.components.influxdb
|
||||
influxdb==5.2.3
|
||||
|
||||
# homeassistant.components.gogogate2
|
||||
ismartgate==4.0.0
|
||||
|
||||
# homeassistant.components.rest
|
||||
jsonpath==0.82
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
"""Tests for the GogoGate2 component."""
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from gogogate2_api import GogoGate2Api
|
||||
from gogogate2_api.common import ApiError
|
||||
from gogogate2_api.const import GogoGate2ApiErrorCode
|
||||
from ismartgate import GogoGate2Api
|
||||
from ismartgate.common import ApiError
|
||||
from ismartgate.const import GogoGate2ApiErrorCode
|
||||
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components.gogogate2.const import (
|
||||
|
@ -2,8 +2,8 @@
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from gogogate2_api import GogoGate2Api, ISmartGateApi
|
||||
from gogogate2_api.common import (
|
||||
from ismartgate import GogoGate2Api, ISmartGateApi
|
||||
from ismartgate.common import (
|
||||
ApiError,
|
||||
DoorMode,
|
||||
DoorStatus,
|
||||
|
@ -2,7 +2,7 @@
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from gogogate2_api import GogoGate2Api
|
||||
from ismartgate import GogoGate2Api
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.gogogate2 import DEVICE_TYPE_GOGOGATE2, async_setup_entry
|
||||
|
@ -2,8 +2,8 @@
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from gogogate2_api import GogoGate2Api, ISmartGateApi
|
||||
from gogogate2_api.common import (
|
||||
from ismartgate import GogoGate2Api, ISmartGateApi
|
||||
from ismartgate.common import (
|
||||
DoorMode,
|
||||
DoorStatus,
|
||||
GogoGate2ActivateResponse,
|
||||
|
Loading…
x
Reference in New Issue
Block a user