plasticrake / tplink-smarthome-api

TP-Link Smarthome WiFi API
MIT License
1.02k stars 141 forks source link

Timeout handler #114

Closed berenteb closed 2 years ago

berenteb commented 3 years ago

I couldn't find any documentation related to error/timeout handling. I'm writing a Homebridge plugin with this API (I know TP-Link plugin already exists, I'm creating a TV accessory). Homebridge will probably freeze if the selected device is offline or not found. I'll add a config field to set the plug mac of the TV, so I've set the mac address filter in the startDiscovery function.

plasticrake commented 2 years ago

Nearly all the commands return a promise. You would either use .catch() or try-catch with await. If you're specifically referring to startDiscovery it emits an "error" event as listed in the documentation: https://plasticrake.github.io/tplink-smarthome-api/classes/client.html#startdiscovery