brutella / hap

The HomeKit Accessory Protocol (hap) implemented in Go
Apache License 2.0
346 stars 39 forks source link

Fix for emitted JSON to be compliant with HomeKit protocol #31

Closed geekman closed 1 year ago

geekman commented 1 year ago

These changes makes sure that characteristics comply with the HomeKit protocol when a characteristic's ValueRequestFunc returns an error. This would fix issue #30.

Changes:

One thing to note that deviates from the preliminary patch in #30 is that the Value must be tri-state to allow for it to:

So I re-used a pattern that was already in the code, using the V struct. A null value is required because the ProgrammableSwitchEvent needs to read as null, and the test was failing. I also realized that /identify must not emit a value at all.

Also added tests for the changes.

brutella commented 1 year ago

Your changes look fine to me. Thanks