diff --git a/custom_components/tuya_openapi/__init__.py b/custom_components/tuya_openapi/__init__.py index 509e7e1..c0b207a 100644 --- a/custom_components/tuya_openapi/__init__.py +++ b/custom_components/tuya_openapi/__init__.py @@ -4,6 +4,14 @@ from typing import NamedTuple import requests +from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN +from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.helpers import device_registry as dr +from homeassistant.helpers import entity_registry as er +from homeassistant.helpers.dispatcher import dispatcher_send from tuya_iot import ( AuthType, TuyaDevice, @@ -14,14 +22,6 @@ TuyaOpenMQ, ) -from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN -from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant, callback -from homeassistant.exceptions import ConfigEntryNotReady -from homeassistant.helpers import device_registry as dr, entity_registry as er -from homeassistant.helpers.dispatcher import dispatcher_send - from .const import ( CONF_ACCESS_ID, CONF_ACCESS_SECRET, diff --git a/custom_components/tuya_openapi/alarm_control_panel.py b/custom_components/tuya_openapi/alarm_control_panel.py index cd92e62..5475870 100644 --- a/custom_components/tuya_openapi/alarm_control_panel.py +++ b/custom_components/tuya_openapi/alarm_control_panel.py @@ -3,8 +3,6 @@ from enum import StrEnum -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.alarm_control_panel import ( AlarmControlPanelEntity, AlarmControlPanelEntityDescription, @@ -20,6 +18,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/base.py b/custom_components/tuya_openapi/base.py index a546ae8..fe3fb3c 100644 --- a/custom_components/tuya_openapi/base.py +++ b/custom_components/tuya_openapi/base.py @@ -2,16 +2,15 @@ from __future__ import annotations import base64 -from dataclasses import dataclass import json import struct +from dataclasses import dataclass from typing import Any, Literal, Self, overload -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import Entity +from tuya_iot import TuyaDevice, TuyaDeviceManager from .const import ( DOMAIN, diff --git a/custom_components/tuya_openapi/binary_sensor.py b/custom_components/tuya_openapi/binary_sensor.py index 27f4240..1942a43 100644 --- a/custom_components/tuya_openapi/binary_sensor.py +++ b/custom_components/tuya_openapi/binary_sensor.py @@ -3,8 +3,6 @@ from dataclasses import dataclass -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, BinarySensorEntity, @@ -15,6 +13,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/button.py b/custom_components/tuya_openapi/button.py index 4c73b70..f6bcd84 100644 --- a/custom_components/tuya_openapi/button.py +++ b/custom_components/tuya_openapi/button.py @@ -1,14 +1,13 @@ """Support for Tuya buttons.""" from __future__ import annotations -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.button import ButtonEntity, ButtonEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/camera.py b/custom_components/tuya_openapi/camera.py index 7221605..ac2a6b5 100644 --- a/custom_components/tuya_openapi/camera.py +++ b/custom_components/tuya_openapi/camera.py @@ -1,14 +1,14 @@ """Support for Tuya cameras.""" from __future__ import annotations -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components import ffmpeg -from homeassistant.components.camera import Camera as CameraEntity, CameraEntityFeature +from homeassistant.components.camera import Camera as CameraEntity +from homeassistant.components.camera import CameraEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/climate.py b/custom_components/tuya_openapi/climate.py index 6b3b84b..b0b4679 100644 --- a/custom_components/tuya_openapi/climate.py +++ b/custom_components/tuya_openapi/climate.py @@ -4,8 +4,6 @@ from dataclasses import dataclass from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.climate import ( SWING_BOTH, SWING_HORIZONTAL, @@ -22,6 +20,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/config_flow.py b/custom_components/tuya_openapi/config_flow.py index bf2c54a..aae264d 100644 --- a/custom_components/tuya_openapi/config_flow.py +++ b/custom_components/tuya_openapi/config_flow.py @@ -3,10 +3,9 @@ from typing import Any -from tuya_iot import AuthType, TuyaOpenAPI import voluptuous as vol - from homeassistant import config_entries +from tuya_iot import AuthType, TuyaOpenAPI from .const import ( CONF_ACCESS_ID, diff --git a/custom_components/tuya_openapi/const.py b/custom_components/tuya_openapi/const.py index c850a64..74d4a0c 100644 --- a/custom_components/tuya_openapi/const.py +++ b/custom_components/tuya_openapi/const.py @@ -1,12 +1,10 @@ """Constants for the Tuya integration.""" from __future__ import annotations +import logging from collections.abc import Callable from dataclasses import dataclass, field from enum import StrEnum -import logging - -from tuya_iot import TuyaCloudOpenAPIEndpoint from homeassistant.components.sensor import SensorDeviceClass from homeassistant.const import ( @@ -27,6 +25,7 @@ UnitOfTemperature, UnitOfVolume, ) +from tuya_iot import TuyaCloudOpenAPIEndpoint DOMAIN = "tuya" LOGGER = logging.getLogger(__package__) diff --git a/custom_components/tuya_openapi/cover.py b/custom_components/tuya_openapi/cover.py index da9f7d2..9c517be 100644 --- a/custom_components/tuya_openapi/cover.py +++ b/custom_components/tuya_openapi/cover.py @@ -4,8 +4,6 @@ from dataclasses import dataclass from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, @@ -18,6 +16,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/diagnostics.py b/custom_components/tuya_openapi/diagnostics.py index 4544169..a7c6820 100644 --- a/custom_components/tuya_openapi/diagnostics.py +++ b/custom_components/tuya_openapi/diagnostics.py @@ -1,18 +1,18 @@ """Diagnostics support for Tuya.""" from __future__ import annotations -from contextlib import suppress import json +from contextlib import suppress from typing import Any, cast -from tuya_iot import TuyaDevice - from homeassistant.components.diagnostics import REDACTED from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import device_registry as dr, entity_registry as er +from homeassistant.helpers import device_registry as dr +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.util import dt as dt_util +from tuya_iot import TuyaDevice from . import HomeAssistantTuyaData from .const import ( diff --git a/custom_components/tuya_openapi/fan.py b/custom_components/tuya_openapi/fan.py index 210cc5c..ce976e3 100644 --- a/custom_components/tuya_openapi/fan.py +++ b/custom_components/tuya_openapi/fan.py @@ -3,8 +3,6 @@ from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.fan import ( DIRECTION_FORWARD, DIRECTION_REVERSE, @@ -19,6 +17,7 @@ ordered_list_item_to_percentage, percentage_to_ordered_list_item, ) +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import EnumTypeData, IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/humidifier.py b/custom_components/tuya_openapi/humidifier.py index 6d09ba4..a8d440d 100644 --- a/custom_components/tuya_openapi/humidifier.py +++ b/custom_components/tuya_openapi/humidifier.py @@ -3,8 +3,6 @@ from dataclasses import dataclass -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.humidifier import ( HumidifierDeviceClass, HumidifierEntity, @@ -15,6 +13,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/light.py b/custom_components/tuya_openapi/light.py index b4396f6..1f44c79 100644 --- a/custom_components/tuya_openapi/light.py +++ b/custom_components/tuya_openapi/light.py @@ -1,12 +1,10 @@ """Support for the Tuya lights.""" from __future__ import annotations -from dataclasses import dataclass, field import json +from dataclasses import dataclass, field from typing import Any, cast -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, @@ -20,6 +18,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/number.py b/custom_components/tuya_openapi/number.py index 5e7bdcc..4fc59db 100644 --- a/custom_components/tuya_openapi/number.py +++ b/custom_components/tuya_openapi/number.py @@ -1,8 +1,6 @@ """Support for Tuya number.""" from __future__ import annotations -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.number import ( NumberDeviceClass, NumberEntity, @@ -13,6 +11,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import IntegerTypeData, TuyaEntity diff --git a/custom_components/tuya_openapi/scene.py b/custom_components/tuya_openapi/scene.py index 289e319..23ca634 100644 --- a/custom_components/tuya_openapi/scene.py +++ b/custom_components/tuya_openapi/scene.py @@ -3,13 +3,12 @@ from typing import Any -from tuya_iot import TuyaHomeManager, TuyaScene - from homeassistant.components.scene import Scene from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaHomeManager, TuyaScene from . import HomeAssistantTuyaData from .const import DOMAIN diff --git a/custom_components/tuya_openapi/select.py b/custom_components/tuya_openapi/select.py index 3cc8c72..5dc2839 100644 --- a/custom_components/tuya_openapi/select.py +++ b/custom_components/tuya_openapi/select.py @@ -1,14 +1,13 @@ """Support for Tuya select.""" from __future__ import annotations -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/sensor.py b/custom_components/tuya_openapi/sensor.py index 170ca7a..85328c1 100644 --- a/custom_components/tuya_openapi/sensor.py +++ b/custom_components/tuya_openapi/sensor.py @@ -3,9 +3,6 @@ from dataclasses import dataclass -from tuya_iot import TuyaDevice, TuyaDeviceManager -from tuya_iot.device import TuyaDeviceStatusRange - from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, @@ -25,6 +22,8 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType +from tuya_iot import TuyaDevice, TuyaDeviceManager +from tuya_iot.device import TuyaDeviceStatusRange from . import HomeAssistantTuyaData from .base import ( diff --git a/custom_components/tuya_openapi/siren.py b/custom_components/tuya_openapi/siren.py index c2dc8ce..9fa9506 100644 --- a/custom_components/tuya_openapi/siren.py +++ b/custom_components/tuya_openapi/siren.py @@ -3,8 +3,6 @@ from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.siren import ( SirenEntity, SirenEntityDescription, @@ -14,6 +12,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/switch.py b/custom_components/tuya_openapi/switch.py index a48d797..d83b0d2 100644 --- a/custom_components/tuya_openapi/switch.py +++ b/custom_components/tuya_openapi/switch.py @@ -3,8 +3,6 @@ from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.switch import ( SwitchDeviceClass, SwitchEntity, @@ -15,6 +13,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import TuyaEntity diff --git a/custom_components/tuya_openapi/vacuum.py b/custom_components/tuya_openapi/vacuum.py index b332be7..a956c58 100644 --- a/custom_components/tuya_openapi/vacuum.py +++ b/custom_components/tuya_openapi/vacuum.py @@ -3,8 +3,6 @@ from typing import Any -from tuya_iot import TuyaDevice, TuyaDeviceManager - from homeassistant.components.vacuum import ( STATE_CLEANING, STATE_DOCKED, @@ -18,6 +16,7 @@ from homeassistant.helpers import issue_registry as ir from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from tuya_iot import TuyaDevice, TuyaDeviceManager from . import HomeAssistantTuyaData from .base import EnumTypeData, IntegerTypeData, TuyaEntity