cbrandlehner / homebridge-daikin-local

Supports Daikin Air Conditioners on HomeBridge
MIT License
99 stars 18 forks source link

plugin crashes if HTTP response is not a JSON as expected #9

Closed cbrandlehner closed 5 years ago

cbrandlehner commented 5 years ago

Describe the bug In case you connect to a not supported device, eg by mistaking the IP address, the plugin crashes.

To Reproduce Information on your wifi gateway from the daikin app:

  1. Firmware version: 1.2.51
  2. If known: Model information of the wifi gateway: 0AB9

Information on your configuration:

  1. Homebridge config
    "accessories": [
        {
            "accessory": "Daikin-Local",
            "name": "Living room",
            "apiroute": "http://192.168.1.50"
        },
        {
            "accessory": "Daikin-Local",
            "name": "Master bedroom",
            "apiroute": "http://192.168.1.51"
        }
    ],

Information from the log:

  1. Homebridge log file showing relevant information.
    
    6/20/2019, 6:30:53 AM] [Master bedroom] Successfully established connection.
    [6/20/2019, 6:30:53 AM] SyntaxError: Unexpected token 
    in JSON at position 8
    at JSON.parse (<anonymous>)
    at Daikin.<anonymous> (/root/.nvm/versions/node/v11.10.0/lib/node_modules/homebridge-daikin-local/index.js:437:21)
    at Request.self.callback (/root/.nvm/versions/node/v11.10.0/lib/node_modules/homebridge-daikin-local/node_modules/request/request.js:185:22)
    at Request.emit (events.js:197:13)
    at Request.<anonymous> (/root/.nvm/versions/node/v11.10.0/lib/node_modules/homebridge-daikin-local/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:197:13)
    at IncomingMessage.<anonymous> (/root/.nvm/versions/node/v11.10.0/lib/node_modules/homebridge-daikin-local/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:285:13)
    at IncomingMessage.emit (events.js:202:15)
    at endReadableNT (_stream_readable.js:1129:12)
    [6/20/2019, 6:30:53 AM] Got SIGTERM, shutting down Homebridge...


**Expected behavior**
Expecting no crash.

**Screenshots**
n/a

**Additional context**
nothing to add.
cbrandlehner commented 5 years ago

fixed in 2019.25.1