-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning get/set errors to HomeKit? #163
Comments
In which case do you want to return an error back to iOS? |
A TV remote control is one example. When iOS issues volume up or down I send a request. It doesn't have a state value. If a failure occurs I return it back to iOS. In most other cases (like lights), I don't. But HAP-NodeJS allows you to either store the value locally or allows you to retrieve it remotely and waits for a callback for get and set. At this point I'm trying to understand the design differences between the two libraries before I migrate everything over. |
What error do you return to iOS when the communication to the actual device was not successful? |
I have the same issue. |
I'm currently working on a new version of the library. import (
"github.com/brutella/hap"
"github.com/brutella/hap/accessory"
)
a := accessory.NewLightbulb(accessory.Info{ Name:"My Light bulb" })
a.Lightbulb.On.SetValueRequestFunc = func(interface{}, *http.Request) int {
return hap.JsonStatusServiceCommunicationFailure
} https://pkg.go.dev/github.com/brutella/hap/characteristic#C Does this solve your issue? |
Sorry it's been a couple years so my memory on this is a little foggy, and I haven't really touched my home stuff in that time. Still meaning to rewrite some of it, which is still in JS. On first glance I'm wondering if it's possible to return an error message as well as an error code. Possibly to provide more contextual information. I don't recall if that was possible in the HomeKit protocol or not...? So in this case should the return type be error? Then if it follows a particular interface protocol you could get the error code from that. And then looking at my original question about async - Is it possible to respond asynchronously? Pretty much every device I have isn't going to respond synchronously. I have a mix of ZWave and Wifi devices. |
The basic characteristic types for booleans, integers, floats, bytes and strings provide the method OnSetRemoteValue, which you can use the return an error. If an error is returned, the library returns the error code -70402, which is the correct behaviour.
The protocol requires you to return an error synchronously. This means you have to block while you communicate with your ZWave and Wifi devices. I'm sure HAP-NodeJS does this in a similar way. |
I currently use HAP-NodeJS and looking to migrate to this library. Comparing the two, HAP-NodeJS allows a get/set to by async, and returns an error with a 207 multi status to HomeKit.
It seems it may be possible to do async requests with this package (because it supports camera), but I am unclear how to return failures.
Is it possible to report an error back to iOS?
The text was updated successfully, but these errors were encountered: