TypeError: Cannot read property 'alias' of undefined
miso-develop opened this issue · comments
Miso Tanaka commented
When running examples/plug-turn-on-off.js on Smart Plug HS105, the following error occurs.
.\node_modules\tplink-smarthome-api\lib\device\index.js:98
this.log.debug('[%s] device sysInfo set', sysInfo.alias || this.alias);
^
TypeError: Cannot read property 'alias' of undefined
at Plug.setSysInfo (.\node_modules\tplink-smarthome-api
\lib\device\index.js:98:59)
at Plug.setSysInfo (.\node_modules\tplink-smarthome-api\lib\plug\index.js:182:15)
at new Plug (.\node_modules\tplink-smarthome-api\lib\plug\index.js:166:14)
at Client.getPlug (.\node_modules\tplink-smarthome-api\lib\client.js:179:16)
at Object.<anonymous> (.\index.js:7:21)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
Version
- v3.1.0
- v3.0.0
Execution environment
-
case1
- OS: Windows10 v1909
- Node.js: v12.16.3
-
case2
- OS: Raspbian v9.11
- Node.js: v12.20.0
Workaround
Install v2.0.0
etc
CLI(npx tplink-smarthome-api search
) also worked with v3.1.0.
Joe Helfrich commented
Getting the same trying to connect to a bulb.
const bulb = client.getBulb({host: '192.168.1.244'})
Uncaught TypeError: Cannot read property 'alias' of undefined
at Bulb.setSysInfo (C:\Users\joe\WebstormProjects\untitled\node_modules\tplink-smarthome-api\lib\device\index.js:98:59)
at Bulb.setSysInfo (C:\Users\joe\WebstormProjects\untitled\node_modules\tplink-smarthome-api\lib\bulb\index.js:123:15)
at new Bulb (C:\Users\joe\WebstormProjects\untitled\node_modules\tplink-smarthome-api\lib\bulb\index.js:109:14)
at Client.getBulb (C:\Users\joe\WebstormProjects\untitled\node_modules\tplink-smarthome-api\lib\client.js:166:16)
Patrick Seal commented
Since v3, using getPlug or getBulb require you to pass in the sysinfo for the device. Its preferred to use client#getDevice which does not have that requirement. I've corrected the example that was broken since v3.