iomax / homebridge-mqttgaragedoor

Homebridge accessory plugin that create an HomeKit Garage Door Opener mapped on MQTT topics
Apache License 2.0
8 stars 9 forks source link

Getting a length error on topic #13

Closed peteroz12 closed 5 years ago

peteroz12 commented 5 years ago

I'm getting the following error message when Homebridge runs: _/usr/lib/node_modules/homebridge-mqttgaragedoor/nodemodules/mqtt/lib/validations.js:42 for (var i = 0; i < topics.length; i++) { TypeError: Cannot read property 'length' of undefined

This is my config file: "accessories": [{ "accessory": "Mqttgarage", "name": "Garage Door", "url": "http://1.1..1:1883", "caption": "Garage Door", "lwt": "", "lwtPayload": "lwt Payload", "topics": { "statusSet": "garadget/Queenscliff/command", "openGet": "garadget/Queenscliff/status", "openValue": "open", "closedValue": "closed", "openStatusCmdTopic": "garadget/Queenscliff/command", "openStatusCmd": "get-status", "closeStatusCmdTopic": "garadget/Queenscliff/command", "closeStatusCmd": "get-status" }, "doorRunInSeconds": "10", "pauseInSeconds" : "" }]

I've managed to try some other MQTT Homebridge plugins, so I'm pretty sure I have the syntax right. I'm using a garadget (https://community.garadget.com/t/mqtt-support/3226/5).

Any idea what I'm doing wrong?

iomax commented 5 years ago

I'd try "url" : "mqtt://ipaddress". ( https://github.com/iomax/homebridge-mqttgaragedoor/issues/12#issuecomment-447417721 )

peteroz12 commented 5 years ago

Thanks, but I'm still getting the same error.

iomax commented 5 years ago

What if removing "empty or unused" params, like "lwt": "" and "pauseInSeconds" : "" ?

peteroz12 commented 5 years ago

Hi sadly nope still the same error of

for (var i = 0; i < topics.length; i++) { ^

iomax commented 5 years ago

Then maybe a library version mismatch between my and your setup ... I'll try to investigate it but a full trace log regarding the error will be needed.

peteroz12 commented 5 years ago

Ah.... appears I somehow ended up with an older version, fixed that and now working without the above error.

Now I'm having trouble understanding why I can't get the topics working... I have a MQTT client watching what is coming through and using that I can send and receive status, but when I go to use the plugin it doesn't seem to work.

The "garadget/Queenscliff/status" topic contains a status update on the garage door with the following four statuses:

{"status":"opening","time":"0s","sensor":0,"bright":1,"signal":-39} {"status":"open","time":"0s","sensor":4,"bright":70,"signal":-40} {"status":"closing","time":"0s","sensor":0,"bright":41,"signal":-40} {"status":"closed","time":"6m","sensor":97,"bright":14,"signal":-41}

To send a command I use the topic "garage/Queenscliff/command" to send one of the following commands:

open close get-status

I have the accessory setup as:

    "accessory": "mqttgaragedoor",
    "name": "Garage Door",
    "url": "mqtt://10.10.0.110",
    "caption": "Garage Door",
    "lwtPayload": "lwt Payload",
    "topics": {
        "statusSet": "garadget/Queenscliff/status",
        "openGet": "garadget/Queenscliff/command",
        "openValue": "open",
        "closedValue": "closed",
        "openStatusCmdTopic": "garadget/Queenscliff/command",
        "openStatusCmd": "open",
        "closeStatusCmdTopic": "garadget/Queenscliff/command",
        "closeStatusCmd": "close"
    },
    "doorRunInSeconds": "10"

It will send the command to open the garage door, but then it doesn't show the correct status or let me close the door. Have I configured it wrong?

iomax commented 5 years ago

The plugin do send the commands just via the "statusSet" topic, all others topic are just to get the various feedback about the door state. Even the "complex" topic payload ( like JSON structure from your example ) can be a problem at this time.