Closed ColinRobbins closed 1 month ago
This maybe an issue because as far as i can see all VolkswagenIDSensor
and VolkswagenIDVehicleSensor
are initialsed with SensorStateClass.MEASUREMENT
if the sensor itself has declared an native_unit_of_measurement
which is not possible if the sensor is of device_class=SensorDeviceClass.ENERGY
fix maybe skipping device_class=SensorDeviceClass.ENERGY
from initialising with SensorStateClass.MEASUREMENT
but with state_class=SensorStateClass.TOTAL
okay this would work as a workaround until a more generic fix would be available otherwise this is very specific to this one code path, thoughts @mitch-dc or @pdcastro?
--- a/custom_components/volkswagen_we_connect_id/sensor.py
+++ b/custom_components/volkswagen_we_connect_id/sensor.py
@@ -430,8 +430,8 @@ VEHICLE_SENSORS: tuple[VolkswagenIdEntityDescription, ...] = (
VolkswagenIdEntityDescription(
key="lastTripAverageElectricConsumption",
name="Last Trip Average Electric consumption",
- native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
+ state_class=SensorStateClass.TOTAL,
value=lambda vehicle: vehicle.trips["shortTerm"].averageElectricConsumption.value,
),
I can make an MR if you think this would be sufficient.
Not seeing the issue now, so assuming fixed.
Version of the custom_component
Installation method (hacs / manual)
HACS
Installation method of hass (venv, docker, hassio,...)
Hassio
Describe the bug
VolkswagenIDVehicleSensor has the wrong class.
Debug log