Fix air quality telemetry propagation and sensor labels#156
Open
isdennu wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes two related issues around Meshtastic air quality metrics in Home Assistant:
air_quality_metricspackets were decoded by the integration, but never forwarded through the API/coordinator event pipeline, so the coordinator never stored them underairQualityMetrics.Problem
I reproduced this with a node returning valid
airQualityMetricsover the HA TCP proxy. Direct requests and proxy requests both returned correct payloads, but Home Assistant did not surface the air quality values correctly.Observed behavior before this patch:
air_quality_metricsresponses were received, but HA did not update coordinator state for them.pm10Standard/pm10Environmentalwere presented like PM10 even though Meshtastic maps those fields to PM1.0.gasResistancewas exposed ashPaeven though the protobuf describes it asMOhm.particles*counters were exposed asμg/m³, even though they are particle counts, not mass concentration.Root cause
MeshtasticApiClient._on_telemetry()handled:deviceMetricslocalStatsenvironmentMetricspowerMetricsbut not
airQualityMetrics.MeshtasticDataUpdateCoordinator._api_telemetry()also did not recognize anair_quality_metricsevent type, so even if the event existed it would have been dropped as unsupported.Separately, the air quality/environment sensor builders relied on
translation_keyonly. For metrics without a Home Assistant-generated friendly fallback, HA ended up displaying the device name or overly generic names instead of the specific metric.Changes
AIR_QUALITY_METRICStoEventMeshtasticApiTelemetryTypetelemetry["airQualityMetrics"]asEVENT_MESHTASTIC_API_TELEMETRYairQualityMetricspm10*->PM1.0 *pm25*->PM2.5 *pm100*->PM10 *gasResistanceunit fromhPatoMOhmparticles*values asparticles/dLinstead ofμg/m³Testing
Local verification performed:
python -m py_compile custom_components/meshtastic/api.py custom_components/meshtastic/coordinator.py custom_components/meshtastic/sensor.pygit diff --check -- custom_components/meshtastic/api.py custom_components/meshtastic/coordinator.py custom_components/meshtastic/sensor.pyI could not run
scripts/lintin this environment becauseruffis not installed locally, but the patch was kept small andpy_compile/git diff --checkpassed.Notes