Comments (2)
@mbuckaway this is indeed an expected behaviour and that is how the sdk and iOS side is designed.
If we internally change the value to fit within the constraints, modifying constraints of some standard characteristics becomes tricky. For example, the code below is perfectly valid
hap_char_t *light_level = hap_char_current_ambient_light_level_create(0);
hap_char_float_set_constraints(light_level, 0, 100000.0, 0.0);
In the first call, if we just change the value from 0 to 0.0001 to fit within the constraints, even if you override the constraints using the next call, the value will stay at 0.0001, which is not what you may have wanted. If we decide to adjust the value while actually reporting, it complicates the code and moreover, since that will happen asynchronously, it will not even be reported to your application code and may cause undesired behaviour.
The SDK only checks the values received from the controller, but lets the application code decide the values set through the firmware.
Now, for any characteristic, if iOS finds that the value is outside the constraints, it is considered as an error and so, the controller either discards the pairing or closes the connection (depending on when the error was received). For some characteristics, it may not even allow changing the constraints(Eg. A value of 400 for hue would be wrong even if you modify the constraints. I haven't tested this, but just a possibility).
If the Home app is working fine with the constraints changed to what you want in this particular case (starting with 0), it could be acceptable.
This is not related to #4 , as there, the JSON formatting itself was getting distorted because ESP8266 does not have floating point support enabled by default. You seem to be using ESP32.
from esp-homekit-sdk.
Thanks for the quick response. Its unfortunate Apple has choose to cause an entire device to go offline when there is an "error" in a sensor read value. In my case, the light sensor does return 0 when it's night....which Apple believes is not valid.
My work around was to create a custom light sensor based on the ESP HomeKit SDK version, and set to the limit to start from 0 and set int constraints since the sensor returns an int and not a float. This works. The Home app shows 0lux at night and shows the correct value during the day.
This is different for a light or a switch where the values are limited. You can set a switch a value of 2 and it only supports 0 or 1. Sensors on the other hand are read-only devices, and return what they return.
That, I have a working device. So, the case can be closed. The issue should probably appear in a FAQ for the SDK.
from esp-homekit-sdk.
Related Issues (20)
- Associated more than one accessory HOT 2
- mbedtls inclusion error, udnefined functions HOT 1
- Unable to find components to build examples for ESP8266 HOT 2
- How to cleanly add or remove accessories ? (bridge) HOT 2
- HTTPD init error HOT 2
- ESP8266无法使用
- Accessory Not Found HOT 6
- Update examples CMakeLists.txt
- hap_platform_httpd_start failing HOT 1
- Is it possible to remove nvs? HOT 2
- More than 1 accessory support without using bridge HOT 6
- How to change Homekit TCP port? HOT 2
- esp-homekit-sdk network allocation HOT 2
- Lightbulb: save status on flash HOT 3
- Change serial number without re-build source code HOT 2
- Is it possible to return the device status outside the hap_serv_set_write_cb callback function? HOT 3
- idf.py menuconfig fails for aws-iot example
- Mfi license HOT 5
- homekit bridge Decryption error/Connection lost HOT 2
- Problem with some services and features HOT 5
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 esp-homekit-sdk.