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
1 changed files with 15 additions and 13 deletions
|
@ -32,7 +32,7 @@ WEMO_MODEL_DISPATCH = {
|
|||
"CoffeeMaker": [Platform.SWITCH],
|
||||
"Dimmer": [Platform.LIGHT],
|
||||
"Humidifier": [Platform.FAN],
|
||||
"Insight": [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH],
|
||||
"Insight": [Platform.BINARY_SENSOR, Platform.SWITCH],
|
||||
"LightSwitch": [Platform.SWITCH],
|
||||
"Maker": [Platform.BINARY_SENSOR, Platform.SWITCH],
|
||||
"Motion": [Platform.BINARY_SENSOR],
|
||||
|
@ -141,7 +141,7 @@ class WemoDispatcher:
|
|||
"""Initialize the WemoDispatcher."""
|
||||
self._config_entry = config_entry
|
||||
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(
|
||||
self, hass: HomeAssistant, wemo: pywemo.WeMoDevice
|
||||
|
@ -151,28 +151,30 @@ class WemoDispatcher:
|
|||
return
|
||||
|
||||
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:
|
||||
# - First time we see component, we need to load it and initialize the backlog
|
||||
# - Component is being loaded, add to backlog
|
||||
# - Component is loaded, backlog is gone, dispatch discovery
|
||||
# - First time we see platform, we need to load it and initialize the backlog
|
||||
# - Platform is being loaded, add to backlog
|
||||
# - Platform is loaded, backlog is gone, dispatch discovery
|
||||
|
||||
if component not in self._loaded_components:
|
||||
hass.data[DOMAIN]["pending"][component] = [coordinator]
|
||||
self._loaded_components.add(component)
|
||||
if platform not in self._loaded_platforms:
|
||||
hass.data[DOMAIN]["pending"][platform] = [coordinator]
|
||||
self._loaded_platforms.add(platform)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(
|
||||
self._config_entry, component
|
||||
self._config_entry, platform
|
||||
)
|
||||
)
|
||||
|
||||
elif component in hass.data[DOMAIN]["pending"]:
|
||||
hass.data[DOMAIN]["pending"][component].append(coordinator)
|
||||
elif platform in hass.data[DOMAIN]["pending"]:
|
||||
hass.data[DOMAIN]["pending"][platform].append(coordinator)
|
||||
|
||||
else:
|
||||
async_dispatcher_send(
|
||||
hass,
|
||||
f"{DOMAIN}.{component}",
|
||||
f"{DOMAIN}.{platform}",
|
||||
coordinator,
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue