Repository navigation
Advertise uint32 format for valve duration characteristics - #203
Merged
Merged
Conversation
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>
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.
Closes #202
Problem
SetDurationCharacteristic(D3) andRemainingDurationCharacteristic(D4) extendIntegerCharacteristic, which hard-codes"format": "int". Apple's HAP spec defines both as UInt32 (seconds, 0–3600).Change
IntegerCharacteristic: newprotectedconstructor that takes the HAPformat. The existing public constructor delegates to it with"int", so all other integer characteristics and any custom subclasses still advertise"int".SetDurationCharacteristicandRemainingDurationCharacteristicpass"uint32". Java values stayInteger, which covers the 0–3600 range.DurationCharacteristicFormatTest: regression tests for the D3/D4 serialized metadata, plus a check thatCurrentPositionCharacteristicstill 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 packageon Zulu JDK 11: all 15 tests pass, and the formatter reformatted nothing.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