Added updates from main branch to here
button press is published on mqtt #98
This commit is contained in:
parent
d7c0113110
commit
e7fb54f717
1 changed files with 21 additions and 0 deletions
|
@ -782,9 +782,18 @@ void checkForRequests() {
|
||||||
if (buttonState == false) {
|
if (buttonState == false) {
|
||||||
setModeByStateString(BTN_MODE_SHORT);
|
setModeByStateString(BTN_MODE_SHORT);
|
||||||
buttonState = true;
|
buttonState = true;
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =static white").c_str());
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
buttonState = false;
|
buttonState = false;
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =off").c_str());
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
sendState();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,12 +801,24 @@ void checkForRequests() {
|
||||||
void mediumKeyPress() {
|
void mediumKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Medium button press\n");
|
DBG_OUTPUT_PORT.printf("Medium button press\n");
|
||||||
setModeByStateString(BTN_MODE_MEDIUM);
|
setModeByStateString(BTN_MODE_MEDIUM);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =fire flicker").c_str());
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
sendState();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when button is kept pressed for 2 seconds or more
|
// called when button is kept pressed for 2 seconds or more
|
||||||
void longKeyPress() {
|
void longKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Long button press\n");
|
DBG_OUTPUT_PORT.printf("Long button press\n");
|
||||||
setModeByStateString(BTN_MODE_LONG);
|
setModeByStateString(BTN_MODE_LONG);
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
|
mqtt_client.publish(mqtt_outtopic, String("OK =fireworks random").c_str());
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
sendState();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void button() {
|
void button() {
|
||||||
|
|
Loading…
Reference in a new issue