GithubHelp home page GithubHelp logo

Comments (3)

maximkulkin avatar maximkulkin commented on June 25, 2024
#ifndef NUMBER_OF_RELAYS
#define NUMBER_OF_RELAYS 4
#endif

homekit_accessory_t *accessories[] = {
    HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]){
        HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]){
            &name,
            HOMEKIT_CHARACTERISTIC(MANUFACTURER, "YOU"),
            HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "123456"),
            HOMEKIT_CHARACTERISTIC(MODEL, "Basic"),
            HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1"),
            HOMEKIT_CHARACTERISTIC(IDENTIFY, identify),
            NULL
        }),
#if (NUMBER_OF_RELAYS == 1)
        HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            HOMEKIT_CHARACTERISTIC(NAME, "Switch"),
            &switch1_on,
            NULL
        }),
#else
        HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            HOMEKIT_CHARACTERISTIC(NAME, "Switch 1"),
            &switch1_on,
            NULL
        }),
#if (NUMBER_OF_RELAYS > 1)
        HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            HOMEKIT_CHARACTERISTIC(NAME, "Switch 2"),
            &switch2_on,
            NULL
        }),
#if (NUMBER_OF_RELAYS > 2)
        HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            HOMEKIT_CHARACTERISTIC(NAME, "Switch 3"),
            &switch3_on,
            NULL
        }),
#if (NUMBER_OF_RELAYS > 3)
        HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            HOMEKIT_CHARACTERISTIC(NAME, "Switch 4"),
            &switch4_on,
            NULL
        }),
#endif
#endif
#endif
#endif
        NULL
    }),
    NULL
};

Then in Makefile add

NUMBER_OF_RELAYS ?= 1

EXTRA_CFLAGS += -DNUMBER_OF_RELAYS=$(NUMBER_OF_RELAYS)

Then you can compile it like this (plus or minus how you normally compile it)

make NUMBER_OF_RELAYS=3 all

from esp-homekit.

FRANAIRBUS avatar FRANAIRBUS commented on June 25, 2024

hello @maximkulkin
Thank you very much for your quick response, I will implement it and it will be solved.

Thanks a lot
congratulations again

from esp-homekit.

maximkulkin avatar maximkulkin commented on June 25, 2024

I assume it worked for you. If you still have issues with it, feel free to reopen this issue (or create new one if you have a different problem)

from esp-homekit.

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.