anerdins / nibepi

Backend for Nibe F series heatpump
MIT License
153 stars 36 forks source link

Use built in retry connection mechanism in MQTT.js when connection to broker fails #5

Open ulmerkott opened 3 years ago

ulmerkott commented 3 years ago

This fixes two problems:

  1. If connection to broker fails initially nibepi wouldn't try to reconnect. This could happen typically after a power outage if the broker server starts slower than nibepi (I'm looking at you homeassistant)
  2. When 1. occurs, nibepi didn't try to connect to broker even after toggling the MQTT setting in UI. In this case startingMQTT was always true and handleMQTT() would never call startMQTT().
nord73 commented 2 years ago

Very good fix for the intermittent MQTT issues!

stoffej commented 2 years ago

where is the file located on the raspberry pi with a nibepi installed. I have been searching but no success.

ulmerkott commented 2 years ago

where is the file located on the raspberry pi with a nibepi installed. I have been searching but no success.

You can replace the existing file with the following command. Please note that you need to remount the filesystem as read-write first. You can do that by unchecking Settings->System->Read-only checkbox in the UI.

scp index.js pi@<your-nibepi-ip>:/home/pi/.node-red/node_modules/nibepi/index.js

Then remount as read-only again and restart your nibepi.