From f81b6d61b9f470e3b014b82adb4457d1b0a9b429 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Mon, 14 Feb 2022 17:01:15 -0500 Subject: [PATCH] Create unique_id for sleepiq sensors (#65227) --- homeassistant/components/sleepiq/__init__.py | 5 +++++ homeassistant/components/sleepiq/binary_sensor.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sleepiq/__init__.py b/homeassistant/components/sleepiq/__init__.py index 60614fcf97f..f6ba5a0393f 100644 --- a/homeassistant/components/sleepiq/__init__.py +++ b/homeassistant/components/sleepiq/__init__.py @@ -99,6 +99,11 @@ class SleepIQSensor(Entity): self.bed.name, self.side.sleeper.first_name, self._name ) + @property + def unique_id(self): + """Return a unique ID for the bed.""" + return f"{self._bed_id}-{self._side}-{self.type}" + def update(self): """Get the latest data from SleepIQ and updates the states.""" # Call the API for new sleepiq data. Each sensor will re-trigger this diff --git a/homeassistant/components/sleepiq/binary_sensor.py b/homeassistant/components/sleepiq/binary_sensor.py index f901851c0b5..f821a569254 100644 --- a/homeassistant/components/sleepiq/binary_sensor.py +++ b/homeassistant/components/sleepiq/binary_sensor.py @@ -41,7 +41,8 @@ class IsInBedBinarySensor(SleepIQSensor, BinarySensorEntity): """Initialize the sensor.""" super().__init__(sleepiq_data, bed_id, side) self._state = None - self._name = SENSOR_TYPES[IS_IN_BED] + self.type = IS_IN_BED + self._name = SENSOR_TYPES[self.type] self.update() @property