Publish entity_category for diagnostic properties - #325
Merged
Conversation
The tag from theengs/decoder#705 is metadata rather than a reading, so it follows "track": kept for discovery, dropped from the published copy. ADVANCED_DATA won't work, as it's stripped before discovery runs.
Battery, voltage, packet counters and transmit power describe the device rather than what it measures, and should properly be marked as diagnostic in HA. Battery and voltage are left alone on devices where those are the primary purpose - based on the "bvpp" decoder flag. Both lists also cover the various aliases each property has in the library.
Defaults to 0, so nothing changes until it is enabled.
jcsanyi
force-pushed
the
discovery-diagnostic
branch
from
August 15, 2026 15:04
e44158c to
1b13648
Compare
This was referenced Aug 15, 2026
jcsanyi
marked this pull request as draft
August 16, 2026 16:12
jcsanyi
marked this pull request as ready for review
August 16, 2026 16:12
Member
|
Thanks |
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.
Description
Home Assistant lets an entity be marked
diagnostic, which moves it out of the device's main sensor list into a separate section. Nothing the gateway publishes uses it today, so a device's battery percentage and packet counter sit alongside its temperature as equally prominent readings. This adds a-Dd/--discovery_diagnosticoption (default 0) which marks the diagnostic ones withent_cat.Follows from decoder discussion #703 and the
bvpptag bit added in decoder #705. Per the design settled there, the decoder says only which devices treat battery or voltage as their primary reading; all the per-property judgment lives here.What gets marked diagnostic
Two lists in
discovery.py, 16 keys covering 120 (model, entity) pairs:packet,packet_1,packet_2,rssi,tx,txpower.bvpp:batt,batt_case,batt_l,batt_low,batt_r,charging_case,charging_l,charging_r,lowbatt,volt.The bvpp payload strip
The first commit is separate from the feature and allows us to include the decoder's new
bvppflag without it leaking through to the non-advdata JSON payload. Copies how we deal with thetrackflag, which we need for discovery, but gets stripped for the published copy.Open Question - default config
I defaulted the config to
0for now - meaning no existing devices or entities see any changes unless this is explicitly turned on. Worth considering whether that's the right call, or if we want to default to1to help nudge towards the standard.Related Releases
This doesn't include the rssi work in Add RSSI sensor to Home Assistant discovery #323 butrssiis included in the list of diagnostic sensors so it'll be properly flagged once that is merged.bvppis in3da3902, which is untagged - the latest release is 2.3.0 andsetup.pypinstheengsdecoder>=2.3.0. Until a release carries the tag, no device setsbvpp, so BM2/BM6 (and similar) devices get their battery and voltage marked diagnostic like everything else. Recommend waiting for a decoder release and bumping the pin before merging this - or at least before releasing it.Testing
I built a capture harness that records every discovery topic and payload the gateway publishes for a set of decoded devices, and ran it over 20 models - the multi-property and edge-case ones, one device per alias key, and two
bvppdevices.developmentacross 120 topics and 194 publishes.bvppinjected: the battery-family entities loseent_cat, and the always-diagnostic keys keep it.publish_advdatasettings.Also running live against my own broker and HA with three BLE sensors (a LYWSD03MMC and two SwitchBot outdoor meters), which covers the
batt/voltpath. Thebvppsuppression couldn't be tested here though, since I don't have any bvpp devices.mypy clean, ruff at the
developmentbaseline at every commit, vale passes.Note that existing entities only move to/from the diagnostic section in HA once the MQTT integration is reloaded - republishing the discovery config to MQTT isn't enough. There's a
use.mdnote covering it.Checklist: