washcroft / homebridge-http-garagedoorcontroller

An HTTP based Garage Door/Light plugin for HomeBridge
MIT License
15 stars 7 forks source link

TypeError: Cannot read property 'setValue' of undefined #8

Closed phoozle closed 6 years ago

phoozle commented 6 years ago

Awesome plugin! Glad someone finally wrote a proper HTTP based garage controller for Homebridge

I am having an issue when no lightName is set:

[25/11/2017, 4:42:56 PM] Homebridge is running on port 51827.
[25/11/2017, 4:42:56 PM] [Garage Door] Request completed!
[25/11/2017, 4:42:56 PM] [Garage Door] Entered _setDoorCurrentState(state: CLOSED, initial: true, isFromTargetState: false)
[25/11/2017, 4:42:56 PM] [Garage Door] INITIAL Garage Door state is: CLOSED
[25/11/2017, 4:42:56 PM] [Garage Door] Entered _setDoorTargetState(state: CLOSED, initial: true, isFromCurrentState: true)
[25/11/2017, 4:42:56 PM] [Garage Door] INITIAL Garage Door target state is: CLOSED
[25/11/2017, 4:42:56 PM] [Garage Door] Entered setDoorTargetState(newState: CLOSED)
[25/11/2017, 4:42:56 PM] [Garage Door] Entered _determineLightState()
[25/11/2017, 4:42:56 PM] [Garage Door] Entered _setLightCurrentState(state: undefined, initial: true)
[25/11/2017, 4:42:56 PM] [Garage Door] INITIAL Garage Light state is: OFF
/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:638
        this.garageLightCurrentState.setValue(this._lightCurrentState);
                                    ^

TypeError: Cannot read property 'setValue' of undefined
    at Object.encodeURIComponent.replace.HttpGarageDoorControllerAccessory._setLightCurrentState (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:638:31)
    at /usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:494:12
    at Object.encodeURIComponent.replace.HttpGarageDoorControllerAccessory._determineLightState (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:556:4)
    at Mutex.<anonymous> (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:490:10)
    at Mutex.unlock (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/node_modules/locks/lib/Mutex.js:66:10)
    at /usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:482:22
    at /usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:548:4
    at Request._callback (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/index.js:827:5)
    at Request.self.callback (/usr/local/lib/node_modules/homebridge-http-garagedoorcontroller/node_modules/request/request.js:186:22)
    at emitTwo (events.js:87:13)

My config is as follows:

{
   "bridge":{
      "name": "Homebridge",
      "username": "CC:22:3D:E3:CE:40",
      "port": 51827,
      "pin": "123-45-678"
   },
   "description": "Homebridge",
   "accessories": [
    {
      "accessory": "HttpGarageDoorController",
      "name": "Garage Door",

      "httpHost": "192.168.178.31",
      "httpPort": 80,
      "httpSsl": false,
      "httpStatusPollMilliseconds": 4000,
      "httpRequestTimeoutMilliseconds": 10000,

      "apiConfig": {
        "apiType": "Generic",

        "doorOperationSeconds": 13,

        "doorOpenMethod": "GET",
        "doorOpenUrl": "/arduino/open",
        "doorOpenSuccessContent": "",

        "doorCloseMethod": "GET",
        "doorCloseUrl": "/arduino/close",
        "doorCloseSuccessContent": "",

        "doorStateMethod": "GET",
        "doorStateUrl":"/arduino/state"
      }
    }
   ]
}