Skip to content

Commit fa2c4ad

Browse files
committed
Add missing device class mappings for distance, power_factor, humidity, pressure (#430, #435)
Aligns sensor.py and number.py METRIC_TYPE_TO_DEVICE_CLASS with the DEVICE_CLASS_METRIC_TYPES list in merge_topics.py. Without these mappings, units for affected metrics (e.g. km on EV odometer/range) were silently dropped.
1 parent 6939c15 commit fa2c4ad

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

custom_components/victron_mqtt/number.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
MetricType.FREQUENCY: NumberDeviceClass.FREQUENCY,
3030
MetricType.ELECTRIC_STORAGE_PERCENTAGE: NumberDeviceClass.BATTERY,
3131
MetricType.TEMPERATURE: NumberDeviceClass.TEMPERATURE,
32+
MetricType.HUMIDITY: NumberDeviceClass.HUMIDITY,
33+
MetricType.PRESSURE: NumberDeviceClass.PRESSURE,
34+
MetricType.DISTANCE: NumberDeviceClass.DISTANCE,
35+
MetricType.POWER_FACTOR: NumberDeviceClass.POWER_FACTOR,
3236
MetricType.SPEED: NumberDeviceClass.SPEED,
3337
MetricType.LIQUID_VOLUME: NumberDeviceClass.VOLUME_STORAGE,
3438
MetricType.DURATION: NumberDeviceClass.DURATION,

custom_components/victron_mqtt/sensor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
MetricType.FREQUENCY: SensorDeviceClass.FREQUENCY,
3939
MetricType.ELECTRIC_STORAGE_PERCENTAGE: SensorDeviceClass.BATTERY,
4040
MetricType.TEMPERATURE: SensorDeviceClass.TEMPERATURE,
41+
MetricType.HUMIDITY: SensorDeviceClass.HUMIDITY,
42+
MetricType.PRESSURE: SensorDeviceClass.PRESSURE,
43+
MetricType.DISTANCE: SensorDeviceClass.DISTANCE,
44+
MetricType.POWER_FACTOR: SensorDeviceClass.POWER_FACTOR,
4145
MetricType.SPEED: SensorDeviceClass.SPEED,
4246
MetricType.LIQUID_VOLUME: SensorDeviceClass.VOLUME_STORAGE,
4347
MetricType.DURATION: SensorDeviceClass.DURATION,

0 commit comments

Comments
 (0)