Merge branch 'pytuya_refactoring' into physical_device
This commit is contained in:
@@ -77,13 +77,12 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Set up LocalTuya integration from a config entry."""
|
||||
|
||||
print('async_setup_entry localtuya subswitch [{}] '.format(entry.data))
|
||||
|
||||
for component in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, component)
|
||||
)
|
||||
for platform in PLATFORMS:
|
||||
# print("ASE*** [{}] [{}]".format(entry.data["entities"][0][CONF_PLATFORM], platform))
|
||||
if entry.data["entities"][0][CONF_PLATFORM] == platform:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
CoverEntity,
|
||||
DOMAIN,
|
||||
PLATFORM_SCHEMA,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
@@ -44,8 +45,6 @@ from .pytuya import TuyaDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM = "cover"
|
||||
|
||||
DEFAULT_OPEN_CMD = "on"
|
||||
DEFAULT_CLOSE_CMD = "off"
|
||||
DEFAULT_STOP_CMD = "stop"
|
||||
@@ -72,7 +71,7 @@ def flow_schema(dps):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Setup a Tuya cover based on a config entry."""
|
||||
device, entities_to_setup = prepare_setup_entities(
|
||||
config_entry, PLATFORM
|
||||
config_entry, DOMAIN
|
||||
)
|
||||
if not entities_to_setup:
|
||||
return
|
||||
@@ -102,7 +101,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up of the Tuya cover."""
|
||||
return import_from_yaml(hass, config, PLATFORM)
|
||||
return import_from_yaml(hass, config, DOMAIN)
|
||||
|
||||
|
||||
class TuyaCache:
|
||||
|
@@ -20,6 +20,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.fan import (
|
||||
FanEntity,
|
||||
DOMAIN,
|
||||
PLATFORM_SCHEMA,
|
||||
SPEED_LOW,
|
||||
SPEED_MEDIUM,
|
||||
@@ -36,8 +37,6 @@ from .pytuya import TuyaDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM = "fan"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(BASE_PLATFORM_SCHEMA)
|
||||
|
||||
|
||||
@@ -49,7 +48,7 @@ def flow_schema(dps):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Setup a Tuya fan based on a config entry."""
|
||||
device, entities_to_setup = prepare_setup_entities(
|
||||
config_entry, PLATFORM
|
||||
config_entry, DOMAIN
|
||||
)
|
||||
if not entities_to_setup:
|
||||
return
|
||||
@@ -70,7 +69,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up of the Tuya fan."""
|
||||
return import_from_yaml(hass, config, PLATFORM)
|
||||
return import_from_yaml(hass, config, DOMAIN)
|
||||
|
||||
|
||||
class LocaltuyaFan(FanEntity):
|
||||
|
@@ -23,6 +23,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.components.light import (
|
||||
LightEntity,
|
||||
DOMAIN,
|
||||
PLATFORM_SCHEMA,
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
@@ -38,8 +39,6 @@ from .pytuya import TuyaDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM = "light"
|
||||
|
||||
MIN_MIRED = 153
|
||||
MAX_MIRED = 370
|
||||
UPDATE_RETRY_LIMIT = 3
|
||||
@@ -55,7 +54,7 @@ def flow_schema(dps):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Setup a Tuya switch based on a config entry."""
|
||||
device, entities_to_setup = prepare_setup_entities(
|
||||
config_entry, PLATFORM
|
||||
config_entry, DOMAIN
|
||||
)
|
||||
if not entities_to_setup:
|
||||
return
|
||||
@@ -75,7 +74,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up of the Tuya switch."""
|
||||
return import_from_yaml(hass, config, PLATFORM)
|
||||
return import_from_yaml(hass, config, DOMAIN)
|
||||
|
||||
|
||||
class TuyaCache:
|
||||
|
@@ -32,6 +32,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import (
|
||||
SwitchEntity,
|
||||
DOMAIN,
|
||||
PLATFORM_SCHEMA,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
@@ -55,8 +56,6 @@ from .pytuya import TuyaDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM = "switch"
|
||||
|
||||
DEFAULT_ID = "1"
|
||||
|
||||
# TODO: This will eventully merge with flow_schema
|
||||
@@ -93,7 +92,7 @@ def flow_schema(dps):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Setup a Tuya switch based on a config entry."""
|
||||
device, entities_to_setup = prepare_setup_entities(
|
||||
config_entry, PLATFORM
|
||||
config_entry, DOMAIN
|
||||
)
|
||||
if not entities_to_setup:
|
||||
return
|
||||
@@ -116,7 +115,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up of the Tuya switch."""
|
||||
return import_from_yaml(hass, config, PLATFORM)
|
||||
return import_from_yaml(hass, config, DOMAIN)
|
||||
|
||||
|
||||
class TuyaCache:
|
||||
|
Reference in New Issue
Block a user