From 1402e7ae567cd83e5b78ea09eba1f2cff83561ec Mon Sep 17 00:00:00 2001 From: Ryan Fleming Date: Sun, 10 Jan 2021 17:23:32 -0500 Subject: [PATCH] Use the camera UUID as the entity unique id (#44937) --- homeassistant/components/uvc/camera.py | 5 +++++ tests/components/uvc/test_camera.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/homeassistant/components/uvc/camera.py b/homeassistant/components/uvc/camera.py index da748c20c1c..1988350eed3 100644 --- a/homeassistant/components/uvc/camera.py +++ b/homeassistant/components/uvc/camera.py @@ -119,6 +119,11 @@ class UnifiVideoCamera(Camera): """Camera Motion Detection Status.""" return self._caminfo["recordingSettings"]["motionRecordEnabled"] + @property + def unique_id(self) -> str: + """Return a unique identifier for this client.""" + return self._uuid + @property def brand(self): """Return the brand of this camera.""" diff --git a/tests/components/uvc/test_camera.py b/tests/components/uvc/test_camera.py index 35e6c82ded6..9e904f82357 100644 --- a/tests/components/uvc/test_camera.py +++ b/tests/components/uvc/test_camera.py @@ -197,6 +197,7 @@ class TestUVC(unittest.TestCase): self.uvc = uvc.UnifiVideoCamera(self.nvr, self.uuid, self.name, self.password) self.nvr.get_camera.return_value = { "model": "UVC Fake", + "uuid": "06e3ff29-8048-31c2-8574-0852d1bd0e03", "recordingSettings": {"fullTimeRecordEnabled": True}, "host": "host-a", "internalHost": "host-b", @@ -238,6 +239,7 @@ class TestUVC(unittest.TestCase): assert "Ubiquiti" == self.uvc.brand assert "UVC Fake" == self.uvc.model assert SUPPORT_STREAM == self.uvc.supported_features + assert "uuid" == self.uvc.unique_id def test_stream(self): """Test the RTSP stream URI."""