Skip to content

Commit

Permalink
we should send only buttons events that have actions assigned to them…
Browse files Browse the repository at this point in the history
… or set BUTTON_MQTT_SEND_ALL_EVENTS to 1 to send everything
  • Loading branch information
Valcob committed Oct 5, 2018
1 parent ba4d4be commit 30285b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code/espurna/button.ino
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ void buttonEvent(unsigned int id, unsigned char event) {
DEBUG_MSG_P(PSTR("[BUTTON] Button #%u event %u\n"), id, event);
if (event == 0) return;

unsigned char action = buttonAction(id, event);

#if MQTT_SUPPORT
buttonMQTT(id, event);
if (action != BUTTON_MODE_NONE || BUTTON_MQTT_SEND_ALL_EVENTS) {
buttonMQTT(id, event);
}
#endif

unsigned char action = buttonAction(id, event);

if (action == BUTTON_MODE_TOGGLE) {
if (_buttons[id].relayID > 0) {
relayToggle(_buttons[id].relayID - 1);
Expand Down
2 changes: 2 additions & 0 deletions code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@

#ifndef BUTTON_LNGLNGCLICK_DELAY
#define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
#define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
// 1 - to send all button events to MQTT
#endif

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 30285b3

Please sign in to comment.