Address late review of VeSync (#63945)
* Fast follow improvements to VeSync * Apply suggestions to other platforms, use async_on_unload * Rename dev_list to entities
This commit is contained in:
parent
0922627612
commit
f43c4d51e1
6 changed files with 49 additions and 52 deletions
|
@ -14,7 +14,6 @@ from .const import (
|
|||
DOMAIN,
|
||||
SERVICE_UPDATE_DEVS,
|
||||
VS_DISCOVERY,
|
||||
VS_DISPATCHERS,
|
||||
VS_FANS,
|
||||
VS_LIGHTS,
|
||||
VS_MANAGER,
|
||||
|
@ -56,8 +55,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
lights = hass.data[DOMAIN][VS_LIGHTS] = []
|
||||
sensors = hass.data[DOMAIN][VS_SENSORS] = []
|
||||
|
||||
hass.data[DOMAIN][VS_DISPATCHERS] = []
|
||||
|
||||
if device_dict[VS_SWITCHES]:
|
||||
switches.extend(device_dict[VS_SWITCHES])
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.SWITCH))
|
||||
|
@ -96,7 +93,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
return
|
||||
if new_switches and not switches:
|
||||
switches.extend(new_switches)
|
||||
hass.async_create_task(forward_setup(config_entry, "switch"))
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.SWITCH))
|
||||
|
||||
fan_set = set(fan_devs)
|
||||
new_fans = list(fan_set.difference(fans))
|
||||
|
@ -106,7 +103,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
return
|
||||
if new_fans and not fans:
|
||||
fans.extend(new_fans)
|
||||
hass.async_create_task(forward_setup(config_entry, "fan"))
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.FAN))
|
||||
|
||||
light_set = set(light_devs)
|
||||
new_lights = list(light_set.difference(lights))
|
||||
|
@ -116,7 +113,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
return
|
||||
if new_lights and not lights:
|
||||
lights.extend(new_lights)
|
||||
hass.async_create_task(forward_setup(config_entry, "light"))
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.LIGHT))
|
||||
|
||||
sensor_set = set(sensor_devs)
|
||||
new_sensors = list(sensor_set.difference(sensors))
|
||||
|
@ -126,7 +123,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
return
|
||||
if new_sensors and not sensors:
|
||||
sensors.extend(new_sensors)
|
||||
hass.async_create_task(forward_setup(config_entry, "sensor"))
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.SENSOR))
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_UPDATE_DEVS, async_new_device_discovery
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue