Skip to content

Add occupancy binary_sensor for presence detectors (BWM)#86

Merged
ernetas merged 1 commit into
mainfrom
feat/presence-binary-sensor
Jun 27, 2026
Merged

Add occupancy binary_sensor for presence detectors (BWM)#86
ernetas merged 1 commit into
mainfrom
feat/presence-binary-sensor

Conversation

@ernetas

@ernetas ernetas commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

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 this because Measurement/quantity are 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 any quantity datapoint whose label denotes presence and exposes 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.pyis_presence_quantity() is the single split point (matches presence/occupancy/motion; deliberately not Present Illuminance).
  • sensor.py — skips presence quantities so the two platforms never double-expose the same datapoint.
  • __init__.py — registers Platform.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) over MOTION (instantaneous pulses).

Validation

  • 142 tests pass (2 new for is_presence_quantity); ruff check/format clean; mypy clean.
  • Simulated against the real diagnostics data: 3 new occupancy binary sensors discovered, the 3 illuminance sensors preserved, no overlap.

🤖 Generated with Claude Code

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>
@ernetas ernetas merged commit 23dd4e9 into main Jun 27, 2026
4 checks passed
@ernetas ernetas deleted the feat/presence-binary-sensor branch June 27, 2026 11:13
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.

1 participant