mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Migrate foscam to use async_update_entry to alter config entries (#110365)
This commit is contained in:
parent
e2ec23955e
commit
f5497cb0be
@ -66,8 +66,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
await async_migrate_entries(hass, entry.entry_id, update_unique_id)
|
await async_migrate_entries(hass, entry.entry_id, update_unique_id)
|
||||||
|
|
||||||
entry.unique_id = None
|
|
||||||
|
|
||||||
# Get RTSP port from the camera or use the fallback one and store it in data
|
# Get RTSP port from the camera or use the fallback one and store it in data
|
||||||
camera = FoscamCamera(
|
camera = FoscamCamera(
|
||||||
entry.data[CONF_HOST],
|
entry.data[CONF_HOST],
|
||||||
@ -85,12 +83,12 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
rtsp_port = response.get("rtspPort") or response.get("mediaPort")
|
rtsp_port = response.get("rtspPort") or response.get("mediaPort")
|
||||||
|
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
entry, data={**entry.data, CONF_RTSP_PORT: rtsp_port}
|
entry,
|
||||||
|
data={**entry.data, CONF_RTSP_PORT: rtsp_port},
|
||||||
|
version=2,
|
||||||
|
unique_id=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Change entry version
|
|
||||||
entry.version = 2
|
|
||||||
|
|
||||||
LOGGER.info("Migration to version %s successful", entry.version)
|
LOGGER.info("Migration to version %s successful", entry.version)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user