Replies: 1 comment
|
Hi @mmlody, with HomeAssistant ZHA (not Z2M) the identify is fully working. You may likely need to Z2M a proper device configuration to have the identify button visible, but I don't use Z2M so can't help much there. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
hello
my code for M5 nanoC6 - working but in "manual" way - call onIdentify is possible only through developer console in zigbee2mqtt
is possible to add endpoint with switch/button ? (like light switch or binary )
working example is in IKEA devices - many devices with identify button
my code:
identify-sample.txt
`
#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif
#include "Zigbee.h"
#define LED_PIN 7 // M5NanoC6 blue LED
#define BUTTON_PIN 9 // BOOT button
ZigbeeLight zbLight(10); // Endpoint 10
TaskHandle_t identifyTaskHandle = NULL;
volatile bool identifyActive = false;
// xTask dla Identify - mruga LED przez 5 sekund
static void identifyTask(void *arg) {
uint16_t identifyTime = ((uint16_t)arg); // Czas w sekundach
Serial.printf("Identify task started for %d seconds\n", identifyTime);
uint32_t endTime = millis() + (identifyTime * 1000);
while (millis() < endTime) {
digitalWrite(LED_PIN, HIGH);
vTaskDelay(200 / portTICK_PERIOD_MS);
digitalWrite(LED_PIN, LOW);
vTaskDelay(200 / portTICK_PERIOD_MS);
}
// Przywróć stan LED
digitalWrite(LED_PIN, zbLight.getLightState());
Serial.println("Identify task finished");
identifyActive = false;
vTaskDelete(NULL); // Usuń task
}
void setup() {
Serial.begin(115200);
// Inicjalizacja LED
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Inicjalizacja przycisku
pinMode(BUTTON_PIN, INPUT_PULLUP);
// Konfiguracja Zigbee Light
zbLight.setManufacturerAndModel("M5Stack", "NanoC6-LED");
zbLight.setPowerSource(ZB_POWER_SOURCE_MAINS);
// Callback przy zmianie stanu przez Zigbee
zbLight.onLightChange([](bool state) {
digitalWrite(LED_PIN, state);
Serial.printf("Zigbee: LED %s\n", state ? "ON" : "OFF");
});
// Callback dla komendy Identify - uruchamia xTask
zbLight.onIdentify([](uint16_t identifyTime) {
Serial.println("identify start");
});
// Dodaj endpoint
Zigbee.addEndpoint(&zbLight);
// Uruchom Zigbee
Serial.println("Starting Zigbee...");
if (!Zigbee.begin()) {
Serial.println("Zigbee failed!");
ESP.restart();
}
// Czekaj na połączenie
while (!Zigbee.connected()) {
Serial.print(".");
delay(100);
}
Serial.println("\nConnected!");
}
void loop() {
// Obsługa przycisku
if (digitalRead(BUTTON_PIN) == LOW) {
delay(100); // debounce
}
delay(100);
}
`
All reactions