Skip to content

Commit

Permalink
Reformatted using isort & black to match vscode task
Browse files Browse the repository at this point in the history
  • Loading branch information
timlaing authored and make-all committed Jul 13, 2023
1 parent d317e63 commit 8410111
Show file tree
Hide file tree
Showing 114 changed files with 261 additions and 404 deletions.
2 changes: 1 addition & 1 deletion custom_components/tuya_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
CONF_TYPE,
DOMAIN,
)
from .device import setup_device, get_device_id, async_delete_device
from .device import async_delete_device, get_device_id, setup_device
from .helpers.device_config import get_config

_LOGGER = logging.getLogger(__name__)
Expand Down
8 changes: 3 additions & 5 deletions custom_components/tuya_local/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Setup for different kinds of Tuya alarm control panels.
"""
from homeassistant.components.alarm_control_panel import (
AlarmControlPanelEntity,
)
import logging

from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
from homeassistant.components.alarm_control_panel.const import (
AlarmControlPanelEntityFeature as Feature,
)
Expand All @@ -17,8 +17,6 @@
STATE_ALARM_TRIGGERED,
)

import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
Expand Down
5 changes: 3 additions & 2 deletions custom_components/tuya_local/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
Setup for different kinds of Tuya Binary sensors
"""
import logging

from homeassistant.components.binary_sensor import (
BinarySensorEntity,
BinarySensorDeviceClass,
BinarySensorEntity,
)
import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tuya_local/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import logging

from homeassistant.components.button import ButtonEntity, ButtonDeviceClass
from homeassistant.components.button import ButtonDeviceClass, ButtonEntity

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
7 changes: 3 additions & 4 deletions custom_components/tuya_local/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
Platform for Tuya Cameras
"""

from homeassistant.components.camera import (
Camera as CameraEntity,
CameraEntityFeature,
)
import logging

from homeassistant.components.camera import Camera as CameraEntity
from homeassistant.components.camera import CameraEntityFeature

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tuya_local/climate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Setup for different kinds of Tuya climate devices
"""
import logging

from homeassistant.components.climate import (
ClimateEntity,
ClimateEntityFeature,
Expand Down Expand Up @@ -30,8 +32,6 @@
PRECISION_WHOLE,
UnitOfTemperature,
)
import logging


from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tuya_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
from homeassistant.core import HomeAssistant, callback

from . import DOMAIN
from .device import TuyaLocalDevice
from .const import (
API_PROTOCOL_VERSIONS,
CONF_DEVICE_CID,
CONF_DEVICE_ID,
CONF_LOCAL_KEY,
CONF_POLL_ONLY,
CONF_DEVICE_CID,
CONF_PROTOCOL_VERSION,
CONF_TYPE,
)
from .device import TuyaLocalDevice
from .helpers.config import get_device_id
from .helpers.device_config import get_config
from .helpers.log import log_json
Expand Down
3 changes: 2 additions & 1 deletion custom_components/tuya_local/cover.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Setup for different kinds of Tuya cover devices
"""
import logging

from homeassistant.components.cover import (
CoverDeviceClass,
CoverEntity,
CoverEntityFeature,
)
import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
6 changes: 2 additions & 4 deletions custom_components/tuya_local/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

import asyncio
import logging
import tinytuya
from threading import Lock
from time import time


import tinytuya
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
Expand All @@ -19,18 +18,17 @@

from .const import (
API_PROTOCOL_VERSIONS,
CONF_DEVICE_CID,
CONF_DEVICE_ID,
CONF_LOCAL_KEY,
CONF_POLL_ONLY,
CONF_PROTOCOL_VERSION,
DOMAIN,
CONF_DEVICE_CID,
)
from .helpers.config import get_device_id
from .helpers.device_config import possible_matches
from .helpers.log import log_json


_LOGGER = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions custom_components/tuya_local/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
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 tinytuya import __version__ as tinytuya_version

from .const import (
API_PROTOCOL_VERSIONS,
CONF_DEVICE_CID,
CONF_PROTOCOL_VERSION,
CONF_TYPE,
DOMAIN,
CONF_DEVICE_CID,
)
from .device import TuyaLocalDevice
from .helpers.config import get_device_id
Expand Down
7 changes: 2 additions & 5 deletions custom_components/tuya_local/fan.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
"""
Setup for different kinds of Tuya fan devices
"""
from homeassistant.components.fan import (
FanEntity,
FanEntityFeature,
)
import logging

from homeassistant.components.fan import FanEntity, FanEntityFeature

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
from .helpers.mixin import TuyaLocalEntity


_LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion custom_components/tuya_local/helpers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from .. import DOMAIN
from ..const import CONF_DEVICE_ID, CONF_DEVICE_CID, CONF_TYPE
from ..const import CONF_DEVICE_CID, CONF_DEVICE_ID, CONF_TYPE
from .device_config import get_config

_LOGGER = logging.getLogger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/helpers/device_config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""
Config parser for Tuya Local devices.
"""
import logging
from base64 import b64decode, b64encode

