AtomBaf / homebridge-mqtt-tasmota

Homebridge handler for tasmota/MQTT devices
MIT License
5 stars 5 forks source link

New install - one Tasmota device: iFan - JSON error #14

Open roger-richards opened 1 month ago

roger-richards commented 1 month ago

Describe the bug New install and setup one device iFan with plugin HB-UI.

To Reproduce my plugin JSON:

{
    "name": "Ceiling Fan",
    "type": "fan",
    "url": "mqtt://localhost:1884",
    "topic": "tasmota_%06X",
    "fullTopic": "cmnd/tasmota_B7CCEB/",
    "debug": true,
    "_bridge": {
        "username": "0E:3A:D6:BB:A5:49",
        "port": 51250
    },
    "accessory": "mqtt-tasmota"
}

homebridge log error:

[16/05/2024, 10:04:02] [Ceiling Fan] Loaded homebridge-mqtt-tasmota v0.12.0 child bridge successfully
[16/05/2024, 10:04:02] [Ceiling Fan] New mqtt-tasmota accessory mqtt-tasmota
[16/05/2024, 10:04:02] [Ceiling Fan] Connecting to MQTT broker on mqtt://192.168.8.211:1884
[16/05/2024, 10:04:02] [Ceiling Fan] Built topic = "cmnd/tasmota_fan/LWT"
[16/05/2024, 10:04:02] [Ceiling Fan] LWT Status subscribe cmnd/tasmota_fan/LWT
[16/05/2024, 10:04:02] [Ceiling Fan] Built topic = "cmnd/tasmota_fan/RESULT"
[16/05/2024, 10:04:02] [Ceiling Fan] Built topic = "cmnd/tasmota_fan/FANSPEED"
[16/05/2024, 10:04:02] [Ceiling Fan] Built topic = "cmnd/tasmota_fan/STATE"
[16/05/2024, 10:04:02] [Ceiling Fan] Built topic = "cmnd/tasmota_fan/STATE"
[16/05/2024, 10:04:03] [Ceiling Fan] MQTT client connected
[16/05/2024, 10:04:03] Homebridge v1.8.1 (HAP v0.12.0) (Ceiling Fan) is running on port 51250.
[16/05/2024, 10:04:03] [Ceiling Fan] Message received cmnd/tasmota_fan/STATE, 

/var/lib/homebridge/node_modules/homebridge-mqtt-tasmota/src/fan.js:46
        message = JSON.parse(message.toString('utf-8'))
                       ^
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at MqttTasmotaFanAccessory.onMqttMessage (/var/lib/homebridge/node_modules/homebridge-mqtt-tasmota/src/fan.js:46:24)
    at MqttClient.emit (node:events:518:28)
    at handlePublish (/var/lib/homebridge/node_modules/homebridge-mqtt-tasmota/node_modules/mqtt/src/lib/handlers/publish.ts:172:11)
    at handle (/var/lib/homebridge/node_modules/homebridge-mqtt-tasmota/node_modules/mqtt/src/lib/handlers/index.ts:29:17)
    at work (/var/lib/homebridge/node_modules/homebridge-mqtt-tasmota/node_modules/mqtt/src/lib/client.ts:726:17)
    at processTicksAndRejections (node:internal/process/task_queues:77:11)
[15/05/2024,] [Ceiling Fan] Child bridge process ended
[15/05/2024,] [Ceiling Fan] Process Ended. Code: 1, Signal: null

Expected behavior no JSON error on a simple and clean setup.

Desktop (please complete the following information):

hombridge host (please complete the following information):

Additional context Mosquitto broker is setup on Raspberry pi and I can control the tasmota iFan via terminal: mosquitto_pub -p 1884 -m "toggle" I used JSONLint to check the entire homebridge config and it is clean.