arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
466 stars 103 forks source link

Homebridge crash #200

Closed ldellus closed 4 years ago

ldellus commented 4 years ago

Hi,

I have strange problem after upgrading node.js to 12.14.1. I uninstalled the plugin and reinstalled it and run npm rebuild --unsafe-perm in the /usr/local/lib/node_modules directory. I updated homebridge to the lasted version.

I have in my config.json two identical accessories of type mqttthing. The first one is named Power-Switch-1, the second one is named Power-Switch-2. With one only, everything's fine, with two, homebridge crashes with the following error. It used to work fine before.

------------------------------------------------

[1/26/2020, 7:35:31 PM] SyntaxError: Unexpected end of JSON input

at JSON.parse ()

at /usr/local/lib/node_modules/homebridge-mqttthing/index.js:1872:32

at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)


Here is my accessory definition: { "accessory": "mqttthing", "type": "outlet", "name": "Power-Switch-1", "url": "mqtt://192.168.1.xxx", "username": "xxxx", "password": "xxxx", "mqttOptions": { "keepalive": 30 }, "mqttPubOptions": { "retain": true }, "topics": { "getOn": "stat/POW-R2-Switch-1/POWER", "setOn": "cmnd/POW-R2-Switch-1/power", "getOnline": "tele/POW-R2-Switch-1/LWT", "getWatts": { "topic": "tele/POW-R2-Switch-1/SENSOR", "apply": "return JSON.parse(message).ENERGY.Power;" }, "getVolts": { "topic": "tele/POW-R2-Switch-1/SENSOR", "apply": "return JSON.parse(message).ENERGY.Voltage;" }, "getAmperes": { "topic": "tele/POW-R2-Switch-1/SENSOR", "apply": "return JSON.parse(message).ENERGY.Current;" } }, "history": "true", "logMqtt": true, "onValue": "ON", "offValue": "OFF", "onlineValue": "Online", "startPub": { "cmnd/POW-R2-Switch-1/power": "" }, "manufacturer": "ITEAD", "model": "Sonoff POW R2", "serialNumber": "CC:50:E3:54:80:AF" }, Thanks for any help you can provide.**

arachnetech commented 4 years ago

Did you find a solution to this?

ldellus commented 4 years ago

Hi,

I reinstalled homebridge and everything's fine now.

Thanks,

Laurent

arachnetech commented 4 years ago

Excellent, thanks for confirming.