smartathome icon indicating copy to clipboard operation
smartathome copied to clipboard

[FEATURE REQUEST] Show power information for smart sockets

Open KaMyKaSii opened this issue 2 years ago • 6 comments

I would like to be able to see this information without relying on my smartphone. Thank you.

KaMyKaSii avatar Jul 23 '22 20:07 KaMyKaSii

What model number do you have?

ndg63276 avatar Jul 23 '22 21:07 ndg63276

This one. If you need the Smart Life app private traffic I can provide it for you.

KaMyKaSii avatar Jul 23 '22 21:07 KaMyKaSii

If you open the developer console (F12 key usually) and type

device_list

You should get a list of your devices. If you expand the details for the smart socket, you could see if the information is already in the data the website gets from Smartlife. If it is, I can add it to the website. If not, I can't.

ndg63276 avatar Jul 23 '22 21:07 ndg63276

I think my needs match the author's feature request. So I analyzed library scripts, and I see that only 3endpoints are used: auth.do access.do skill

But for measuring consumption, there is "logs" endpoint. I used tuya cloud explorer. From documentation: GET /v1.0/devices/xxxid/logs?start_row_key=xxxx_1&type=1,2&start_time=1545898159931&end_time=1545898159935&size=20

or real example: curl --request GET "https://openapi.tuyaeu.com/v1.0/devices/xxxx_1/logs?end_time=1761779264392&start_time=0&type=7" --header "sign_method: HMAC-SHA256" --header "client_id: xxxxx" --header "t: 1661293844933" --header "mode: cors" --header "Content-Type: application/json" --header "sign: yyyyyy" --header "access_token: zzzz"

where 7 data point report, (Types supported by log query. Supports query of multiple event types, separated by commas (,), must be transmitted. (1 online, 2 offline, 3 device activation, 4 device reset, 5 instructions Issue, 6 firmware upgrade, 7 data point report, 8 device semaphore, 9 device restart, 10 timing information))

and results are paginated.

My device is: "model": "SMART PLUG-WIFI-D", "name": "SMART PLUG",

Could you add support for visualizing power consumption? That's what I managed to draw from logs via excel image It seems data is enough for that

Thanks

webmake avatar Aug 23 '22 22:08 webmake

Oooh, nice work. Gonna be hard though, my site is using an old API set up for homeassistant, https://px1.tuyaeu.com/homeassistant/. Can you point me towards the documentation you mention? Did you have to register to use openapi.tuyaeu.com? And what smart plug do you have?

ndg63276 avatar Aug 24 '22 09:08 ndg63276

@webmake from where you get the access_token value? I'm intercepting the Smart app (Android) traffic with ssl pinning disabled but with the calls to https://a1.tuyaus.com/log.json I can only get other parameters like cliendId, sign, deviceId, sid, ttid...

KaMyKaSii avatar Aug 24 '22 14:08 KaMyKaSii