mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
All WeMo devices use the Sensor platform (#72396)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
b2e18682d2
commit
1a43f107c4
@ -32,7 +32,7 @@ WEMO_MODEL_DISPATCH = {
|
|||||||
"CoffeeMaker": [Platform.SWITCH],
|
"CoffeeMaker": [Platform.SWITCH],
|
||||||
"Dimmer": [Platform.LIGHT],
|
"Dimmer": [Platform.LIGHT],
|
||||||
"Humidifier": [Platform.FAN],
|
"Humidifier": [Platform.FAN],
|
||||||
"Insight": [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH],
|
"Insight": [Platform.BINARY_SENSOR, Platform.SWITCH],
|
||||||
"LightSwitch": [Platform.SWITCH],
|
"LightSwitch": [Platform.SWITCH],
|
||||||
"Maker": [Platform.BINARY_SENSOR, Platform.SWITCH],
|
"Maker": [Platform.BINARY_SENSOR, Platform.SWITCH],
|
||||||
"Motion": [Platform.BINARY_SENSOR],
|
"Motion": [Platform.BINARY_SENSOR],
|
||||||
@ -141,7 +141,7 @@ class WemoDispatcher:
|
|||||||
"""Initialize the WemoDispatcher."""
|
"""Initialize the WemoDispatcher."""
|
||||||
self._config_entry = config_entry
|
self._config_entry = config_entry
|
||||||
self._added_serial_numbers: set[str] = set()
|
self._added_serial_numbers: set[str] = set()
|
||||||
self._loaded_components: set[str] = set()
|
self._loaded_platforms: set[Platform] = set()
|
||||||
|
|
||||||
async def async_add_unique_device(
|
async def async_add_unique_device(
|
||||||
self, hass: HomeAssistant, wemo: pywemo.WeMoDevice
|
self, hass: HomeAssistant, wemo: pywemo.WeMoDevice
|
||||||
@ -151,28 +151,30 @@ class WemoDispatcher:
|
|||||||
return
|
return
|
||||||
|
|
||||||
coordinator = await async_register_device(hass, self._config_entry, wemo)
|
coordinator = await async_register_device(hass, self._config_entry, wemo)
|
||||||
for component in WEMO_MODEL_DISPATCH.get(wemo.model_name, [Platform.SWITCH]):
|
platforms = set(WEMO_MODEL_DISPATCH.get(wemo.model_name, [Platform.SWITCH]))
|
||||||
|
platforms.add(Platform.SENSOR)
|
||||||
|
for platform in platforms:
|
||||||
# Three cases:
|
# Three cases:
|
||||||
# - First time we see component, we need to load it and initialize the backlog
|
# - First time we see platform, we need to load it and initialize the backlog
|
||||||
# - Component is being loaded, add to backlog
|
# - Platform is being loaded, add to backlog
|
||||||
# - Component is loaded, backlog is gone, dispatch discovery
|
# - Platform is loaded, backlog is gone, dispatch discovery
|
||||||
|
|
||||||
if component not in self._loaded_components:
|
if platform not in self._loaded_platforms:
|
||||||
hass.data[DOMAIN]["pending"][component] = [coordinator]
|
hass.data[DOMAIN]["pending"][platform] = [coordinator]
|
||||||
self._loaded_components.add(component)
|
self._loaded_platforms.add(platform)
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_forward_entry_setup(
|
hass.config_entries.async_forward_entry_setup(
|
||||||
self._config_entry, component
|
self._config_entry, platform
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
elif component in hass.data[DOMAIN]["pending"]:
|
elif platform in hass.data[DOMAIN]["pending"]:
|
||||||
hass.data[DOMAIN]["pending"][component].append(coordinator)
|
hass.data[DOMAIN]["pending"][platform].append(coordinator)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
hass,
|
hass,
|
||||||
f"{DOMAIN}.{component}",
|
f"{DOMAIN}.{platform}",
|
||||||
coordinator,
|
coordinator,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user