Skip to content

Fix carbon monoxide IAS zone device class mapping#713

Merged
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/ias_zone_mappings
Mar 23, 2026
Merged

Fix carbon monoxide IAS zone device class mapping#713
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/ias_zone_mappings

Conversation

@TheJulianJES
Copy link
Copy Markdown
Contributor

@TheJulianJES TheJulianJES commented Mar 20, 2026

Proposed change

This changes the device class for the IasZone.ZoneType.Carbon_Monoxide_Sensor from BinarySensorDeviceClass.GAS to CO. This is needed for the Frient US smoke sensor

Additional information

  • For some reason, this device has zone_type 0x0227, which is not mapped. The quirk will change it using _CONSTANT_ATTRIBUTES, as ZHA unsets the device class if zone_type is set, but doesn't contain a known value.
  • There's also an issue where change_entity_metadata takes a str for new_device_class, not the actual StrEnum member for BinarySensorDeviceClass. See: Change Third Reality soil moisture sensor device class 3RSM0147Z zha-device-handlers#3780 (comment)
  • But as we now use _CONSTANT_ATTRIBUTES for this due to the two issues mentioned above, both ZHA issues can be addressed later.
  • The Frient US smoke sensor is already part of the diagnostics, but as the quirk is not present yet, its diagnostics don't yet change.

@TheJulianJES TheJulianJES force-pushed the tjj/ias_zone_mappings branch from c65f47c to c7195ef Compare March 20, 2026 01:55
@TheJulianJES TheJulianJES marked this pull request as ready for review March 20, 2026 01:56
Copilot AI review requested due to automatic review settings March 20, 2026 01:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ZHA’s IAS Zone binary sensor device class mapping so Zigbee Carbon Monoxide zone types are represented as carbon_monoxide rather than generic gas, aligning entity metadata and diagnostics with the correct Home Assistant device class.

Changes:

  • Map IasZone.ZoneType.Carbon_Monoxide_Sensor to BinarySensorDeviceClass.CO instead of GAS.
  • Update affected device diagnostics fixtures to expect device_class: "carbon_monoxide".

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
zha/application/platforms/binary_sensor/const.py Corrects IAS Zone → HA binary sensor device class mapping for Carbon Monoxide.
tests/data/devices/tze284-rjxqso4a-ts0601.json Updates expected diagnostics device_class from gas to carbon_monoxide.
tests/data/devices/tze200-hr0tdd47-ts0601.json Updates expected diagnostics device_class from gas to carbon_monoxide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.62%. Comparing base (23eef76) to head (c7195ef).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #713   +/-   ##
=======================================
  Coverage   97.62%   97.62%           
=======================================
  Files          62       62           
  Lines       10954    10954           
=======================================
  Hits        10694    10694           
  Misses        260      260           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheJulianJES TheJulianJES merged commit 28f1515 into zigpy:dev Mar 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants