py-air-control: Unable to get CoAP to work with AC2889/60
Firmware (from the app) reports as
Firmware Version: AWS_Philips_AIR@54.2 Device Version: 1.0.7 Model: AC2889/10
Any attempt to send a command just gets back {"status":"failed"} (looking at it via tcpdump). Also from tcpdump, the app appears to be exclusively using the cloud based system to talk to it. If I put both on a wifi network not connected to the internet, even the app doesn’t work.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 82 (40 by maintainers)
When we look at a Wireshark capture, we can see that the packet is not truncated. But the packet received by the library is indeed truncated.
The problem comes from the CoAPthon3 library. We can see in
coapthon/client/coap.py, line 239, methodreceive_datagram:I’ve cloned the CoAPthon3 library and modified this line to:
Now it works like a charm!
I will try submitting a PR to this external dependency, but there has been no update to the pip package since 2018, even if several PRs have been accepted since…
@spider7611 thanks for the feedback
I see they merged the patch submitted by @bobzomer for this: https://github.com/Tanganelli/CoAPthon3/issues/29
maybe we can put dependency to the latest code on github until they release on PyPI.
Thoughts?
Can confirm that this gets data on my AC2889/10 on version 1.0.7. Thanks for all the work guys.
Good news: I’ve forked the project using a new git branch: https://github.com/Cyber1000/py-air-control/tree/coap_1_0_7
general info (Everyone is invited to test 🧪 )
Installation (maybe you need sudo):
What works for now:
So you are getting information in json and list-format, writing to your device won’t work for now.
technical info (for everyone who likes to develop and improve my code/spike)
parser.add_argument('--version', help='set the version of your device ', choices=['0.1.0','0.2.1', '1.0.7'], default='0.1.0')Great work with the decryption! I’m not a python guy myself, but if it helps - I’ve put together a java sample here, which works with my AC3829/10.
@bocsitomcsi You seem to have the seem problem like https://github.com/rgerganov/py-air-control/issues/35#issuecomment-625288284 (btw. it’s AC2729/50 too) and some others here. The returning message is too long for a single coap-package, and is cut somewhere in the middle. I don’t know so far how to get multiple packages.
I just catch the exception now and you get a “Message from device got corrupted” therefore.
I’ll make a PR within the next 2 days with this known limitation and will look into this in the near future.
From your example:
encodedCounter: substring(0, 8) ‘23D56232’
decodedCounter: remove zeros in front if they exist. hex -> decimal = 601186866
I just tried it out:
My best guess is that you have installed CoAPthon3 multiple times:
I would try as “normal” user:
Maybe you have also installed some version with pip (and not pip3) as you mentioned correctly, that the README was wrong. Then a uninstall command with pip, similar to the shown above might help.
I also spend some time looking into this and came to the conclusion that putting a dependency to source control in
setup.pyis deprecated and considered bad practice. This is what the pip documentation says about cases like ours:So I updated the requirements file and put a note in the README (which needs to be fixed 😃 ).
After this modification:
Working my model Id: AC3858/50 too! airctrl --ipaddr 192.168.1.102 --protocol coap --pwr 1 Need home assistant integration! 😃
I have merged @Cyber1000’s PR into master, you are welcome to test with HEAD. I will release a new PyPI version when we fix the issues with the truncated CoAP response.
Thanks to everyone who contributed to the project so far!
@Cyber1000 Just to mention this: Your fork also works for my AC2889/10! Thanks!
This can be decrypted if we get a bigger chunk from the payload:
this is the result:
As you can see it is truncated. I guess this means we should either increase the COAP response buffer or make another request.
@Cyber1000 Iam running this
I’ve got a friend who does Android reversing who is willing to take at least a brief look at the app. I can go looking for a uart if I can’t return the AC2889. Will probably open up the AC3259/60 regardless to add a switch for the speaker.