mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Remove Amcrest camera unique id migration (#113870)
This commit is contained in:
parent
ac008a4c6d
commit
d2663347e9
@ -13,15 +13,11 @@ from amcrest import AmcrestError
|
|||||||
from haffmpeg.camera import CameraMjpeg
|
from haffmpeg.camera import CameraMjpeg
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.camera import (
|
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||||
DOMAIN as CAMERA_DOMAIN,
|
|
||||||
Camera,
|
|
||||||
CameraEntityFeature,
|
|
||||||
)
|
|
||||||
from homeassistant.components.ffmpeg import FFmpegManager, get_ffmpeg_manager
|
from homeassistant.components.ffmpeg import FFmpegManager, get_ffmpeg_manager
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_NAME, STATE_OFF, STATE_ON
|
from homeassistant.const import ATTR_ENTITY_ID, CONF_NAME, STATE_OFF, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import (
|
from homeassistant.helpers.aiohttp_client import (
|
||||||
async_aiohttp_proxy_stream,
|
async_aiohttp_proxy_stream,
|
||||||
async_aiohttp_proxy_web,
|
async_aiohttp_proxy_web,
|
||||||
@ -37,7 +33,6 @@ from .const import (
|
|||||||
COMM_TIMEOUT,
|
COMM_TIMEOUT,
|
||||||
DATA_AMCREST,
|
DATA_AMCREST,
|
||||||
DEVICES,
|
DEVICES,
|
||||||
DOMAIN,
|
|
||||||
RESOLUTION_TO_STREAM,
|
RESOLUTION_TO_STREAM,
|
||||||
SERVICE_UPDATE,
|
SERVICE_UPDATE,
|
||||||
SNAPSHOT_TIMEOUT,
|
SNAPSHOT_TIMEOUT,
|
||||||
@ -141,18 +136,6 @@ async def async_setup_platform(
|
|||||||
device = hass.data[DATA_AMCREST][DEVICES][name]
|
device = hass.data[DATA_AMCREST][DEVICES][name]
|
||||||
entity = AmcrestCam(name, device, get_ffmpeg_manager(hass))
|
entity = AmcrestCam(name, device, get_ffmpeg_manager(hass))
|
||||||
|
|
||||||
# 2021.9.0 introduced unique id's for the camera entity, but these were not
|
|
||||||
# unique for different resolution streams. If any cameras were configured
|
|
||||||
# with this version, update the old entity with the new unique id.
|
|
||||||
serial_number = await device.api.async_serial_number
|
|
||||||
serial_number = serial_number.strip()
|
|
||||||
registry = er.async_get(hass)
|
|
||||||
entity_id = registry.async_get_entity_id(CAMERA_DOMAIN, DOMAIN, serial_number)
|
|
||||||
if entity_id is not None:
|
|
||||||
_LOGGER.debug("Updating unique id for camera %s", entity_id)
|
|
||||||
new_unique_id = f"{serial_number}-{device.resolution}-{device.channel}"
|
|
||||||
registry.async_update_entity(entity_id, new_unique_id=new_unique_id)
|
|
||||||
|
|
||||||
async_add_entities([entity], True)
|
async_add_entities([entity], True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user