Skip to content
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

The globalInputHandler not working #700

Open
kartom opened this issue Jan 2, 2021 · 1 comment
Open

The globalInputHandler not working #700

kartom opened this issue Jan 2, 2021 · 1 comment

Comments

@kartom
Copy link
Contributor

kartom commented Jan 2, 2021

When assigning a global input handler with the following code:

void onHomieEvent(const HomieEvent& event) {
    if(event.type == HomieEventType::MQTT_READY) {
        //Update MQTT about current state when reconnecting
        nodes.setProperty("on").send(on? "true":"false");
    }
}

bool inputHandler(const HomieNode& node, const HomieRange& range, const String& property, const String& value)     {
    return false;
}

void setup() {
    Homie.onEvent(onHomieEvent);
    Homie.setGlobalInputHandler(inputHandler);
    Homie.setup();

This will cause the MQTT connection to be continuously connected / disconnected.

There is also wrong information in the documentation for the global input handler. According to the documentation is should be:
bool globalInputHandler(const HomieNode& node, const String& property, const HomieRange& range, const String& value)
but this is the correct declaration:
bool globalInputHandler(const HomieNode& node, const HomieRange& range, const String& property, const String& value)

@kartom
Copy link
Contributor Author

kartom commented Jan 2, 2021

There is something fishy going on with my code, now i get the problem even when commenting out both the onEvent ant the setGlobalInputHandler. The documentation problem still exists though.

This is the output from the log:

 MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✔ MQTT ready
Triggering MQTT_READY event...
〽 Sending statistics...
  • Interval: 65s (60s including 5s grace time)
  • Wi-Fi signal quality: 54%
  • Uptime: 210s
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✔ MQTT ready
Triggering MQTT_READY event...
〽 Sending statistics...
  • Interval: 65s (60s including 5s grace time)
  • Wi-Fi signal quality: 58%
  • Uptime: 210s
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✔ MQTT ready
Triggering MQTT_READY event...
〽 Sending statistics...
  • Interval: 65s (60s including 5s grace time)
  • Wi-Fi signal quality: 60%
  • Uptime: 210s
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...
Sending initial information...
✖ MQTT disconnected, reason: 0
Triggering MQTT_DISCONNECTED event...
↕ Attempting to connect to MQTT...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant