tuya-iot-python-sdk
tuya-iot-python-sdk copied to clipboard
get energy stats?
Hi, is there a way to get the energy statistics of the device via this API or via general cloud API calls? That would be really great, as that is an important feature for most of the users.
Thx!
I found this one: https://developer.tuya.com/en/docs/cloud/device-data-statistic?id=Ka7g7nvnad1rm
Unfortunately I don't know which service needs to be authorized to allow the usage. Currently I get code 1004 as result.
1004 means the signature is invalid. Can you provide your code and logs?
I added the following code before this line (https://github.com/tuya/tuya-iot-python-sdk/blob/83f1e999d75ef87b2170ffbbb239ca8651dab0c3/tuya_iot/device.py#L577):
def get_device_stats(self, device_id: str) -> dict[str, Any]:
response = self.api.get(f"/v1.0/devices/{device_id}/statistics/hours")
return response
Do I need to use a different api to access such endpoints?