[App][Pro] MQTT Broker for Homey

Sorry I was too quick, because it works with a trick77. I got the idea because of this query:

https://github.com/search?q="homey"+AND+"onUnload"&ref=opensearch&type=repositories

Now my onInit() looks like this:

this.homey.on('unload', this.onUnload.bind(this));

That’s still broken, try this for instance:

  onUnload() {
    this.log('unUnload called!');
    Promise.resolve().then(() => console.log('GOT HERE!'));
  }

Then run your app in one window, keep it running, then run it again in another window. You’ll see that it will log unUnload called! but not GOT HERE!

That’s because any asynchronous code (like most likely any cleanup code will be) inside the handler will not be run.

This is how I use it with devices, for example:

onInit()

this.#mqttClient = MqttClient.getInstance(this, options.rootTopic);

onUnload()

this.#mqttClient.end(true);

I haven’t had any problems since then.

Hi Menno

Sorry for the delay, but I was able to test the new version and it seems to work fine, except for the problem with the configuration. If you still have problems just contact me again.

Chris

The app was constantly crashing with the following error.
Uninstalling and installing either of the regular or experimental versions didn’t work.
It seems to have stopped after disabling password hashing.
The password didn’t contain any special characters, just letters and numbers.

TypeError [ERR_INVALID_ARG_TYPE]: The "password" argument must be of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView. Received undefined
    at check (node:internal/crypto/pbkdf2:89:14)
    at Object.pbkdf2Sync (node:internal/crypto/pbkdf2:67:5)
    at hashPassword (/app/hashpwd.js:24:22)
    at machPasswords (/app/hashpwd.js:46:17)
    at Object.machPasswords (/app/hashpwd.js:11:14)
    at Aedes.authUser [as authenticate] (/app/broker.js:245:34)
    at ClientPacketStatus.authenticate (/app/node_modules/aedes/lib/handlers/connect.js:106:17)
    at makeCallTwo (/app/node_modules/fastseries/series.js:150:3)
    at release (/app/node_modules/fastseries/series.js:138:7)
    at resultList (/app/node_modules/fastseries/series.js:125:3)

Since it seems Athom has created their own MQTT broker, I will abandon this app. Unless someone gives me a good reason why I should continue this.

I’m not sure Athom’s MQTT Server is a “general purpose” broker. For the moment i haven’t been able to use it in place of this app.
My use case will probably seem unorthodox. As there is no app for my solar inverter I crafted a python script that runs on an RPI that is used for various other tasks also. The script reads data from the inverter and sends it as MQTT messages through this app, the MQTT Client app picks up relevant topics and then a flow updates a virtual device. Convoluted but it works reliably.
So far I haven’t been able to get this to work with Athom’s app. Clients appear to connect but no messages comes through.

Have you reported this issue on Github?

From what I understand, the “official” app only gained trigger cards for topic a few days ago:

Nope, haven’t reported, just assumed it wasn’t in the intended scope of the official app.
Hadn’t noticed that it now got cards, perhaps it only works with it’s built in client. Will check when I get a chance, only have the “production system” to test on.

With regard to my previous comments on the need for this app, after further experimenting with the official app I have concluded that it supports my use case. Basically, forget everything I said in this thread.