Make gardena closing sensor unavailable when closed (#98133)

pull/97830/head^2
Joakim Plate 2023-08-11 13:07:45 +02:00 committed by GitHub
parent a0ac8ba5a6
commit 990ec1d445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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]