Giter Site home page Giter Site logo

Comments (2)

shahpiyushv avatar shahpiyushv commented on June 24, 2024

@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.

mbuckaway avatar mbuckaway commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.