Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Jan 10, 2025
1 parent 42b2e68 commit e3c8fc1
Show file tree
Hide file tree
Showing 28 changed files with 81 additions and 125 deletions.
7 changes: 1 addition & 6 deletions custom_components/localtuya/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""The LocalTuya integration."""

import asyncio
from dataclasses import dataclass
import logging
import time
from datetime import timedelta
from typing import Any, NamedTuple

import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.device_registry as dr
Expand All @@ -27,9 +24,7 @@
)
from homeassistant.core import Event, HomeAssistant, ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.event import async_track_time_interval

from .coordinator import TuyaDevice, HassLocalTuyaData, TuyaCloudApi
from .config_flow import ENTRIES_VERSION
from .const import (
ATTR_UPDATED_AT,
Expand All @@ -42,7 +37,7 @@
DOMAIN,
PLATFORMS,
)

from .coordinator import TuyaDevice, HassLocalTuyaData, TuyaCloudApi
from .discovery import TuyaDiscovery

_LOGGER = logging.getLogger(__name__)
Expand Down
7 changes: 3 additions & 4 deletions custom_components/localtuya/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
"""Platform to present any Tuya DP as a Alarm."""

from enum import StrEnum
import logging
from enum import StrEnum
from functools import partial
from .config_flow import col_to_select

import voluptuous as vol
from homeassistant.helpers import selector
from homeassistant.components.alarm_control_panel import (
DOMAIN,
AlarmControlPanelEntity,
CodeFormat,
AlarmControlPanelEntityFeature,
AlarmControlPanelState,
)
from homeassistant.helpers import selector

from .entity import LocalTuyaEntity, async_setup_entry
from .const import CONF_ALARM_SUPPORTED_STATES
from .entity import LocalTuyaEntity, async_setup_entry

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 0 additions & 2 deletions custom_components/localtuya/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import logging
from functools import partial

import voluptuous as vol
from homeassistant.components.button import DOMAIN, ButtonEntity

from .entity import LocalTuyaEntity, async_setup_entry
from .const import CONF_PASSIVE_ENTITY

_LOGGER = logging.getLogger(__name__)

Expand Down
9 changes: 4 additions & 5 deletions custom_components/localtuya/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
# PRESETS and HVAC_MODE Needs to be handle in better way.
"""

import asyncio
import logging
from functools import partial
from .config_flow import col_to_select
from homeassistant.helpers import selector

import voluptuous as vol
from homeassistant.components.climate import (
Expand All @@ -32,8 +29,9 @@
PRECISION_WHOLE,
UnitOfTemperature,
)
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .entity import LocalTuyaEntity, async_setup_entry
from homeassistant.helpers import selector

from .config_flow import col_to_select
from .const import (
CONF_CURRENT_TEMPERATURE_DP,
CONF_ECO_DP,
Expand All @@ -55,6 +53,7 @@
CONF_FAN_SPEED_DP,
CONF_FAN_SPEED_LIST,
)
from .entity import LocalTuyaEntity, async_setup_entry

_LOGGER = logging.getLogger(__name__)

Expand Down
28 changes: 13 additions & 15 deletions custom_components/localtuya/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
import errno
import logging
import time
from importlib import import_module
from functools import partial
from collections.abc import Coroutine
from typing import Any
from copy import deepcopy

from functools import partial
from importlib import import_module
from typing import Any

import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.entity_registry as er
from homeassistant.helpers.selector import (
SelectSelector,
SelectSelectorConfig,
SelectSelectorMode,
SelectOptionDict,
)
import voluptuous as vol
from homeassistant import exceptions
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import (
CONF_CLIENT_ID,
CONF_CLIENT_SECRET,
Expand All @@ -40,12 +34,13 @@
EntityCategory,
)
from homeassistant.core import callback, HomeAssistant
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from markdown_it.common.entities import entities
from homeassistant.helpers.selector import (
SelectSelector,
SelectSelectorConfig,
SelectSelectorMode,
SelectOptionDict,
)

