Skip to content

Commit

Permalink
Support ppb and ppm for VOC reporting in Home Assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
agoode committed Jun 2, 2024
1 parent 8b4f753 commit 77b6489
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,15 @@ export default class HomeAssistant extends Extension {
delete discoveryEntry.discovery_payload.device_class;
}

// Home Assistant only supports µg/m³, not other units like ppb.
// Home Assistant uses a different voc device_class for µg/m³ versus ppb or ppm.
// https://github.com/Koenkk/zigbee2mqtt/issues/16057
if (firstExpose.name === 'voc' && discoveryEntry.discovery_payload.unit_of_measurement !== 'µg/m³') {
delete discoveryEntry.discovery_payload.device_class;
if (discoveryEntry.discovery_payload.unit_of_measurement === 'ppb' ||
discoveryEntry.discovery_payload.unit_of_measurement === 'ppm') {
discoveryEntry.discovery_payload.device_class = 'volatile_organic_compounds_parts';
} else {
delete discoveryEntry.discovery_payload.device_class;
}
}

// entity_category config is not allowed for sensors
Expand Down

0 comments on commit 77b6489

Please sign in to comment.