6 Sept 2024, 10:09

@Emil I use the MQTT publisher from https://github.com/id628/flic2hass. It constantly writes to console following error:

Error: Crashed
    at <anonymous> (root/MQTT/main.js:226)
    at runNextTimeout (core.js:964)

and the underlying exception is:

TypeError: class constructors must be invoked with 'new'
    at Socket (core.js:1158)
    at <anonymous> (root/MQTT/mqtt.js:418)
    at <anonymous> (root/MQTT/main.js:230)
    at require (core.js:2895)
    at requireMain (core.js:2903)
    at handlePacket (core.js:2937)
    at onPipeData (core.js:2974)

It seem the line 418 in mqtt.js:

client = require("net").Socket().connect({ host: mqo.server, port: mqo.port }, onConnect);

has to be changed to:

const net = require("net")
...
client = new net.Socket().connect({ host: mqo.server, port: mqo.port }, onConnect);