Create unique_id for sleepiq sensors (#65227)

This commit is contained in:
Jarod Wilson 2022-02-14 17:01:15 -05:00 committed by GitHub
parent 74a304cac7
commit f81b6d61b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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