-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT report setting for buttons: send action events, all events or state #1772
base: dev
Are you sure you want to change the base?
Conversation
Per definitions configuration, button limit is 8 (=> uint8_t as mask makes sense)
|
Is there currently any way I can use the mqtt reporting of a button state whose I'd like to be able to use the |
See BUTTON_MQTT_SEND_ALL_EVENTS flag (default off)? |
Thanks. I thought BUTTON_MQTT_SEND_ALL_EVENTS was already default to ON. I'll test. |
That all works. I did have one issue as I had set Can |
I've yet to add this to config list in the Wiki: espurna/code/espurna/button.ino Lines 581 to 596 in e2e0409
btnRepDel<#index> key can be used for specific button. It will cancel out what WebUI sets, which is global default value.
|
I was mistaken about the order above. To actually do that: diff --git a/code/espurna/button.ino b/code/espurna/button.ino
index ff311352..7f5b7796 100644
--- a/code/espurna/button.ino
+++ b/code/espurna/button.ino
@@ -490,7 +490,7 @@ void _buttonConfigure() {
// TODO: compatibility proxy, fetch global key before indexed
template<typename T>
unsigned long _buttonGetSetting(const char* key, unsigned char index, T default_value) {
- return getSetting(key, getSetting({key, index}, default_value));
+ return getSetting({key, index}, getSetting(key, default_value));
} Without the patch |
#1772 (comment) > Without the patch btnRepDel overrides every btnRepDel0, btnRepDel1 etc., btnRepDel0 read second, then hard-coded value. With the patch btnRepDel0 is read first, then btnRepDel, then hard-coded value. Indexed key can only be set via settings upload or in terminal, WebUI can change only the global override setting. Allow more 'specific' key to override global setting.
ref #1747
@skyynet I though a bit about eventsensor for this, but it might be a bad match due to hardware limitations and noise (i think you pretty much required to have hardware filtering for the digital pin signal)
Instead, what about an option to send button pressed state instead of event, bypassing event mapping and directly giving user the button state?
edit:
...but I think this needs to be per-button instead of a global to be more flexibledone! current gcc version supports binary literals, so it is pretty easy to specify bitmask directly as int
Deprecate BUTTON_MQTT_SEND_ALL_EVENTS
New defines are BUTTON_MQTT_MASK_EVENTS and BUTTON_MQTT_MASK_PRESSED (with runtime btnMaskEvents and btnMaskPressed)
0b11000000
to make BUTTON1 and BUTTON2 report to MQTT. BUTTON3 will still handle events