Arduino-HomeKit-ESP8266
Arduino-HomeKit-ESP8266 copied to clipboard
How to achieve a button that switches back to OFF automatically
Hi there, I do not know where to ask.
I successfully build this with a NodeMCU. (Switch)
What I want to achieve is a button I trigger from Homekit.. And I want it to return automatically after lets say 3sec to OFF.
I thought to do some automation on the HomeKit side. But I would prefer to have it in 'hardware' (=in the Arduino code). Where do I infuse what to accomplish this? Any help appreciated. I am new to this.
Seems like a timer in the main loop would do. Some pseudo code;
uint32_t timer = 0;
if millis() > timer {
timer = millis() + (3 * 1000); //3 seconds from now
digitalWrite(pin, setting) //set it to whatever value
switch.value.bool = setting //make the state consistent
homekit_notify_accessory_change (setting) //notify for any changes.
}