Add occupancy binary_sensor for presence detectors (BWM)#86
Merged
Conversation
JUNG presence/motion detectors (Measurement "BWM" functions) report detection as a `quantity` datapoint with an empty unit and a 0/1 value (label "Presence Detected"). sensor.py only surfaces quantities that have a unit, so presence — the whole point of a motion sensor — was silently dropped. The diagnostics "unhandled types" check can't catch it because Measurement/quantity are both already handled types; it's only visible in the raw WebSocket frames. Surface presence as an occupancy binary_sensor: - binary_sensor.py: discover any `quantity` datapoint whose label denotes presence and expose it as BinarySensorDeviceClass.OCCUPANCY. on when the value is non-zero; None for a non-finite value (a bare `NaN != 0` is misleadingly truthy, so it's guarded). - const.py: is_presence_quantity() is the single split point (matches presence/occupancy/motion; not "Present Illuminance"). - sensor.py: skip presence quantities so the two platforms never double-expose the same datapoint. - __init__.py: register Platform.BINARY_SENSOR. - CLAUDE.md + tests updated; bump manifest to 1.2.2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
JUNG presence/motion detectors (
Measurement"BWM" functions) report detection as aquantitydatapoint with an empty unit and a0/1value (labelPresence Detected).sensor.pyonly surfaces quantities that have a unit, so presence — the whole point of a motion sensor — was silently dropped. The diagnostics "unhandled types" check can't catch this becauseMeasurement/quantityare both already-handled types; it was only visible in the raw WebSocket frames (spotted in a shared diagnostics dump).Changes
binary_sensor.py(new) — discovers anyquantitydatapoint whose label denotes presence and exposes it asBinarySensorDeviceClass.OCCUPANCY.onwhen the value is non-zero;Nonefor a non-finite value (a bareNaN != 0is misleadingly truthy, so it's guarded).const.py—is_presence_quantity()is the single split point (matchespresence/occupancy/motion; deliberately notPresent Illuminance).sensor.py— skips presence quantities so the two platforms never double-expose the same datapoint.__init__.py— registersPlatform.BINARY_SENSOR.CLAUDE.md+ tests updated; bump manifest to 1.2.2.Device-class note: chose
OCCUPANCY(label is "Presence Detected"; these hold state while occupied) overMOTION(instantaneous pulses).Validation
is_presence_quantity);ruff check/formatclean;mypyclean.🤖 Generated with Claude Code