diff --git a/homeassistant/components/govee_ble/coordinator.py b/homeassistant/components/govee_ble/coordinator.py index 0d0ff5f93bd..011a89e565b 100644 --- a/homeassistant/components/govee_ble/coordinator.py +++ b/homeassistant/components/govee_ble/coordinator.py @@ -10,6 +10,7 @@ from homeassistant.components.bluetooth import ( BluetoothServiceInfoBleak, ) from homeassistant.components.bluetooth.passive_update_processor import ( + PassiveBluetoothDataProcessor, PassiveBluetoothProcessorCoordinator, ) from homeassistant.config_entries import ConfigEntry @@ -77,3 +78,11 @@ class GoveeBLEBluetoothProcessorCoordinator( def set_model_info(self, device_type: str) -> None: """Set the model info.""" self.model_info = get_model_info(device_type) + + +class GoveeBLEPassiveBluetoothDataProcessor[_T]( + PassiveBluetoothDataProcessor[_T, SensorUpdate] +): + """Define a govee-ble Bluetooth Passive Update Data Processor.""" + + coordinator: GoveeBLEBluetoothProcessorCoordinator diff --git a/homeassistant/components/govee_ble/sensor.py b/homeassistant/components/govee_ble/sensor.py index a0102cf629e..8c9812249a3 100644 --- a/homeassistant/components/govee_ble/sensor.py +++ b/homeassistant/components/govee_ble/sensor.py @@ -27,7 +27,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.sensor import sensor_device_info_to_hass_device_info -from .coordinator import GoveeBLEConfigEntry +from .coordinator import GoveeBLEConfigEntry, GoveeBLEPassiveBluetoothDataProcessor SENSOR_DESCRIPTIONS = { (DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription( @@ -130,12 +130,15 @@ class GoveeBluetoothSensorEntity( ): """Representation of a govee ble sensor.""" + processor: GoveeBLEPassiveBluetoothDataProcessor + @property def available(self) -> bool: """Return False if sensor is in error.""" - return ( - self.processor.entity_data.get(self.entity_key) != ERROR - and super().available + coordinator = self.processor.coordinator + return self.processor.entity_data.get(self.entity_key) != ERROR and ( + ((model_info := coordinator.model_info) and model_info.sleepy) + or super().available ) @property