Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing field `re_power_type #159

Closed
zaraquer opened this issue Jan 19, 2024 · 16 comments
Closed

missing field `re_power_type #159

zaraquer opened this issue Jan 19, 2024 · 16 comments

Comments

@zaraquer
Copy link

Hi!

I recieved this error booth on rust and python examples on L510 bulbs.
Error: Serde(Error("missing field re_power_type", line: 1, column: 550))
I want to use the client to monitor the power usage of the bulbs.
What can I do to fix this issue?

@mihai-dinculescu
Copy link
Owner

It looks like this is a regression of the change in #135.
Can you please call get_device_info_json instead of get_device_info, and paste the output here?

@zaraquer
Copy link
Author

After I changed get_device_info to get_device_info_json it works great.:

2024-01-19T09:11:54.974Z INFO tapo_l510 > Device usage: DeviceUsageEnergyMonitoringResult { time_usage: UsageByPeriodResult { today: 28, past7: 1211, past30: 13237 }, power_usage: UsageByPeriodResult { today: 1, past7: 172, past30: 1829 }, saved_power: UsageByPeriodResult { today: 27, past7: 1039, past30: 11408 } }

Thanks for the help and your great work mate!

@mihai-dinculescu
Copy link
Owner

Sorry, the output that's pasted above is for device usage.
Can you please provide the one for device info?

@zaraquer
Copy link
Author

zaraquer commented Jan 19, 2024

Sure, I just changed the sensitive parts.

Device info: Object {"avatar": String("bulb"), "brightness": Number(30), "default_states": Object {"brightness": Object {"type": String("last_states"), "value": Number(30)}}, "device_id": String("8023C0D888DD972F67F68BF0809ABE791EF4B5E0"), "device_on": Bool(false), "fw_id": String("7BECA9DC454565672FEC87D1104F9972"), "fw_ver": String("1.3.0 Build 20230831 Rel. 75926"), "has_set_location_info": Bool(true), "hw_id": String("93F94D88DA9499F43B929DD38EBDF09A"), "hw_ver": String("1.0.0"), "ip": String("xx.xx.xx.xx"), "lang": String("hu_HU"), "latitude": Number(21412431), "longitude": Number(212141), "mac": String("11-11-11-11-11-11"), "model": String("L510 Series"), "nickname": String("S29ueWhh"), "oem_id": String("6B97E8E19CE8019B59D9E81CEDD371BD"), "on_time": Number(0), "overheated": Bool(false), "region": String("Europe/Budapest"), "rssi": Number(-46), "signal_level": Number(3), "specs": String("EU"), "ssid": String("V29yay1OZXR3b3Jr"), "time_diff": Number(60), "type": String("SMART.TAPOBULB")}

Not fully okay as I see it now, because it wont get forexample the nickname correctly.

@mihai-dinculescu
Copy link
Owner

mihai-dinculescu commented Jan 19, 2024

Thank you, this is very helpful.

The get_device_info_json function gives the response as it comes from the Tapo API without trying to parse it in any way. Decoding the nickname is part of the parsing that get_device_info does.

I know what needs changing now. re_power_type seems optional.

@mihai-dinculescu
Copy link
Owner

The fix has been released in Tapo Rust v0.7.8 and Tapo Python v0.1.5.

@mihai-dinculescu
Copy link
Owner

