mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Create unique_id for sleepiq sensors (#65227)
This commit is contained in:
parent
74a304cac7
commit
f81b6d61b9
@ -99,6 +99,11 @@ class SleepIQSensor(Entity):
|
|||||||
self.bed.name, self.side.sleeper.first_name, self._name
|
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):
|
def update(self):
|
||||||
"""Get the latest data from SleepIQ and updates the states."""
|
"""Get the latest data from SleepIQ and updates the states."""
|
||||||
# Call the API for new sleepiq data. Each sensor will re-trigger this
|
# Call the API for new sleepiq data. Each sensor will re-trigger this
|
||||||
|
@ -41,7 +41,8 @@ class IsInBedBinarySensor(SleepIQSensor, BinarySensorEntity):
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(sleepiq_data, bed_id, side)
|
super().__init__(sleepiq_data, bed_id, side)
|
||||||
self._state = None
|
self._state = None
|
||||||
self._name = SENSOR_TYPES[IS_IN_BED]
|
self.type = IS_IN_BED
|
||||||
|
self._name = SENSOR_TYPES[self.type]
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user