question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MQTT handle * failed to configure

See original GitHub issue

Describe the bug

When I disable homie discovery the MQTT doesn’t work anymore.

To Reproduce

Steps to reproduce the behavior:

  1. Go to settings
  2. Click on mqtt
  3. Scroll down to homie autodiscovery
  4. Click on Enabled (so it gets disabled)
  5. See the error in the vacuum log

Vacuum Model

Roborock S50

Valetudo Version

2021.05.0

Expected behavior

Stop homie discovery (since I have no homie, not needed)

Log

[2021-05-26T13:21:20.406Z] [WARN] MQTT handle valetudo/robot/ConsumableMonitoringCapability/brush-side_right failed to configure Error: Handle may only be configured while the MQTT controller is not initialized
    at PropertyMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:160:19)
    at ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:167:29)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/RobotStateNodeMqttHandle.js:30:9)
    at async /snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:162:17
    at async MqttController.reconfigure (/snapshot/Valetudo/backend/lib/mqtt/MqttController.js:452:13)
    at async ConsumableMonitoringCapabilityMqttHandle.findNewConsumables (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:153:13)
    at async ConsumableMonitoringCapabilityMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:168:9)
    at async RobotMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:225:13)
[2021-05-26T13:21:20.409Z] [WARN] MQTT handle valetudo/robot/ConsumableMonitoringCapability/filter-main failed to configure Error: Handle may only be configured while the MQTT controller is not initialized
    at PropertyMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:160:19)
    at ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:167:29)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/RobotStateNodeMqttHandle.js:30:9)
    at async /snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:162:17
    at async MqttController.reconfigure (/snapshot/Valetudo/backend/lib/mqtt/MqttController.js:452:13)
    at async ConsumableMonitoringCapabilityMqttHandle.findNewConsumables (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:153:13)
    at async ConsumableMonitoringCapabilityMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:168:9)
    at async RobotMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:225:13)
[2021-05-26T13:21:20.411Z] [WARN] MQTT handle valetudo/robot/ConsumableMonitoringCapability/sensor-all failed to configure Error: Handle may only be configured while the MQTT controller is not initialized
    at PropertyMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:160:19)
    at ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:167:29)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ConsumableMonitoringCapabilityMqttHandle.configure (/snapshot/Valetudo/backend/lib/mqtt/handles/RobotStateNodeMqttHandle.js:30:9)
    at async /snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:162:17
    at async MqttController.reconfigure (/snapshot/Valetudo/backend/lib/mqtt/MqttController.js:452:13)
    at async ConsumableMonitoringCapabilityMqttHandle.findNewConsumables (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:153:13)
    at async ConsumableMonitoringCapabilityMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ConsumableMonitoringCapabilityMqttHandle.js:168:9)
    at async RobotMqttHandle.refresh (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:225:13)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
flacjacketcommented, Jun 3, 2021

I can confirm that using the version built here fixes this problem for me.

1reaction
Hypfercommented, Jun 25, 2021

So theres still a race condition somewhere.

@Depau already had some ideas how to fix this properly:

Davide Depau 🏳️‍🌈, [31.05.21 11:24] I think this should need a more careful implementation using this mutex idea but with a proper finite state machine, with some additional internal states that map to homie state “init” but that has a more specific internal meaning

Davide Depau 🏳️‍🌈, [31.05.21 11:24] This way we can have a proper table of allowed state transitions

Davide Depau 🏳️‍🌈, [31.05.21 11:29] Which can be something like

DISCONNECTED → STARTUP → RECONFIGURE → READY reconfigure: READY → RECONFIGURE → READY shutdown: READY → TEARDOWN → DISCONNECTED

with STARTUP being a fake state that is only triggered explicitly by the mqtt controller to otherwise disallow going from disconnected to reconfigure, and TEARDOWN being otherwise identical to RECONFIGURE except any other state transition will fail

Davide Depau 🏳️‍🌈, [31.05.21 11:31] With allowed transitions:

DISCONNECTED: STARTUP STARTUP: RECONFIGURE RECONFIGURE: READY READY: RECONFIGURE, TEARDOWN TEARDOWN: DISCONNECTED

Davide Depau 🏳️‍🌈, [31.05.21 11:32] The advantage of this approach is that while it sounds kinda complex it’s actually extremely easy to implement and extremely hard to mess up being there a finite number of states

Davide Depau 🏳️‍🌈, [31.05.21 11:37] It might make sense though to have an additional error state in case mqtt.js explodes

Davide Depau 🏳️‍🌈, [31.05.21 11:37] Which can only take the shutdown route, then needs to do the reconnection

Davide Depau 🏳️‍🌈, [31.05.21 11:39] I noticed that while mqtt.js technically does handle reconnection, it sometimes will lose subscriptions to topics, so it’s probably better to stick in an error state as long as MQTT.js is not working, then take it down and reconnect

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Transient Error Handling for an MQTT Trigger
The transient error handling properties that you specify for an MQTT trigger determines the number of times Integration Server retries a trigger service ......
Read more >
Resolving problem: MQTT client does not connect - IBM
Attempt to isolate the problem by running another client. Run the MQTT sample application using the same telemetry channel. Run the wmqttSample GUI...
Read more >
Error in connection to MQTT server - Home Assistant Community
I have the mosquito server running and the config file looks OK. Seems the connection is refused. Traceback (most recent call last): File...
Read more >
Solved: MQTT client error - Infineon Developer Community
I am testing AnyCloud MQTT-Client on CY8CKIT-062S2-43012. I always got error ''MQTT connection failed with error code.
Read more >
How to handle failed connections with Flask-MQTT
I faced a similar error. Everything was working fine when the mqtt server was running but if I started the app with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found