Returning value out of range made accessory disappear #19
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.
Andy,
After some detective work I was able to narrow down the reason the accessory was disappearing. I'm still running more tests to confirm this was the reason but so far after 24 hours it is holding fine. The problem was not in the code but in the data the accessory was returning. To be more precise, AmbientLightLevelCharacteristic said that values were in the range between 0.0001 and 100000. My zwave sensor was returning 0.0 when it was dark. Seems like HK runs some background check at some moment and if an accessory is returning some invalid data (e.g. value out of range) then it is declared as "incompatible" (I guess) and is silently removed.
I added a simple check in the library to detect out of range values (for Floats) and return closest value within range. The problem is also logged like this:
It would be nice to also check range for IntegerCharacteristic but a bigger refactoring is needed that could break compatibility so I left that one alone.
Columbo can now take a break from this long investigation. :)