Skip to content

Commit

Permalink
Merge pull request #11 from gilcu3/keep-values
Browse files Browse the repository at this point in the history
keep states available all the time
  • Loading branch information
chkuendig authored Dec 5, 2024
2 parents c963481 + 43d80db commit 4353bb2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions custom_components/amphiro_ble/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,20 @@ class AmphiroBluetoothSensorEntity(
def native_value(self) -> int | float | None:
"""Return the native value."""
return self.processor.entity_data.get(self.entity_key)

@property
def available(self) -> bool:
"""Return True if entity is available.
The sensor is only created when the device is seen.
Since these are sleepy devices which stop broadcasting
when not in use, we can't rely on the last update time
so once we have seen the device we always return True.
"""
return True

@property
def assumed_state(self) -> bool:
"""Return True if the device is no longer broadcasting."""
return not self.processor.available

0 comments on commit 4353bb2

Please sign in to comment.