PaulAnnekov / tuyaha

Implements the special Tuya Home Assistant API.
Other
142 stars 106 forks source link

current sensor for smart plugs #5

Closed fondberg closed 4 years ago

fondberg commented 5 years ago

great job with this library and component!

I was wondering if it is possible to get the amp current measurement from a switch device?

PaulAnnekov commented 5 years ago

Do you have a tuya switch which displays this data in a mobile app?

srozb commented 5 years ago

I do. It's tuya smart switch branded as Smart DGM for polish market. I'm also interested in power consumption monitoring so let me know if I can help somehow.

fondberg commented 5 years ago

I have 2 devices. The gosund sp1 and gosund sp111. Both have energy monitoring. I'm not sure about the cloud api but it is possible to get the consumption using tuyapi

PaulAnnekov commented 5 years ago

I need to know what API reports. You can run the following python script inside tuyaha folder:

import tuyaha
client = tuyaha.TuyaApi()
client.init("<username>", "<password>", "<countrycode>", "<provider: tuya|smart_life|jinvoo_smart>")
print(client.discovery())

and give the output.

Martin781 commented 5 years ago

Sadly it doesn't return the energy monitoring values:

[{'data': {'online': True, 'state': True}, 'name': 'switch1', 'icon': 'https://images.tuyaeu.com/smart/icon/1541647698myzx2yx1yk_0.jpg', 'id': 'xxxxxxxxxxxxxxxxxxxx', 'dev_type': 'switch', 'ha_type': 'switch'}, {'data': {'online': True, 'state': False}, 'name': 'switch2', 'icon': 'https://images.tuyaeu.com/smart/icon/1541647698myzx2yx1yk_0.jpg', 'id': 'xxxxxxxxxxxxxxxxxxxx', 'dev_type': 'switch', 'ha_type': 'switch'}, {'data': {'online': True, 'state': False}, 'name': 'switch3', 'icon': 'https://images.tuyaeu.com/smart/icon/1541647698myzx2yx1yk_0.jpg', 'id': 'xxxxxxxxxxxxxxxxxxxx', 'dev_type': 'switch', 'ha_type': 'switch'}, {'data': {'online': True, 'state': False}, 'name': 'switch4', 'icon': 'https://images.tuyaeu.com/smart/icon/1541647698myzx2yx1yk_0.jpg', 'id': 'xxxxxxxxxxxxxxxxxxxx', 'dev_type': 'switch', 'ha_type': 'switch'}, {'data': {'online': True, 'state': False}, 'name': 'switch5', 'icon': 'https://images.tuyaeu.com/smart/icon/1541647698myzx2yx1yk_0.jpg', 'id': 'xxxxxxxxxxxxxxxxxxxx', 'dev_type': 'switch', 'ha_type': 'switch'}]

These are BlitzWolf BW-SHP6 smart sockets.

PaulAnnekov commented 4 years ago

As you understand, if existing API doesn't have these values, there is no way to support them.