from .coordinator import pytuya, TuyaCloudApi
from .core.cloud_api import TUYA_ENDPOINTS
from .core.helpers import templates, get_gateway_by_deviceid, gen_localtuya_entities
from .const import (
ATTR_UPDATED_AT,
CONF_ADD_DEVICE,
Expand Down Expand Up @@ -76,6 +71,9 @@
SUPPORTED_PROTOCOL_VERSIONS,
CONF_DEVICE_SLEEP_TIME,
)
from .coordinator import pytuya, TuyaCloudApi
from .core.cloud_api import TUYA_ENDPOINTS
from .core.helpers import templates, get_gateway_by_deviceid, gen_localtuya_entities
from .discovery import discover

_LOGGER = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dataclasses import dataclass
from typing import Any

from homeassistant.const import (
CONF_DEVICE_ID,
CONF_ENTITIES,
Expand Down
26 changes: 12 additions & 14 deletions custom_components/localtuya/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
"""Tuya Device API"""

from __future__ import annotations

import asyncio
import errno
import logging
import time
from datetime import timedelta
from typing import Any, NamedTuple
from functools import partial


from homeassistant.core import HomeAssistant, CALLBACK_TYPE, callback, State
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ID, CONF_DEVICES, CONF_HOST, CONF_DEVICE_ID
from homeassistant.helpers.event import async_track_time_interval, async_call_later
from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_DEVICE_ID
from homeassistant.core import HomeAssistant, CALLBACK_TYPE, callback
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
dispatcher_send,
)
from homeassistant.helpers.event import async_track_time_interval

from .core import pytuya
from .core.cloud_api import TuyaCloudApi
from .core.pytuya import (
HEARTBEAT_INTERVAL,
TuyaListener,
ContextualLogger,
SubdeviceState,
)
from .const import (
ATTR_UPDATED_AT,
CONF_GATEWAY_ID,
Expand All @@ -39,6 +29,14 @@
DeviceConfig,
RESTORE_STATES,
)
from .core import pytuya
from .core.cloud_api import TuyaCloudApi
from .core.pytuya import (
HEARTBEAT_INTERVAL,
TuyaListener,
ContextualLogger,
SubdeviceState,
)

_LOGGER = logging.getLogger(__name__)
RECONNECT_INTERVAL = timedelta(seconds=5)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/localtuya/core/ha_entities/base.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from enum import StrEnum
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any

from homeassistant.const import (
CONF_FRIENDLY_NAME,
CONF_ICON,
CONF_ENTITY_CATEGORY,
CONF_DEVICE_CLASS,
Platform,
EntityCategory,
)
from ...const import CONF_CLEAN_AREA_DP, CONF_DPS_STRINGS, CONF_STATE_CLASS

from ...const import CONF_STATE_CLASS


# Obtain values from cloud data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
Modified by: xZetsubou
"""

from .base import DPCode, LocalTuyaEntity, CONF_DEVICE_CLASS, EntityCategory
from homeassistant.components.binary_sensor import BinarySensorDeviceClass

from .base import DPCode, LocalTuyaEntity, EntityCategory

CONF_STATE_ON = "state_on"

ALARM_ON = {CONF_STATE_ON: "alarm"}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/localtuya/core/ha_entities/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Modified by: xZetsubou
"""

from .base import DPCode, LocalTuyaEntity, CONF_DEVICE_CLASS, EntityCategory
from .base import DPCode, LocalTuyaEntity, EntityCategory

BUTTONS: dict[str, tuple[LocalTuyaEntity, ...]] = {
# Scene Switch
Expand Down
5 changes: 0 additions & 5 deletions custom_components/localtuya/core/ha_entities/climates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from homeassistant.components.climate import (
HVACMode,
HVACAction,
DEFAULT_MAX_TEMP,
DEFAULT_MIN_TEMP,
ATTR_MAX_TEMP,
ATTR_MIN_TEMP,
)
from homeassistant.const import CONF_TEMPERATURE_UNIT

Expand All @@ -36,7 +32,6 @@
CONF_PRESET_DP,
)


UNIT_C = "celsius"
UNIT_F = "fahrenheit"

