mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Replace hard-coded domain strings with constants in the Wemo module (#44222)
This commit is contained in:
parent
1003464544
commit
d4ab7880af
@ -7,24 +7,28 @@ import requests
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||||
|
from homeassistant.components.fan import DOMAIN as FAN_DOMAIN
|
||||||
|
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||||
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
# Mapping from Wemo model_name to component.
|
# Mapping from Wemo model_name to domain.
|
||||||
WEMO_MODEL_DISPATCH = {
|
WEMO_MODEL_DISPATCH = {
|
||||||
"Bridge": "light",
|
"Bridge": LIGHT_DOMAIN,
|
||||||
"CoffeeMaker": "switch",
|
"CoffeeMaker": SWITCH_DOMAIN,
|
||||||
"Dimmer": "light",
|
"Dimmer": LIGHT_DOMAIN,
|
||||||
"Humidifier": "fan",
|
"Humidifier": FAN_DOMAIN,
|
||||||
"Insight": "switch",
|
"Insight": SWITCH_DOMAIN,
|
||||||
"LightSwitch": "switch",
|
"LightSwitch": SWITCH_DOMAIN,
|
||||||
"Maker": "switch",
|
"Maker": SWITCH_DOMAIN,
|
||||||
"Motion": "binary_sensor",
|
"Motion": BINARY_SENSOR_DOMAIN,
|
||||||
"Sensor": "binary_sensor",
|
"Sensor": BINARY_SENSOR_DOMAIN,
|
||||||
"Socket": "switch",
|
"Socket": SWITCH_DOMAIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -135,7 +139,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
device.serialnumber,
|
device.serialnumber,
|
||||||
)
|
)
|
||||||
|
|
||||||
component = WEMO_MODEL_DISPATCH.get(device.model_name, "switch")
|
component = WEMO_MODEL_DISPATCH.get(device.model_name, SWITCH_DOMAIN)
|
||||||
|
|
||||||
# Three cases:
|
# Three cases:
|
||||||
# - First time we see component, we need to load it and initialize the backlog
|
# - First time we see component, we need to load it and initialize the backlog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user