Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Characteristic, compatible with EVE App #195

Open
Camaendir opened this issue Sep 29, 2021 · 4 comments
Open

Custom Characteristic, compatible with EVE App #195

Camaendir opened this issue Sep 29, 2021 · 4 comments

Comments

@Camaendir
Copy link

I want to write a small LED-Strip Animation that is compatible with the EVE App. For that i need an additional Characteristic. How can i add one? I've tried the following:

#define HOMEKIT_CHARACTERISTIC_ANIMATION MYUUID
#define HOMEKIT_DECLARE_CHARACTERISTIC_ANIMATION(_value, ...) \
    .type = HOMEKIT_CHARACTERISTIC_ANIMATION, \
    .description = "ANIMATION", \
    .format = homekit_format_uint8, \
    .permissions = homekit_permissions_paired_read \
				 | homekit_permissions_paired_write \
                 | homekit_permissions_notify, \
    .min_value = (float[]) {0}, \
    .max_value = (float[]) {2}, \
    .min_step = (float[]) {1}, \
    .valid_values = { \
        .count = 3, \
        .values = (uint8_t[]) { 0, 1, 2 }, \
    }, \
    .value = HOMEKIT_UINT8_(_value), \
    ##__VA_ARGS__

added to the characteristics.h and using that just like the others. But the compilation errors with an "initializer element is not constant" error. Do you have an example with a custom characteristic.

Thanks for the help

@maccoylton
Copy link

Here's a library I used in my accessories for custom characteristics:-

https://github.com/maccoylton/esp-homekit-common-functions/tree/master/custom_characteristics

@Camaendir
Copy link
Author

@maccoylton Thanks for the Link. I still get an error "initializer element is not constant" Did you get such an error as well?

@maccoylton
Copy link

The link I showed you works and is used in about a dozen different accessories. Copy the pattern from one of my custom characteristics and it should work fine, your syntax doesn't look correct.

@maximkulkin
Copy link
Owner

First, you do not need to put your custom characteristic type definitions into characteristics.h, it is sufficient to just put it somewhere and include it into code before you start creating characteristics of that type. E.g. you can put them right inside .c file, just make sure it is before your characteristics definitions.

Second, the error you're getting is not because of definition, but because of what you put inside that macro as a value. Can you post the code where you create characteristic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants