Comments (5)
The Apple Home app shows "No Response" when it has no network connection to a specific accessory.
If an accessory is managed by a bridge, and HomeKit doesn't get a network connection to one of the bridged accessories, it marks the whole bridge as not accessible. (I haven't tested this myself but it seems reasonable.)
One way to handle the case where a specific accessory is not accessible is to remove the accessory from the bridge. But there are some things you have to consider.
- If you add and remove accessories over time, you have to make sure that their corresponding IDs are the same. HomeKit identifies accessory by their ids and expects that an accessory has the same id the next time the bridge is accessible. You will have to do some kind of mapping between an accessories and ids.
hap
currently doesn't support removing accessory dynamically while the bridge is running. You will have to recreate the list of accessory and use a new bridge instance programmatically when removing an accessory. I'm doing the same in my projects and it works perfectly.
from hap.
Alright I've managed to trace through the code using a runtime/debug.PrintStack()
at ValueRequestFunc
and figured it out. I found it hard to believe that something like a Philips Hue hub would not be able to signal to iOS that only a few bulbs are unreachable and takes down the entire hub with it.
Apparently there was a call to ValueRequestFunc
as part of C.MarshalJSON()
. The reason why iOS stopped at GET /accessories
was because the returned JSON was "malformed", at least according to Apple's parsing. /accessories
will call *A.MarshalJSON
then *S.MarshalJSON
, then ultimately to *C.MarshalJSON
. Here, "value" is filled only on success:
Lines 288 to 290 in 040bd95
But in testing, "value" needs to be present and cannot be null, so it can only be a dummy value.
After that is fixed, iOS continues on to call PUT /characteristics
as I described above.
Next, the multi-status 207 return is also malformed. "status": 0
must be explicit, it cannot be omitted. Additionally, "value"
must be omitted here, since it is an error.
Applying these 2 fixes solved the issue:
$ git diff
diff --git a/characteristic/c.go b/characteristic/c.go
index 0f1c61c..8b3b415 100644
--- a/characteristic/c.go
+++ b/characteristic/c.go
@@ -287,6 +287,8 @@ func (c *C) MarshalJSON() ([]byte, error) {
// 2022-03-21 (mah) FIXME provide a http request instead of nil
if v, s := c.ValueRequest(nil); s == 0 {
d.Value = &V{v}
+ } else {
+ d.Value = &V{c.Val} // dummy "zero" value
}
}
diff --git a/characteristics.go b/characteristics.go
index 1f6f72d..3ed757c 100644
--- a/characteristics.go
+++ b/characteristics.go
@@ -14,7 +14,7 @@ import (
type characteristicData struct {
Aid uint64 `json:"aid"`
Iid uint64 `json:"iid"`
- Value interface{} `json:"value"`
+ Value interface{} `json:"value,omitempty"`
// optional values
Type *string `json:"type,omitempty"`
@@ -89,6 +89,7 @@ func (srv *Server) getCharacteristics(res http.ResponseWriter, req *http.Request
cdata.Status = &s
} else {
cdata.Value = v
+ cdata.Status = new(int) // 0
}
if meta {
As I'm not too familiar with the code, I don't know if there will be any side effects from these changes, but it works now. Only 1 sensor will be marked as "no response", while all other accessories function normally.
from hap.
Thanks for clarifying your findings.
We might also want to remove the "omitempty" json option for the Value field in the MarshalJSON()
function.
from hap.
Do you want me to submit a PR that fixes the bugs? I would probably also add some tests that checks for the marshaled JSON results to verify they are conformant.
from hap.
Do you want me to submit a PR that fixes the bugs?
That would be great. 👍
from hap.
Related Issues (20)
- HAP Devices are switching rooms HOT 2
- Accessory not showing up for pairing HOT 1
- Cannot see accessory: DNS probing gets stuck HOT 10
- Can't use Thermostat with custom min temperature HOT 3
- dynamically adding/removing accessory from a bridge HOT 1
- Usage example from readme cannot gracefully exit the app HOT 4
- Some Characteristics not shown on iPhone/MacOS HOT 1
- Feat: Expose Client UUID
- Not paired with {id}. Access blocks by another connected cloud id to my house. HOT 2
- How to create new accessory or use Air Conditioner accessory HOT 2
- Thermostat need a struct value for current humidity. HOT 2
- dnssd Name Conflict Resolution results in HTTP Bad Request
- Manually setting the accessory ID causes accessory to be unresponsive HOT 5
- Thermostat HOT 1
- Connection issues when using Chinese characters
- Simple Setup - pair-setup.go:42: pairing is not allowed HOT 1
- Person detection and facial recognition characteristics
- dns-sd name conflict resolution leads to space in name, causing malformed host header and failure to pair HOT 7
- Using a bridge causes the state of the device in the Apple home app to be out of sync
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hap.