ClementNerma / tapo-rest

An unofficial REST API to remotely control Tapo devices
36 stars 3 forks source link

Feature Request | Discovery Endpoint #3

Closed NyasakiAT closed 1 year ago

NyasakiAT commented 1 year ago

Would be nice to be able to call a endpoint like /devices to get all devices and their type. So curl -i -X GET -H 'Authorization: Bearer <your session ID>' 'http://localhost:8000/devices' would return the following

{
    "name": "Bulb1",
    "device_type": "L630"
},
{
    "name": "Bulb2",
    "device_type": "L630"
},
{
    "name": "Bulb3",
    "device_type": "L630"
}

This would add support for automatic discovery of devices so whatever consumes the API knows what devices are avaliable and their device type so they know how to address them

ClementNerma commented 1 year ago

Hi, thanks for your feedback!

I've created a route you can hit on /discovery, which will return a list of all connected devices along with their type. Note that this route will always require to be authenticated.

Tell me if the route suits your needs :)

NyasakiAT commented 1 year ago

Hey, you named it discover https://github.com/ClementNerma/tapo-rest/commit/32e2480440575c9b1f8327d59c2f67fe6e550539#diff-1b33b1af1a8e35c4f324cac560774fc81865de0181472f33fd544f199e8cf931R52

But yes that works as expected Thanks a lot :)