Skip to content

Commit 124b1eb

Browse files
committed
Support ppb and ppm for VOC reporting in Home Assistant
See home-assistant/core#92973.
1 parent 8b4f753 commit 124b1eb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/extension/homeassistant.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,15 @@ export default class HomeAssistant extends Extension {
908908
delete discoveryEntry.discovery_payload.device_class;
909909
}
910910

911-
// Home Assistant only supports µg/m³, not other units like ppb.
911+
// Home Assistant uses a different voc device_class for µg/m³ versus ppb or ppm.
912912
// https://github.com/Koenkk/zigbee2mqtt/issues/16057
913913
if (firstExpose.name === 'voc' && discoveryEntry.discovery_payload.unit_of_measurement !== 'µg/m³') {
914-
delete discoveryEntry.discovery_payload.device_class;
914+
if (discoveryEntry.discovery_payload.unit_of_measurement === 'ppb' ||
915+
discoveryEntry.discovery_payload.unit_of_measurement === 'ppm') {
916+
discoverEntry.discovery_payload.device_class = 'volatile_organic_compounds_parts';
917+
} else {
918+
delete discoveryEntry.discovery_payload.device_class;
919+
}
915920
}
916921

917922
// entity_category config is not allowed for sensors

0 commit comments

Comments
 (0)