ilcato / homebridge-mqttswitch

Homebridge accessory plugin that create an HomeKit Switch based on MQTT topics
Apache License 2.0
31 stars 41 forks source link

Cannot read property 'replace' of null #2

Closed tvillingett closed 8 years ago

tvillingett commented 8 years ago

Something is not ok with the MQTT server call...

Loading 1 accessories...
[mqtt_test_switch] Initializing mqttswitch accessory...
/usr/local/lib/node_modules/homebridge-mqttswitch/node_modules/mqtt/lib/connect/index.js:62
    opts.protocol = opts.protocol.replace(/\:$/, '');
                                 ^

TypeError: Cannot read property 'replace' of null
    at Object.connect (/usr/local/lib/node_modules/homebridge-mqttswitch/node_modules/mqtt/lib/connect/index.js:62:34)
    at new MqttSwitchAccessory (/usr/local/lib/node_modules/homebridge-mqttswitch/index.js:64:21)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:175:29)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:36:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:23:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
tvillingett commented 8 years ago

My config looks like this:

        "accessories": [{
            "accessory": "mqttswitch",
            "name": "mqtt_test_switch",
                "username": " ",
                "password": " ",
            "url": "localhost",
                        "caption": "Test switch MQTT",
                        "topics": {
                                "statusGet":    "test/get/sw1",
                                "statusSet":    "test/set/sw1"
                        }
        }
]
tvillingett commented 8 years ago

I changed the host to "mqtt://127.0.0.1", apparantly that is what you get if you don't use a correct URL