Browse Source

Merge pull request #1246 from Valcob/fix/button-send-mqtt-only-event-with-actions-or-all

Buttons send mqtt message for events with assigned actions to them
ota
Xose Pérez 6 years ago
committed by GitHub
parent
commit
a2db30baa9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions
  1. +5
    -3
      code/espurna/button.ino
  2. +2
    -0
      code/espurna/config/general.h

+ 5
- 3
code/espurna/button.ino View File

@ -97,12 +97,14 @@ void buttonEvent(unsigned int id, unsigned char event) {
DEBUG_MSG_P(PSTR("[BUTTON] Button #%u event %u\n"), id, event); DEBUG_MSG_P(PSTR("[BUTTON] Button #%u event %u\n"), id, event);
if (event == 0) return; if (event == 0) return;
unsigned char action = buttonAction(id, event);
#if MQTT_SUPPORT #if MQTT_SUPPORT
buttonMQTT(id, event);
if (action != BUTTON_MODE_NONE || BUTTON_MQTT_SEND_ALL_EVENTS) {
buttonMQTT(id, event);
}
#endif #endif
unsigned char action = buttonAction(id, event);
if (action == BUTTON_MODE_TOGGLE) { if (action == BUTTON_MODE_TOGGLE) {
if (_buttons[id].relayID > 0) { if (_buttons[id].relayID > 0) {
relayToggle(_buttons[id].relayID - 1); relayToggle(_buttons[id].relayID - 1);


+ 2
- 0
code/espurna/config/general.h View File

@ -236,6 +236,8 @@
#ifndef BUTTON_LNGLNGCLICK_DELAY #ifndef BUTTON_LNGLNGCLICK_DELAY
#define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click #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 #endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------


Loading…
Cancel
Save