Support geofence_client for aiohue compatibility #962
Merged
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.
Fixes #897 by adding just enough functionality to support aiohue's (ab)use of a
geofence_client
resource - creating one with aPOST
and periodically updating it with aPUT
, generating an event for the event stream each time.In testing I've found that the event stream isn't very reliable at passing messages through to the client - I'm not sure if that's an artefact of my dev environment, but it does eventually settle down if left running for a few minutes.
One addition I'm not sure about is returning an HTTP 500 error to clients when presented with resources through
POST
orPUT
that diyHue doesn't support, rather than either silently failing or (as was happening in #897) dumping stack traces to the logs. Experience tells me that's usually a better way to handle it, but if any current diyHue clients are relying on the existing behaviour this might cause problems. Happy to back out that part of these changes if you'd prefer.