• Moin,

    Habe folgendes Anliegen: Eine alte Fahrstuhl Steuerung (siehe Bilder) soll ´´Smart´´ werden. Sie soll am Ende des Tages mit ihren 7 Schaltern Geräte steuern können. Ähnlich wie hier

    jedoch 7 mal und möglichst mit einem Bord 😊. Bin relativ neu mit dem schreiben von scripten in der Arduino IDE, deswegen wäre mir eine fertige Firmware oder fertiges script am liebsten 😅. Es ist bereits ein Homebridge System vorhanden, daher wäre ein Umweg nicht so schlimm.

    Vielen Dank im Voraus.

    IMG_1908_klein.jpg
    IMG_1906_klein.jpg[Link Text](Link Adresse)


  • Also eigentlich nur 7x Button einlesen und dementsprechend eine Request senden? Batterie oder per Netzteil? Ansonsten wäre für Batterie der Deep-Sleep geeignet:
    https://makesmart.net/esp8266-deep-sleep-tutorial/

    Wie man eine HTTP-Request sendet an Homebridge dann zB kannst du u.a hier nachlesen:
    https://makesmart.net/esp8266-http-get-request/

    Sollt jetzt eigentlich nicht so das riesen Ding sein.


  • Gibt es überhaupt einen Button in homekit? Oder stellt der esp einen ´´Switch´´ zum schalten da? Gibt es den Code des Buzzers oder der Fernbedienung irgendwo?

    MfG


  • @zockerplayshd es gibt glaub ein homebridge Plugin was auch so einen push button beinhaltet. ist dann quasi ein Taster also denke ich mal

    https://www.npmjs.com/package/homebridge-http-webhooks


  • Moin, nach längerer Zeit mal ein Update/Hilferuf 😂. Ich habe mir das Beispiel des stateless programmable switch aus der esp Homekit Bibliothek vorgenommen und modifiziert. (https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266)

    Example03_statelessProgrammableSwitch

    #include <Arduino.h>
    #include <arduino_homekit_server.h>
    #include "wifi_info.h"
    #include "ESPButton.h"
    
    #define LOG_D(fmt, ...)   printf_P(PSTR(fmt "\n") , ##__VA_ARGS__);
    
    void setup() {
    	Serial.begin(115200);
    	wifi_connect(); 	
    	my_homekit_setup();
    }
    
    void loop() {
    	my_homekit_loop();
    	delay(10);
    }
    
    //==============================
    // HomeKit setup and loop
    //==============================
    
    extern "C" homekit_server_config_t config;
    extern "C" homekit_characteristic_t cha_programmable_switch_event;
    extern "C" homekit_characteristic_t cha_programmable_switch_event2;
    #define PIN_BUTTON1 0 
    #define PIN_BUTTON2 2
    
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS   0
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS   1
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS     2
    
    homekit_value_t cha_programmable_switch_event_getter() {
    	return HOMEKIT_NULL_CPP();
    }
    
    
    homekit_value_t cha_programmable_switch_event2_getter() {
      
      return HOMEKIT_NULL_CPP();
    }
    
    void my_homekit_setup() {
    	pinMode(PIN_BUTTON1, INPUT_PULLUP);
    	ESPButton.add(0, PIN_BUTTON1, LOW, true, true);
    	ESPButton.setCallback([&](uint8_t id, ESPButtonEvent event) {
    		LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
    		uint8_t cha_value = 0;
    		if (event == ESPBUTTONEVENT_SINGLECLICK) {
    			cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
    		} else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
    			cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
    		} else if (event == ESPBUTTONEVENT_LONGCLICK) {
    			cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
    		}
    		cha_programmable_switch_event.value.uint8_value = cha_value;
    		homekit_characteristic_notify(&cha_programmable_switch_event,
    				cha_programmable_switch_event.value);
    	});
    	ESPButton.begin();
    
    	cha_programmable_switch_event.getter = cha_programmable_switch_event_getter;
    	arduino_homekit_setup(&config);
    
      pinMode(PIN_BUTTON2, INPUT_PULLUP);
      ESPButton.add(0, PIN_BUTTON2, LOW, true, true);
      ESPButton.setCallback([&](uint8_t id, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event2.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event2,
            cha_programmable_switch_event2.value);
      });
      ESPButton.begin();
    
      cha_programmable_switch_event2.getter = cha_programmable_switch_event2_getter;
      arduino_homekit_setup(&config);
    }
    
    static uint32_t next_heap_millis = 0;
    
    void my_homekit_loop() {
    	ESPButton.loop();
    	arduino_homekit_loop();
    	const uint32_t t = millis();
    	if (t > next_heap_millis) {
    		// Show heap info every 5 seconds
    		next_heap_millis = t + 5 * 1000;
    		LOG_D("Free heap: %d, HomeKit clients: %d",
    				ESP.getFreeHeap(), arduino_homekit_connected_clients_count());
    
    	}
    }
    

    my_accessory.c

    #include <homekit/homekit.h>
    #include <homekit/characteristics.h>
    
    void my_accessory_identify(homekit_value_t _value) {
    	printf("accessory identify\n");
    }
    
    
    
    homekit_characteristic_t cha_programmable_switch_event = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    
    homekit_characteristic_t cha_programmable_switch_event2 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    
    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*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch1"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
    		HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            	HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
            	&cha_programmable_switch_event,
    			NULL
    		}),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=2, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch2"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event2,
          NULL
        }),
            NULL
        }),
        NULL
    };
    
    homekit_server_config_t config = {
    		.accessories = accessories,
    		.password = "111-11-111"
    };
    

    Folgendes Problem:
    Das Script wird ohne Probleme Hochgeladen, doch die Buttons werden nicht von der Home app gefunden. Bin mittlerweile Ratlos 😞
    Vielen Dank im Vorraus


  • Soooo, bin mittlerweile doch noch ein ganzes stück weiter. Ich war wohl mit meinem Code vorher irgendwie auf dem Holzweg 🙈 Ich habe es mittlerweile hinbekommen, dass alle Buttons in der Home app hinzugefügt und erkannt werden. Allerdings wird nun bei jedem Pin den ich definierte habe nur 1 Button in der Home App getriggert. Das heißt, egal welchen Knopf ich drücke es wird immer der gleiche ´´Digitale´´ Button in der Home App getriggert. Ich poste nochmal meinen aktuellen Code rein, vielleicht kann mir ja jemand helfen.

    my_buttons

    #include <Arduino.h>
    #include <arduino_homekit_server.h>
    #include "wifi_info.h"
    #include "ESPButton.h"
    
    #define LOG_D(fmt, ...)   printf_P(PSTR(fmt "\n") , ##__VA_ARGS__);
    
    void setup() {
      Serial.begin(115200);
      wifi_connect(); // in wifi_info.h
      homekit_storage_reset(); // to remove the previous HomeKit pairing storage when you first run this new HomeKit example
      my_homekit_setup();
    }
    
    void loop() {
      my_homekit_loop();
      delay(10);
    }
    
    //==============================
    // HomeKit setup and loop
    //==============================
    
    extern "C" homekit_server_config_t config;
    extern "C" homekit_characteristic_t cha_programmable_switch_event2;
    extern "C" homekit_characteristic_t cha_programmable_switch_event3;
    extern "C" homekit_characteristic_t cha_programmable_switch_event4;
    extern "C" homekit_characteristic_t cha_programmable_switch_event5;
    extern "C" homekit_characteristic_t cha_programmable_switch_event6;
    extern "C" homekit_characteristic_t cha_programmable_switch_event7;
    extern "C" homekit_characteristic_t cha_programmable_switch_event8;
    
    #define PIN_BUTTON2 D1 
    #define PIN_BUTTON3 D2 
    #define PIN_BUTTON4 D3 
    #define PIN_BUTTON5 D4 
    #define PIN_BUTTON6 D5 
    #define PIN_BUTTON7 D6 
    #define PIN_BUTTON8 D7 
    #define PIN_BUTTON9 D8 
    
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS   0
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS   1
    #define HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS     2
    
    // Called when the value is read by iOS Home APP
    homekit_value_t cha_programmable_switch_event_getter(){
      // Should always return "null" for reading, see HAP section 9.75
      return HOMEKIT_NULL_CPP();
    }
    
    void my_homekit_setup() {
      pinMode(PIN_BUTTON2, INPUT_PULLUP);
       pinMode(PIN_BUTTON3, INPUT_PULLUP);
        pinMode(PIN_BUTTON4, INPUT_PULLUP);
         pinMode(PIN_BUTTON5, INPUT_PULLUP);
          pinMode(PIN_BUTTON6, INPUT_PULLUP);
           pinMode(PIN_BUTTON7, INPUT_PULLUP);
            pinMode(PIN_BUTTON8, INPUT_PULLUP);
             pinMode(PIN_BUTTON9, INPUT_PULLUP);
    
      
      ESPButton.add(2, PIN_BUTTON2, LOW, true, true);
      ESPButton.add(3, PIN_BUTTON3, LOW, true, true);
      ESPButton.add(4, PIN_BUTTON4, LOW, true, true);
      ESPButton.add(5, PIN_BUTTON5, LOW, true, true);
      ESPButton.add(6, PIN_BUTTON6, LOW, true, true);
      ESPButton.add(7, PIN_BUTTON7, LOW, true, true);
      ESPButton.add(8, PIN_BUTTON8, LOW, true, true);
      ESPButton.add(9, PIN_BUTTON9, LOW, true, true);
      
      ESPButton.setCallback([&](uint8_t id = 2, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event2.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event2,
            cha_programmable_switch_event2.value);
      });
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 3, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event3.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event3,
            cha_programmable_switch_event3.value);
      });
    
    
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 4, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event4.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event4,
            cha_programmable_switch_event4.value);
      });
    
    
    
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 5, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event5.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event5,
            cha_programmable_switch_event5.value);
      });
    
    
    
    
    
    
    
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 6, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event6.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event6,
            cha_programmable_switch_event6.value);
      });
    
    
    
    
    
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 7, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event7.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event7,
            cha_programmable_switch_event7.value);
      });
    
    
    
    
    
    
    
    
    
    
       ESPButton.setCallback([&](uint8_t id = 8, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event8.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event8,
            cha_programmable_switch_event8.value);
      });
    
    
    
    
    
    
    
      /*ESPButton.setCallback([&](uint8_t id = 9, ESPButtonEvent event) {
        // Only one button is added, no need to check the id.
        LOG_D("Button Event: %s", ESPButton.getButtonEventDescription(event));
        uint8_t cha_value = 0;
        if (event == ESPBUTTONEVENT_SINGLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_SINGLE_PRESS;
        } else if (event == ESPBUTTONEVENT_DOUBLECLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_DOUBLE_PRESS;
        } else if (event == ESPBUTTONEVENT_LONGCLICK) {
          cha_value = HOMEKIT_PROGRAMMABLE_SWITCH_EVENT_LONG_PRESS;
        }
        cha_programmable_switch_event.value.uint8_value = cha_value;
        homekit_characteristic_notify(&cha_programmable_switch_event,
            cha_programmable_switch_event.value);
      });*/
    
    
    
    
      
      ESPButton.begin();
      cha_programmable_switch_event2.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event3.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event4.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event5.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event6.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event7.getter = cha_programmable_switch_event_getter;
      cha_programmable_switch_event8.getter = cha_programmable_switch_event_getter;
      arduino_homekit_setup(&config);
    }
    
    static uint32_t next_heap_millis = 0;
    
    void my_homekit_loop() {
      ESPButton.loop();
      arduino_homekit_loop();
      const uint32_t t = millis();
      if (t > next_heap_millis) {
        // Show heap info every 5 seconds
        next_heap_millis = t + 5 * 1000;
        LOG_D("Free heap: %d, HomeKit clients: %d",
            ESP.getFreeHeap(), arduino_homekit_connected_clients_count());
    
      }
    }
    

    my_accesory.c

    /*
     * my_accessory.c
     * Define the accessory in C language using the Macro in characteristics.h
     *
     *  Created on: 2020-05-16
     *      Author: Mixiaoxiao (Wang Bin)
     */
    
    #include <homekit/homekit.h>
    #include <homekit/characteristics.h>
    
    void my_accessory_identify(homekit_value_t _value) {
    	printf("accessory identify\n");
    }
    
    // Stateless Programmable Switch (HAP section 8.37)
    // required: PROGRAMMABLE_SWITCH_EVENT
    // optional: NAME, SERVICE_LABEL_INDEX
    
    // format: uint8; HAP section 9.75; write the .getter function and always return "null" for reading
    homekit_characteristic_t cha_programmable_switch_event2 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event3 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event4 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event5 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event6 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event7 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    homekit_characteristic_t cha_programmable_switch_event8 = HOMEKIT_CHARACTERISTIC_(PROGRAMMABLE_SWITCH_EVENT, 0);
    
    homekit_accessory_t *accessories[] ={
        HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_bridge, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Multiple Switches"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Homekit Switches"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "1234567"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266 D1 Mini"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
            NULL
        }),   
        HOMEKIT_ACCESSORY(.id=2, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch1"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
    		HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
            	HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
            	&cha_programmable_switch_event2,
    			NULL
    		}),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=3, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch2"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event3,
          NULL
        }),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=4, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch3"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event4,
          NULL
        }),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=5, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch4"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event5,
          NULL
        }),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=6, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch5"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event6,
          NULL
        }),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=7, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch6"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event7,
          NULL
        }),
            NULL
        }),
        HOMEKIT_ACCESSORY(.id=8, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
            HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
                HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch7"),
                HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"),
                HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123457"),
                HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"),
                HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
                HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
                NULL
            }),
        HOMEKIT_SERVICE(STATELESS_PROGRAMMABLE_SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
              HOMEKIT_CHARACTERISTIC(NAME, "Stateless Programmable Switch"),
              &cha_programmable_switch_event8,
          NULL
        }),
            NULL
        }),
        NULL
    };
    
    homekit_server_config_t config = {
    		.accessories = accessories,
    		.password = "111-11-111"
    };
    

Ähnliche Themen

  • 5
  • 11
  • 9
  • 1
  • 3