Expand Down
3 changes: 2 additions & 1 deletion custom_components/localtuya/core/ha_entities/covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
Modified by: xZetsubou
"""

from .base import DPCode, LocalTuyaEntity, CONF_DEVICE_CLASS, EntityCategory
from homeassistant.components.cover import CoverDeviceClass

from .base import DPCode, LocalTuyaEntity

# from const.py this is temporarily.
CONF_COMMANDS_SET = "commands_set"
CONF_POSITIONING_MODE = "positioning_mode"
Expand Down
5 changes: 2 additions & 3 deletions custom_components/localtuya/core/ha_entities/fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
Modified by: xZetsubou
"""

from homeassistant.components.fan import DIRECTION_FORWARD, DIRECTION_REVERSE

from .base import (
DPCode,
LocalTuyaEntity,
CONF_DEVICE_CLASS,
EntityCategory,
CLOUD_VALUE,
)
from homeassistant.components.fan import DIRECTION_FORWARD, DIRECTION_REVERSE

# from const.py this is temporarily
CONF_FAN_SPEED_CONTROL = "fan_speed_control"
Expand Down
13 changes: 6 additions & 7 deletions custom_components/localtuya/core/ha_entities/humidifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
Modified by: xZetsubou
"""

from .base import (
DPCode,
LocalTuyaEntity,
CONF_DEVICE_CLASS,
EntityCategory,
CLOUD_VALUE,
)
from homeassistant.components.humidifier import (
HumidifierDeviceClass,
ATTR_MAX_HUMIDITY,
Expand All @@ -21,6 +14,12 @@
DEFAULT_MIN_HUMIDITY,
)

from .base import (
DPCode,
LocalTuyaEntity,
CLOUD_VALUE,
)

CONF_HUMIDIFIER_SET_HUMIDITY_DP = "humidifier_set_humidity_dp"
CONF_HUMIDIFIER_CURRENT_HUMIDITY_DP = "humidifier_current_humidity_dp"
CONF_HUMIDIFIER_MODE_DP = "humidifier_mode_dp"
Expand Down
5 changes: 3 additions & 2 deletions custom_components/localtuya/core/ha_entities/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"""

from typing import Any
from .base import DPCode, LocalTuyaEntity, EntityCategory, CLOUD_VALUE
from homeassistant.const import CONF_BRIGHTNESS, CONF_COLOR_TEMP, CONF_SCENE

from homeassistant.const import CONF_BRIGHTNESS

from .base import DPCode, LocalTuyaEntity, EntityCategory, CLOUD_VALUE
from ...const import (
CONF_BRIGHTNESS_LOWER,
CONF_BRIGHTNESS_UPPER,
Expand Down
1 change: 0 additions & 1 deletion custom_components/localtuya/core/ha_entities/selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .base import (
DPCode,
LocalTuyaEntity,
CONF_DEVICE_CLASS,
EntityCategory,
CLOUD_VALUE,
)
Expand Down
3 changes: 0 additions & 3 deletions custom_components/localtuya/core/ha_entities/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@

from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.const import (
PERCENTAGE,
UnitOfTime,
UnitOfPower,
PERCENTAGE,
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfTime,
CONF_UNIT_OF_MEASUREMENT,
UnitOfTemperature,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/localtuya/core/ha_entities/sirens.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Modified by: xZetsubou
"""

from .base import DPCode, LocalTuyaEntity, CONF_DEVICE_CLASS, EntityCategory
from .base import DPCode, LocalTuyaEntity

# All descriptions can be found here:
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
Expand Down
3 changes: 2 additions & 1 deletion custom_components/localtuya/core/ha_entities/switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
Modified by: xZetsubou
"""

from .base import DPCode, LocalTuyaEntity, CONF_DEVICE_CLASS, EntityCategory
from homeassistant.components.switch import SwitchDeviceClass

from .base import DPCode, LocalTuyaEntity, EntityCategory

CHILD_LOCK = (
LocalTuyaEntity(
id=DPCode.CHILD_LOCK,
Expand Down
Loading

0 comments on commit e3c8fc1

Please sign in to comment.