Fix point calls config entry to a platform multiple times (#126535)
* fix multiple async_forward_entry_setups calls * ensure entity is at the right place
This commit is contained in:
parent
788d9571b5
commit
88c751df7a
2 changed files with 13 additions and 15 deletions
|
@ -136,7 +136,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: PointConfigEntry) -> boo
|
||||||
entry.runtime_data = PointData(client)
|
entry.runtime_data = PointData(client)
|
||||||
|
|
||||||
await async_setup_webhook(hass, entry, point_session)
|
await async_setup_webhook(hass, entry, point_session)
|
||||||
# Entries are added in the client.update() function.
|
await hass.config_entries.async_forward_entry_setups(
|
||||||
|
entry, [*PLATFORMS, Platform.ALARM_CONTROL_PANEL]
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -225,27 +227,23 @@ class MinutPointClient:
|
||||||
async_dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY)
|
async_dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY)
|
||||||
return
|
return
|
||||||
|
|
||||||
async def new_device(device_id, platform):
|
|
||||||
"""Load new device."""
|
|
||||||
async_dispatcher_send(
|
|
||||||
self._hass, POINT_DISCOVERY_NEW.format(platform, DOMAIN), device_id
|
|
||||||
)
|
|
||||||
|
|
||||||
self._is_available = True
|
self._is_available = True
|
||||||
for home_id in self._client.homes:
|
for home_id in self._client.homes:
|
||||||
if home_id not in self._known_homes:
|
if home_id not in self._known_homes:
|
||||||
await self._hass.config_entries.async_forward_entry_setups(
|
async_dispatcher_send(
|
||||||
self._config_entry, [Platform.ALARM_CONTROL_PANEL]
|
self._hass,
|
||||||
|
POINT_DISCOVERY_NEW.format(Platform.ALARM_CONTROL_PANEL),
|
||||||
|
home_id,
|
||||||
)
|
)
|
||||||
await new_device(home_id, "alarm_control_panel")
|
|
||||||
self._known_homes.add(home_id)
|
self._known_homes.add(home_id)
|
||||||
for device in self._client.devices:
|
for device in self._client.devices:
|
||||||
if device.device_id not in self._known_devices:
|
if device.device_id not in self._known_devices:
|
||||||
await self._hass.config_entries.async_forward_entry_setups(
|
|
||||||
self._config_entry, PLATFORMS
|
|
||||||
)
|
|
||||||
for platform in PLATFORMS:
|
for platform in PLATFORMS:
|
||||||
await new_device(device.device_id, platform)
|
async_dispatcher_send(
|
||||||
|
self._hass,
|
||||||
|
POINT_DISCOVERY_NEW.format(platform),
|
||||||
|
device.device_id,
|
||||||
|
)
|
||||||
self._known_devices.add(device.device_id)
|
self._known_devices.add(device.device_id)
|
||||||
async_dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY)
|
async_dispatcher_send(self._hass, SIGNAL_UPDATE_ENTITY)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ EVENT_RECEIVED = "point_webhook_received"
|
||||||
SIGNAL_UPDATE_ENTITY = "point_update"
|
SIGNAL_UPDATE_ENTITY = "point_update"
|
||||||
SIGNAL_WEBHOOK = "point_webhook"
|
SIGNAL_WEBHOOK = "point_webhook"
|
||||||
|
|
||||||
POINT_DISCOVERY_NEW = "point_new_{}_{}"
|
POINT_DISCOVERY_NEW = "point_new_{}"
|
||||||
|
|
||||||
OAUTH2_AUTHORIZE = "https://api.minut.com/v8/oauth/authorize"
|
OAUTH2_AUTHORIZE = "https://api.minut.com/v8/oauth/authorize"
|
||||||
OAUTH2_TOKEN = "https://api.minut.com/v8/oauth/token"
|
OAUTH2_TOKEN = "https://api.minut.com/v8/oauth/token"
|
||||||
|
|
Loading…
Add table
Reference in a new issue