diff --git a/homeassistant/components/blebox/sensor.py b/homeassistant/components/blebox/sensor.py index 82c9bb876d7..dbdf034faee 100644 --- a/homeassistant/components/blebox/sensor.py +++ b/homeassistant/components/blebox/sensor.py @@ -7,10 +7,14 @@ from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + PERCENTAGE, + UnitOfEnergy, + UnitOfSpeed, UnitOfTemperature, ) from homeassistant.core import HomeAssistant @@ -40,6 +44,22 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), + SensorEntityDescription( + key="powerMeasurement", + device_class=SensorDeviceClass.ENERGY, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + state_class=SensorStateClass.TOTAL, + ), + SensorEntityDescription( + key="humidity", + device_class=SensorDeviceClass.HUMIDITY, + native_unit_of_measurement=PERCENTAGE, + ), + SensorEntityDescription( + key="wind_speed", + device_class=SensorDeviceClass.WIND_SPEED, + native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND, + ), ) @@ -75,3 +95,10 @@ class BleBoxSensorEntity(BleBoxEntity[blebox_uniapi.sensor.BaseSensor], SensorEn def native_value(self): """Return the state.""" return self._feature.native_value + + @property + def last_reset(self): + """Return the time when the sensor was last reset, if implemented.""" + native_implementation = getattr(self._feature, "last_reset", None) + + return native_implementation or super().last_reset diff --git a/tests/components/blebox/conftest.py b/tests/components/blebox/conftest.py index 4bda47bb414..82698633c30 100644 --- a/tests/components/blebox/conftest.py +++ b/tests/components/blebox/conftest.py @@ -37,14 +37,14 @@ def setup_product_mock(category, feature_mocks, path=None): return product_mock -def mock_only_feature(spec, **kwargs): +def mock_only_feature(spec, set_spec: bool = True, **kwargs): """Mock just the feature, without the product setup.""" - return mock.create_autospec(spec, True, True, **kwargs) + return mock.create_autospec(spec, set_spec, True, **kwargs) -def mock_feature(category, spec, **kwargs): +def mock_feature(category, spec, set_spec: bool = True, **kwargs): """Mock a feature along with whole product setup.""" - feature_mock = mock_only_feature(spec, **kwargs) + feature_mock = mock_only_feature(spec, set_spec, **kwargs) feature_mock.async_update = AsyncMock() product = setup_product_mock(category, [feature_mock])