components/gardena_bluetooth: Improve avaliability reliability (#113056)

* components/gardena_bluetooth: Improve avaliability reliability

The available() function incorrectly returns false even though the device
is accessible.

The last_update_success property should correctly indicate if the device
isn't contactable, so we don't need to call async_address_present().
This is confirmed by seeing that no other users are calling
async_address_present() in the available() function.

This commit removes the call to async_address_present() to help fix the
sensor being unavailable when using a ESPHome BLE proxy.

Signed-off-by: Alistair Francis <alistair@alistair23.me>

---------

Signed-off-by: Alistair Francis <alistair@alistair23.me>
Co-authored-by: Joakim Plate <elupus@ecce.se>
This commit is contained in:
Alistair Francis 2024-03-12 03:58:43 +10:00 committed by GitHub
parent c75342bd9a
commit 1853c2d73a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,6 @@ from gardena_bluetooth.exceptions import (
)
from gardena_bluetooth.parse import Characteristic, CharacteristicType
from homeassistant.components import bluetooth
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import DeviceInfo
@ -118,13 +117,7 @@ class GardenaBluetoothEntity(CoordinatorEntity[Coordinator]):
@property
def available(self) -> bool:
"""Return if entity is available."""
return (
self.coordinator.last_update_success
and bluetooth.async_address_present(
self.hass, self.coordinator.address, True
)
and self._attr_available
)
return self.coordinator.last_update_success and self._attr_available
class GardenaBluetoothDescriptorEntity(GardenaBluetoothEntity):