From dc7e5e3af48cfc34757bce17ae915ab1cecd95d2 Mon Sep 17 00:00:00 2001 From: Daniel Shokouhi Date: Tue, 16 Oct 2018 01:06:00 -0700 Subject: [PATCH] Add unique_id for Ring (#17497) --- homeassistant/components/binary_sensor/ring.py | 6 ++++++ homeassistant/components/camera/ring.py | 5 +++++ homeassistant/components/sensor/ring.py | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/homeassistant/components/binary_sensor/ring.py b/homeassistant/components/binary_sensor/ring.py index 3945eb5c926..5a65917f40b 100644 --- a/homeassistant/components/binary_sensor/ring.py +++ b/homeassistant/components/binary_sensor/ring.py @@ -73,6 +73,7 @@ class RingBinarySensor(BinarySensorDevice): SENSOR_TYPES.get(self._sensor_type)[0]) self._device_class = SENSOR_TYPES.get(self._sensor_type)[2] self._state = None + self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type) @property def name(self): @@ -89,6 +90,11 @@ class RingBinarySensor(BinarySensorDevice): """Return the class of the binary sensor.""" return self._device_class + @property + def unique_id(self): + """Return a unique ID.""" + return self._unique_id + @property def device_state_attributes(self): """Return the state attributes.""" diff --git a/homeassistant/components/camera/ring.py b/homeassistant/components/camera/ring.py index ae886bd0669..eafb3066e48 100644 --- a/homeassistant/components/camera/ring.py +++ b/homeassistant/components/camera/ring.py @@ -97,6 +97,11 @@ class RingCam(Camera): """Return the name of this camera.""" return self._name + @property + def unique_id(self): + """Return a unique ID.""" + return self._camera.id + @property def device_state_attributes(self): """Return the state attributes.""" diff --git a/homeassistant/components/sensor/ring.py b/homeassistant/components/sensor/ring.py index 408971c60e1..92c033241e0 100644 --- a/homeassistant/components/sensor/ring.py +++ b/homeassistant/components/sensor/ring.py @@ -100,6 +100,7 @@ class RingSensor(Entity): self._data.name, SENSOR_TYPES.get(self._sensor_type)[0]) self._state = STATE_UNKNOWN self._tz = str(hass.config.time_zone) + self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type) @property def name(self): @@ -111,6 +112,11 @@ class RingSensor(Entity): """Return the state of the sensor.""" return self._state + @property + def unique_id(self): + """Return a unique ID.""" + return self._unique_id + @property def device_state_attributes(self): """Return the state attributes."""