mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Prettify Tuya entity class names (#57629)
This commit is contained in:
parent
b854a2537f
commit
b220ab6e91
@ -44,7 +44,7 @@ class EnumTypeData:
|
||||
return cls(**json.loads(data))
|
||||
|
||||
|
||||
class TuyaHaEntity(Entity):
|
||||
class TuyaEntity(Entity):
|
||||
"""Tuya base device."""
|
||||
|
||||
_attr_should_poll = False
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import HomeAssistantTuyaData
|
||||
from .base import TuyaHaEntity
|
||||
from .base import TuyaEntity
|
||||
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
|
||||
|
||||
# All descriptions can be found here. Mostly the Boolean data types in the
|
||||
@ -71,7 +71,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class TuyaBinarySensorEntity(TuyaHaEntity, BinarySensorEntity):
|
||||
class TuyaBinarySensorEntity(TuyaEntity, BinarySensorEntity):
|
||||
"""Tuya Binary Sensor Entity."""
|
||||
|
||||
def __init__(
|
||||
|
@ -31,7 +31,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import HomeAssistantTuyaData
|
||||
from .base import EnumTypeData, IntegerTypeData, TuyaHaEntity
|
||||
from .base import EnumTypeData, IntegerTypeData, TuyaEntity
|
||||
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
|
||||
|
||||
TUYA_HVAC_TO_HA = {
|
||||
@ -110,7 +110,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class TuyaClimateEntity(TuyaHaEntity, ClimateEntity):
|
||||
class TuyaClimateEntity(TuyaEntity, ClimateEntity):
|
||||
"""Tuya Climate Device."""
|
||||
|
||||
_current_humidity_dpcode: DPCode | None = None
|
||||
|
@ -25,7 +25,7 @@ from homeassistant.util.percentage import (
|
||||
)
|
||||
|
||||
from . import HomeAssistantTuyaData
|
||||
from .base import TuyaHaEntity
|
||||
from .base import TuyaEntity
|
||||
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
|
||||
|
||||
TUYA_SUPPORT_TYPE = {
|
||||
@ -43,11 +43,11 @@ async def async_setup_entry(
|
||||
@callback
|
||||
def async_discover_device(device_ids: list[str]) -> None:
|
||||
"""Discover and add a discovered tuya fan."""
|
||||
entities: list[TuyaHaFan] = []
|
||||
entities: list[TuyaFanEntity] = []
|
||||
for device_id in device_ids:
|
||||
device = hass_data.device_manager.device_map[device_id]
|
||||
if device and device.category in TUYA_SUPPORT_TYPE:
|
||||
entities.append(TuyaHaFan(device, hass_data.device_manager))
|
||||
entities.append(TuyaFanEntity(device, hass_data.device_manager))
|
||||
async_add_entities(entities)
|
||||
|
||||
async_discover_device([*hass_data.device_manager.device_map])
|
||||
@ -57,7 +57,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class TuyaHaFan(TuyaHaEntity, FanEntity):
|
||||
class TuyaFanEntity(TuyaEntity, FanEntity):
|
||||
"""Tuya Fan Device."""
|
||||
|
||||
def __init__(self, device: TuyaDevice, device_manager: TuyaDeviceManager) -> None:
|
||||
|
@ -23,7 +23,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import HomeAssistantTuyaData
|
||||
from .base import TuyaHaEntity
|
||||
from .base import TuyaEntity
|
||||
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -73,11 +73,11 @@ async def async_setup_entry(
|
||||
@callback
|
||||
def async_discover_device(device_ids: list[str]):
|
||||
"""Discover and add a discovered tuya light."""
|
||||
entities: list[TuyaHaLight] = []
|
||||
entities: list[TuyaLightEntity] = []
|
||||
for device_id in device_ids:
|
||||
device = hass_data.device_manager.device_map[device_id]
|
||||
if device and device.category in TUYA_SUPPORT_TYPE:
|
||||
entities.append(TuyaHaLight(device, hass_data.device_manager))
|
||||
entities.append(TuyaLightEntity(device, hass_data.device_manager))
|
||||
async_add_entities(entities)
|
||||
|
||||
async_discover_device([*hass_data.device_manager.device_map])
|
||||
@ -87,7 +87,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class TuyaHaLight(TuyaHaEntity, LightEntity):
|
||||
class TuyaLightEntity(TuyaEntity, LightEntity):
|
||||
"""Tuya light device."""
|
||||
|
||||
def __init__(self, device: TuyaDevice, device_manager: TuyaDeviceManager) -> None:
|
||||
|
@ -21,10 +21,12 @@ async def async_setup_entry(
|
||||
"""Set up Tuya scenes."""
|
||||
hass_data: HomeAssistantTuyaData = hass.data[DOMAIN][entry.entry_id]
|
||||
scenes = await hass.async_add_executor_job(hass_data.home_manager.query_scenes)
|
||||
async_add_entities(TuyaHAScene(hass_data.home_manager, scene) for scene in scenes)
|
||||
async_add_entities(
|
||||
TuyaSceneEntity(hass_data.home_manager, scene) for scene in scenes
|
||||
)
|
||||
|
||||
|
||||
class TuyaHAScene(Scene):
|
||||
class TuyaSceneEntity(Scene):
|
||||
"""Tuya Scene Remote."""
|
||||
|
||||
_should_poll = False
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import HomeAssistantTuyaData
|
||||
from .base import TuyaHaEntity
|
||||
from .base import TuyaEntity
|
||||
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
|
||||
|
||||
# All descriptions can be found here. Mostly the Boolean data types in the
|
||||
@ -271,7 +271,7 @@ async def async_setup_entry(
|
||||
@callback
|
||||
def async_discover_device(device_ids: list[str]) -> None:
|
||||
"""Discover and add a discovered tuya sensor."""
|
||||
entities: list[TuyaHaSwitch] = []
|
||||
entities: list[TuyaSwitchEntity] = []
|
||||
for device_id in device_ids:
|
||||
device = hass_data.device_manager.device_map[device_id]
|
||||
if descriptions := SWITCHES.get(device.category):
|
||||
@ -281,7 +281,9 @@ async def async_setup_entry(
|
||||
or description.key in device.status
|
||||
):
|
||||
entities.append(
|
||||
TuyaHaSwitch(device, hass_data.device_manager, description)
|
||||
TuyaSwitchEntity(
|
||||
device, hass_data.device_manager, description
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
@ -293,7 +295,7 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class TuyaHaSwitch(TuyaHaEntity, SwitchEntity):
|
||||
class TuyaSwitchEntity(TuyaEntity, SwitchEntity):
|
||||
"""Tuya Switch Device."""
|
||||
|
||||
def __init__(
|
||||
|
Loading…
x
Reference in New Issue
Block a user