from collections.abc import Sequence
from fnmatch import fnmatch
import logging
from numbers import Number
from os import walk
from os.path import join, dirname, splitext, exists
from os.path import dirname, exists, join, splitext

from homeassistant.util import slugify
from homeassistant.util.yaml import load_yaml
Expand Down
1 change: 1 addition & 0 deletions custom_components/tuya_local/helpers/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Mixins to make writing new platforms easier
"""
import logging

from homeassistant.const import (
AREA_SQUARE_METERS,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
Expand Down
6 changes: 3 additions & 3 deletions custom_components/tuya_local/humidifier.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"""
Setup for different kinds of Tuya humidifier devices
"""
import logging

from homeassistant.components.humidifier import (
HumidifierDeviceClass,
HumidifierEntity,
HumidifierEntityFeature,
)

from homeassistant.components.humidifier.const import (
DEFAULT_MAX_HUMIDITY,
DEFAULT_MIN_HUMIDITY,
)
import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
from .helpers.mixin import TuyaLocalEntity
from .helpers.config import async_tuya_setup_platform

_LOGGER = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions custom_components/tuya_local/light.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Setup for different kinds of Tuya light devices
"""
import logging
from struct import pack, unpack

import homeassistant.util.color as color_util
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
Expand All @@ -11,10 +15,6 @@
LightEntity,
LightEntityFeature,
)
import homeassistant.util.color as color_util

import logging
from struct import pack, unpack

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tuya_local/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from homeassistant.components.number import NumberEntity
from homeassistant.components.number.const import (
DEFAULT_MIN_VALUE,
DEFAULT_MAX_VALUE,
DEFAULT_MIN_VALUE,
NumberDeviceClass,
)

Expand Down
5 changes: 3 additions & 2 deletions custom_components/tuya_local/sensor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Setup for different kinds of Tuya sensors
"""
import logging

from homeassistant.components.sensor import (
STATE_CLASSES,
SensorDeviceClass,
SensorEntity,
STATE_CLASSES,
)
import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
6 changes: 2 additions & 4 deletions custom_components/tuya_local/siren.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""
Setup for Tuya siren devices
"""
from homeassistant.components.siren import (
SirenEntity,
SirenEntityFeature,
)
from homeassistant.components.siren import SirenEntity, SirenEntityFeature
from homeassistant.components.siren.const import (
ATTR_DURATION,
ATTR_TONE,
ATTR_VOLUME_LEVEL,
)

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tuya_local/switch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Setup for different kinds of Tuya switch devices
"""
from homeassistant.components.switch import SwitchEntity, SwitchDeviceClass
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
1 change: 1 addition & 0 deletions custom_components/tuya_local/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
StateVacuumEntity,
VacuumEntityFeature,
)

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
from .helpers.device_config import TuyaEntityConfig
Expand Down
5 changes: 3 additions & 2 deletions custom_components/tuya_local/water_heater.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""
Setup for different kinds of Tuya water heater devices
"""
import logging

from homeassistant.components.water_heater import (
ATTR_AWAY_MODE,
ATTR_CURRENT_TEMPERATURE,
ATTR_OPERATION_MODE,
ATTR_AWAY_MODE,
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
import logging

from .device import TuyaLocalDevice
from .helpers.config import async_tuya_setup_platform
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[isort]
profile=black
13 changes: 6 additions & 7 deletions tests/devices/base_device_tests.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from unittest import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, patch, PropertyMock
from unittest.mock import AsyncMock, PropertyMock, patch
from uuid import uuid4

from homeassistant.helpers.entity import EntityCategory

from custom_components.tuya_local.binary_sensor import TuyaLocalBinarySensor
from custom_components.tuya_local.alarm_control_panel import TuyaLocalAlarmControlPanel
from custom_components.tuya_local.binary_sensor import TuyaLocalBinarySensor
from custom_components.tuya_local.button import TuyaLocalButton
from custom_components.tuya_local.camera import TuyaLocalCamera
from custom_components.tuya_local.climate import TuyaLocalClimate
from custom_components.tuya_local.cover import TuyaLocalCover
from custom_components.tuya_local.fan import TuyaLocalFan
from custom_components.tuya_local.helpers.device_config import (
TuyaDeviceConfig,
possible_matches,
)
from custom_components.tuya_local.humidifier import TuyaLocalHumidifier
from custom_components.tuya_local.light import TuyaLocalLight
from custom_components.tuya_local.lock import TuyaLocalLock
Expand All @@ -22,11 +26,6 @@
from custom_components.tuya_local.vacuum import TuyaLocalVacuum
from custom_components.tuya_local.water_heater import TuyaLocalWaterHeater

from custom_components.tuya_local.helpers.device_config import (
TuyaDeviceConfig,
possible_matches,
)

DEVICE_TYPES = {
"alarm_control_panel": TuyaLocalAlarmControlPanel,
"binary_sensor": TuyaLocalBinarySensor,
Expand Down
Loading

0 comments on commit 8410111

Please sign in to comment.