imbrianj / switchBoard

Control of Internet connected devices within a given network via web interface.
MIT License
201 stars 53 forks source link

celsius bug during SmartThings Oath setup #68

Closed alljetnopilot closed 6 years ago

alljetnopilot commented 6 years ago

App errors out during the oath re-direct with the following error message

SmartThings: Fetching device url
/home/osmc/switchboard/devices/smartthings/controller.js:613
      smartthings.config    = { celsius : !!config.config.celsius };
                                                         ^

TypeError: Cannot read property 'celsius' of undefined
    at Object.module.exports.send (/home/osmc/switchboard/devices/smartthings/controller.js:613:58)
    at Object.module.exports.oauthUrl (/home/osmc/switchboard/devices/smartthings/controller.js:137:12)
    at Object.smartthings.callback (/home/osmc/switchboard/devices/smartthings/controller.js:87:18)
    at IncomingMessage.<anonymous> (/home/osmc/switchboard/devices/smartthings/controller.js:664:41)
    at IncomingMessage.g (events.js:286:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Commenting out the line 613 and retrying gets the following error message:

SmartThings: Auth data cached with URL
undefined: Fetching device info
/home/osmc/switchboard/devices/smartthings/controller.js:150
      config.config   = { celsius : config.config.celsius };
                                                 ^

TypeError: Cannot read property 'celsius' of undefined
    at Object.module.exports.oauthDeviceList (/home/osmc/switchboard/devices/smartthings/controller.js:150:50)
    at WriteStream.<anonymous> (/home/osmc/switchboard/devices/smartthings/controller.js:129:20)
    at WriteStream.g (events.js:286:16)
    at emitOne (events.js:96:13)
    at WriteStream.emit (events.js:188:7)
    at WriteStream.<anonymous> (fs.js:1884:10)
    at FSReqWrap.oncomplete (fs.js:117:15)

Commenting that line out gets it to run.

imbrianj commented 6 years ago

@alljetnopilot can you tell me what your file version is? It should be at the top of the /devices/smartthings/controller.js file: https://github.com/imbrianj/switchBoard/blob/master/devices/smartthings/controller.js#L32

alljetnopilot commented 6 years ago

version : 20171105

imbrianj commented 6 years ago

Awesome - thank you for reporting! Will try and get this sorted tonight.

imbrianj commented 6 years ago

Okay - I have a fixed device controller coming up soon. Thank you for reporting this - there were some object mapping issues there.

If you get an "Invalid data returned from API" in your log, can you just make sure that the URL doesn't have the OAuth code stuff? The console errors there are benign, but can occur if you just refresh the page after getting your auth token.

imbrianj commented 6 years ago

https://github.com/imbrianj/switchBoard/commit/3dd49194fa04adfffc5d5464529022999c121a86

Can you try 20171108 and let me know if you see any other issues?