mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 01:46:11 -04:00
Refactor split between quirks and device_quirks
This commit is contained in:
@@ -17,7 +17,6 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||
from homeassistant.xternal_tuya_quirks import register_tuya_quirks
|
||||
|
||||
from .const import (
|
||||
CONF_APP_TYPE,
|
||||
@@ -32,6 +31,7 @@ from .const import (
|
||||
TUYA_DISCOVERY_NEW,
|
||||
TUYA_HA_SIGNAL_UPDATE_ENTITY,
|
||||
)
|
||||
from .xternal_tuya_device_quirks import register_tuya_quirks
|
||||
|
||||
# Suppress logs from the library, it logs unneeded on error
|
||||
logging.getLogger("tuya_sharing").setLevel(logging.CRITICAL)
|
||||
|
||||
@@ -18,17 +18,13 @@ from homeassistant.components.cover import (
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.xternal_tuya_quirks import (
|
||||
TUYA_QUIRKS_REGISTRY,
|
||||
TuyaCoverDefinition,
|
||||
parse_enum,
|
||||
)
|
||||
|
||||
from . import TuyaConfigEntry
|
||||
from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType
|
||||
from .entity import TuyaEntity
|
||||
from .models import EnumTypeData, IntegerTypeData
|
||||
from .util import get_dpcode
|
||||
from .xternal_tuya_quirks import TUYA_QUIRKS_REGISTRY, TuyaCoverDefinition, parse_enum
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
@@ -9,15 +9,11 @@ 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 AddConfigEntryEntitiesCallback
|
||||
from homeassistant.xternal_tuya_quirks import (
|
||||
TUYA_QUIRKS_REGISTRY,
|
||||
TuyaSelectDefinition,
|
||||
parse_enum,
|
||||
)
|
||||
|
||||
from . import TuyaConfigEntry
|
||||
from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType
|
||||
from .entity import TuyaEntity
|
||||
from .xternal_tuya_quirks import TUYA_QUIRKS_REGISTRY, TuyaSelectDefinition, parse_enum
|
||||
|
||||
# All descriptions can be found here. Mostly the Enum data types in the
|
||||
# default instructions set of each category end up being a select.
|
||||
|
||||
@@ -30,11 +30,6 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.xternal_tuya_quirks import (
|
||||
TUYA_QUIRKS_REGISTRY,
|
||||
TuyaSensorDefinition,
|
||||
parse_enum,
|
||||
)
|
||||
|
||||
from . import TuyaConfigEntry
|
||||
from .const import (
|
||||
@@ -50,6 +45,7 @@ from .const import (
|
||||
from .entity import TuyaEntity
|
||||
from .models import ComplexValue, ElectricityValue, EnumTypeData, IntegerTypeData
|
||||
from .util import get_dptype
|
||||
from .xternal_tuya_quirks import TUYA_QUIRKS_REGISTRY, TuyaSensorDefinition, parse_enum
|
||||
|
||||
_WIND_DIRECTIONS = {
|
||||
"north": 0.0,
|
||||
|
||||
+8
-23
@@ -8,38 +8,23 @@ import pathlib
|
||||
import pkgutil
|
||||
import sys
|
||||
|
||||
from .device_quirk import (
|
||||
TuyaCoverDefinition,
|
||||
TuyaDeviceQuirk,
|
||||
TuyaSelectDefinition,
|
||||
TuyaSensorDefinition,
|
||||
)
|
||||
from .homeassistant import TuyaCoverDeviceClass, TuyaSensorDeviceClass, parse_enum
|
||||
from .registry import QuirksRegistry
|
||||
from ..xternal_tuya_quirks import TUYA_QUIRKS_REGISTRY
|
||||
|
||||
__all__ = [
|
||||
"QUIRKS_REGISTRY",
|
||||
"QuirksRegistry",
|
||||
"TuyaCoverDefinition",
|
||||
"TuyaCoverDeviceClass",
|
||||
"TuyaDeviceQuirk",
|
||||
"TuyaSelectDefinition",
|
||||
"TuyaSensorDefinition",
|
||||
"TuyaSensorDeviceClass",
|
||||
"parse_enum",
|
||||
]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
TUYA_QUIRKS_REGISTRY = QuirksRegistry()
|
||||
|
||||
|
||||
def register_tuya_quirks(custom_quirks_path: str | None = None) -> None:
|
||||
"""Register all quirks with zigpy, including optional custom quirks."""
|
||||
"""Register all quirks with xternal_tuya_quirks.
|
||||
|
||||
- remove custom quirks from `custom_quirks_path`
|
||||
- add quirks from `xternal_tuya_device_quirks`
|
||||
- add custom quirks from `custom_quirks_path`
|
||||
"""
|
||||
|
||||
if custom_quirks_path is not None:
|
||||
TUYA_QUIRKS_REGISTRY.purge_custom_quirks(custom_quirks_path)
|
||||
|
||||
# Import all quirks in the `zhaquirks` package first
|
||||
# Import all quirks in the `xternal_tuya_device_quirks` package first
|
||||
for _importer, modname, _ispkg in pkgutil.walk_packages(
|
||||
path=__path__,
|
||||
prefix=__name__ + ".",
|
||||
+6
-3
@@ -2,9 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import TUYA_QUIRKS_REGISTRY # noqa: TID252
|
||||
from ..device_quirk import TuyaDeviceQuirk # noqa: TID252
|
||||
from ..homeassistant import TuyaCoverDeviceClass, TuyaEntityCategory # noqa: TID252
|
||||
from ..xternal_tuya_quirks import (
|
||||
TUYA_QUIRKS_REGISTRY,
|
||||
TuyaCoverDeviceClass,
|
||||
TuyaDeviceQuirk,
|
||||
TuyaEntityCategory,
|
||||
)
|
||||
|
||||
(
|
||||
# This model has percent_state and percent_control but percent_state never
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Quirks for Tuya."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .device_quirk import (
|
||||
TuyaCoverDefinition,
|
||||
TuyaDeviceQuirk,
|
||||
TuyaSelectDefinition,
|
||||
TuyaSensorDefinition,
|
||||
)
|
||||
from .homeassistant import (
|
||||
TuyaCoverDeviceClass,
|
||||
TuyaEntityCategory,
|
||||
TuyaSensorDeviceClass,
|
||||
parse_enum,
|
||||
)
|
||||
from .registry import QuirksRegistry
|
||||
|
||||
__all__ = [
|
||||
"QUIRKS_REGISTRY",
|
||||
"QuirksRegistry",
|
||||
"TuyaCoverDefinition",
|
||||
"TuyaCoverDeviceClass",
|
||||
"TuyaDeviceQuirk",
|
||||
"TuyaEntityCategory",
|
||||
"TuyaSelectDefinition",
|
||||
"TuyaSensorDefinition",
|
||||
"TuyaSensorDeviceClass",
|
||||
"parse_enum",
|
||||
]
|
||||
|
||||
TUYA_QUIRKS_REGISTRY = QuirksRegistry()
|
||||
@@ -1 +0,0 @@
|
||||
"""Quirks for Tuya."""
|
||||
Reference in New Issue
Block a user