@zaraquer, it would be lovely if you could try out the new version. I suspect that there might be some further errors :(

@zaraquer
Copy link
Author

zaraquer commented Jan 22, 2024

Thanks! I will check it today a bit later. Sorry for the late answer, I was away from my computer. BTW thanks again for your fast and amazing work!

@zaraquer
Copy link
Author

I tried the python version first.
With get_device_info:

Traceback (most recent call last):
File "/root/tapo/tapo-py/examples/tapo_l510.py", line 40, in
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/root/tapo/tapo-py/examples/tapo_l510.py", line 32, in main
device_info = await device.get_device_info()
Exception: Serde(Error("missing field re_power_type", line: 1, column: 539))

After I changed it to get_device_info_json:

Traceback (most recent call last):
File "/root/tapo/tapo-py/examples/tapo_l510.py", line 40, in
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/root/tapo/tapo-py/examples/tapo_l510.py", line 33, in main
print(f"Device info: {device_info.to_dict()}")
AttributeError: 'dict' object has no attribute 'to_dict'

@mihai-dinculescu
Copy link
Owner

mihai-dinculescu commented Jan 23, 2024

Are you sure you're using the latest version? I'm surprised to see the missing field re_power_type error occurring.

to_dict is required only on the result of get_device_info.
get_device_info_json returns a dict straight up, so you should not call to_dict on its result.

@zaraquer
Copy link
Author

Yeah, its the latest.

git log

commit 4923824 (HEAD -> main, origin/main, origin/HEAD)
Author: Dinculescu mihai.dinculescu@outlook.com
Date: Sun Jan 21 21:23:35 2024 +0000

tapo-py: Add support for the L530, L630, and L900 devices

Addresses #123.

commit e9d2953 (tag: py-v0.1.5)
Author: Dinculescu mihai.dinculescu@outlook.com
Date: Sat Jan 20 21:28:49 2024 +0000

tapo-py: Release v0.1.5

commit c8307d5 (tag: v0.7.8)
Author: Dinculescu mihai.dinculescu@outlook.com
Date: Sat Jan 20 21:27:13 2024 +0000

Release v0.7.8

I'm testing with the example's.

@zaraquer
Copy link
Author

Okay, I deleted dict, now this is what I get:

python examples/tapo_l510.py
Turning device on...
Waiting 2 seconds...
Setting the brightness to 30%...
Waiting 2 seconds...
Turning device off...
Device info: {'avatar': 'bulb', 'brightness': 30, 'default_states': {'brightness': {'type': 'last_states', 'value': 30}}, 'device_id': '8023C0D888DD972F67F68BF0809ABE791EF4B5E0', 'device_on': False, 'fw_id': '7BECA9DC454565672FEC87D1104F9972', 'fw_ver': '1.3.0 Build 20230831 Rel. 75926', 'has_set_location_info': True, 'hw_id': '93F94D88DA9499F43B929DD38EBDF09A', 'hw_ver': '1.0.0', 'ip': 'xx.xx.xx.xx', 'lang': 'hu_HU', 'latitude': 554786, 'longitude': 332565, 'mac': 'aa-aa-aa-aa-aa-aa', 'model': 'L510 Series', 'nickname': 'S29ueWhh', 'oem_id': '6B97E8E19CE8019B59D9E81CEDD371BD', 'on_time': 0, 'overheated': False, 'region': 'Europe/Budapest', 'rssi': -46, 'signal_level': 3, 'specs': 'EU', 'ssid': 'V29yay1OZXR4b3Jr', 'time_diff': 60, 'type': 'SMART.TAPOBULB'}
Device usage: <builtins.DeviceUsageEnergyMonitoringResult object at 0x7f1f75495590>

@mihai-dinculescu
Copy link
Owner

mihai-dinculescu commented Jan 23, 2024

Hmm, before running the example, can you please run

cd tapo-py
poetry install
poetry shell
maturin develop

and try get_device_info again?

@zaraquer
Copy link
Author

I did what you suggest:

(tapo-Q5KVV4uC-py3.10)~/tapo/tapo-py# python examples/tapo_l510.py
Turning device on...
Waiting 2 seconds...
Setting the brightness to 30%...
Waiting 2 seconds...
Turning device off...
Traceback (most recent call last):
  File "/root/tapo/tapo-py/examples/tapo_l510.py", line 40, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/root/tapo/tapo-py/examples/tapo_l510.py", line 32, in main
    device_info = await device.get_device_info()
Exception: Serde(Error("missing field `dynamic_light_effect_enable`", line: 1, column: 722))

@mihai-dinculescu
Copy link
Owner

That's brilliant, thank you. This error does make sense, and it's what I was afraid of.
I'll have a fix in the next couple of days.

mihai-dinculescu added a commit that referenced this issue Jan 27, 2024
@mihai-dinculescu
Copy link
Owner

The fix has been released in Tapo Rust v.0.7.9 and Tapo Python v0.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants