Skip to content

Advertise uint32 format for valve duration characteristics - #203

Merged
yfre merged 1 commit into
masterfrom
fix/202-valve-duration-uint32
Oct 18, 2026
Merged

yfre merged 1 commit into
masterfrom
fix/202-valve-duration-uint32

Conversation

@yfre

@yfre yfre commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Closes #202

Problem

SetDurationCharacteristic (D3) and RemainingDurationCharacteristic (D4) extend IntegerCharacteristic, which hard-codes "format": "int". Apple's HAP spec defines both as UInt32 (seconds, 0–3600).

Change

  • IntegerCharacteristic: new protected constructor that takes the HAP format. The existing public constructor delegates to it with "int", so all other integer characteristics and any custom subclasses still advertise "int".
  • SetDurationCharacteristic and RemainingDurationCharacteristic pass "uint32". Java values stay Integer, which covers the 0–3600 range.
  • DurationCharacteristicFormatTest: regression tests for the D3/D4 serialized metadata, plus a check that CurrentPositionCharacteristic still serializes as "int".

Serialized output after the fix:

{"iid":12,"type":"D3","perms":["pr","pw","ev"],"format":"uint32","value":300,"minValue":0,"maxValue":3600,"minStep":1,"unit":"s"}

Testing

  • mvn -B package on Zulu JDK 11: all 15 tests pass, and the formatter reformatted nothing.
  • Against the old valve classes, the two new duration tests fail with expected "uint32" but was "int".

As the issue notes, it is not established whether this also fixes the countdown display in openhab/openhab-addons#18245.

Checklist

🤖 Generated with Claude Code

SetDurationCharacteristic (D3) and RemainingDurationCharacteristic (D4)
serialized their metadata with "format":"int", but the HAP spec defines
both as UInt32. Add a protected IntegerCharacteristic constructor that
takes the HAP format and use it for the two duration characteristics.
All other integer characteristics keep advertising "int".

Add regression tests for the D3/D4 formats and for an unchanged
int-format characteristic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yfre
yfre merged commit 3b750c1 into master Oct 18, 2026
1 check 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.

Valve duration characteristics advertise int instead of uint32

1 participant