Make gardena closing sensor unavailable when closed (#98133)

This commit is contained in:
Joakim Plate 2023-08-11 13:07:45 +02:00 committed by Franck Nijhof
parent b584eb757b
commit 32d4c2607b
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 6 additions and 1 deletions

View File

@ -117,3 +117,8 @@ class GardenaBluetoothRemainSensor(GardenaBluetoothEntity, SensorEntity):
self._attr_native_value = time
super()._handle_coordinator_update()
return
@property
def available(self) -> bool:
"""Sensor only available when open."""
return super().available and self._attr_native_value is not None

View File

@ -35,7 +35,7 @@
'entity_id': 'sensor.mock_title_valve_closing',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'state': 'unavailable',
})
# ---
# name: test_setup[98bd2a19-0b0e-421a-84e5-ddbf75dc6de4-raw0-sensor.mock_title_battery]