mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix Xiaomi Miio setup of switch entity for lumi.acpartner.v3 (#47345)
This commit is contained in:
parent
b49a672fd5
commit
b58f9ce33a
@ -24,7 +24,7 @@ from .gateway import ConnectXiaomiGateway
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
GATEWAY_PLATFORMS = ["alarm_control_panel", "sensor", "light"]
|
||||
GATEWAY_PLATFORMS = ["alarm_control_panel", "sensor", "switch", "light"]
|
||||
SWITCH_PLATFORMS = ["switch"]
|
||||
FAN_PLATFORMS = ["fan"]
|
||||
VACUUM_PLATFORMS = ["vacuum"]
|
||||
|
@ -68,7 +68,6 @@ MODELS_SWITCH = [
|
||||
"chuangmi.plug.v2",
|
||||
"chuangmi.plug.hmi205",
|
||||
"chuangmi.plug.hmi206",
|
||||
"lumi.acpartner.v3",
|
||||
]
|
||||
MODELS_FAN = MODELS_FAN_MIIO + MODELS_HUMIDIFIER_MIOT + MODELS_PURIFIER_MIOT
|
||||
MODELS_VACUUM = ["roborock.vacuum"]
|
||||
|
@ -21,6 +21,7 @@ import homeassistant.helpers.config_validation as cv
|
||||
from .const import (
|
||||
CONF_DEVICE,
|
||||
CONF_FLOW_TYPE,
|
||||
CONF_GATEWAY,
|
||||
CONF_MODEL,
|
||||
DOMAIN,
|
||||
SERVICE_SET_POWER_MODE,
|
||||
@ -128,16 +129,19 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the switch from a config entry."""
|
||||
entities = []
|
||||
|
||||
if config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE:
|
||||
if DATA_KEY not in hass.data:
|
||||
hass.data[DATA_KEY] = {}
|
||||
|
||||
host = config_entry.data[CONF_HOST]
|
||||
token = config_entry.data[CONF_TOKEN]
|
||||
name = config_entry.title
|
||||
model = config_entry.data[CONF_MODEL]
|
||||
unique_id = config_entry.unique_id
|
||||
|
||||
if config_entry.data[CONF_FLOW_TYPE] == CONF_DEVICE or (
|
||||
config_entry.data[CONF_FLOW_TYPE] == CONF_GATEWAY
|
||||
and model == "lumi.acpartner.v3"
|
||||
):
|
||||
if DATA_KEY not in hass.data:
|
||||
hass.data[DATA_KEY] = {}
|
||||
|
||||
_LOGGER.debug("Initializing with host %s (token %s...)", host, token[:5])
|
||||
|
||||
if model in ["chuangmi.plug.v1", "chuangmi.plug.v3", "chuangmi.plug.hmi208"]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user