rudders / homebridge-http

HTTP Plugin for Homebridge
Apache License 2.0
178 stars 110 forks source link

TypeError: Cannot read property '0' of undefined #79

Closed Buadhai closed 6 years ago

Buadhai commented 6 years ago

I just installed this yesterday. I worked fine. But, when I got up this morning I get the following error message:

TypeError: Cannot read property '0' of undefined
    at Server._createAccessory (/usr/local/lib/node_modules/homebridge/lib/server.js:390:17)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:276:26)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
/usr/local/lib/node_modules/homebridge/lib/server.js:390
  if (!(services[0] instanceof Service)) {
                       ^

Here's my configuration file:

{
    "bridge": {
        "name": "Koratbridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "Homebridge config file",

    "accessories": [
        {
            "accessory": "Http",
            "name": "Water Pump",
            "switchHandling": "realtime",
            "http_method": "GET",
            "on_url":      "http://192.168.0.55/cgi-bin/relaynew.cgi?on",
            "off_url":     "http://192.168.0.55/cgi-bin/relaynew.cgi?off",
            "status_url":  "http://192.168.0.55/cgi-bin/relaynew.cgi?state",
            "service": "Pump",
            "brightnessHandling": "no",
            "sendimmediately": "",
            "username" : "",
            "password" : ""
      }
    ]
}
Buadhai commented 6 years ago

I should note that the device and cgi urls are working fine:

MrMuscle:.homebridge mnewman$ curl http://192.168.0.55/cgi-bin/relaynew.cgi?state
0
MrMuscle:.homebridge mnewman$ curl http://192.168.0.55/cgi-bin/relaynew.cgi?on
OK
MrMuscle:.homebridge mnewman$ curl http://192.168.0.55/cgi-bin/relaynew.cgi?state
1
MrMuscle:.homebridge mnewman$ curl http://192.168.0.55/cgi-bin/relaynew.cgi?off
OK
MrMuscle:.homebridge mnewman$ curl http://192.168.0.55/cgi-bin/relaynew.cgi?state
0
Buadhai commented 6 years ago

I solved this by changing:

"service": "Pump",

to:

"service": "Light",

I also tried

"service": "Outlet",

But that didn't work.