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

Magic Home Integration cant connect to RGB Controller #77005

Closed
Buonoster opened this issue Aug 18, 2022 · 26 comments · Fixed by #77500
Closed

Magic Home Integration cant connect to RGB Controller #77005

Buonoster opened this issue Aug 18, 2022 · 26 comments · Fixed by #77500
Assignees

Comments

@Buonoster
Copy link

The problem

The integration seems to discover the Wi-Fi controllers, but can never connect.

From the Integration UI "Retrying setup: [Errno 111] Connect call failed ('192.168.1.217', 5577)"

I have 2 controllers, same result with both. Magic Home Android App works fine to control them.

What version of Home Assistant Core has the issue?

2022.8.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Magic Home

Link to integration documentation on our website

https://www.home-assistant.io/integrations/flux_led/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:1067
First occurred: 15:02:43 (10 occurrences)
Last logged: 16:02:39

Config entry 'Controller RGB/WW/CW E6462E' for flux_led integration not ready yet: [Errno 111] Connect call failed ('192.168.1.193', 5577); Retrying in background
Config entry 'Controller RGB/WW/CW C8F170' for flux_led integration not ready yet: [Errno 111] Connect call failed ('192.168.1.217', 5577); Retrying in background

Additional information

Could the port number (5577) be wrong? It looks like the Magic Home App on my phone is using a different port to communicate with the controllers. If so, is there a way to override the port number?

@probot-home-assistant
Copy link

flux_led documentation
flux_led source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @icemanch, @bdraco, mind taking a look at this issue as it has been labeled with an integration (flux_led) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@bdraco
Copy link
Member

bdraco commented Aug 18, 2022

Historically all of these have talked over port 5577.

Which port is the app using for these devices?

Are they using a new firmware version?

Where did you purchase the devices?

@Buonoster
Copy link
Author

From a Wireshark capture it looks like the app is using port 34001. I think I see the failed connection from HA as well.
192.168.1.125 is HA, 192.168.1.193 is the RGB controller.

27 104.368624 192.168.1.125 192.168.1.193 TCP 74 51388 → 5577 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 SACK_PERM=1 TSval=710756492 TSecr=0 WS=128
28 104.370412 192.168.1.193 192.168.1.125 TCP 60 5577 → 51388 [RST, ACK] Seq=1 Ack=1 Win=5840 Len=0

The exact model I'm using is this one: https://assets.leevalley.com/Original/10090/75284-wi-fi-led-dimmer-lighting-controller-c-01-e.pdf

FW versions looks like 25.v2.18.6459-A

@bdraco
Copy link
Member

bdraco commented Aug 21, 2022

I have a few of those lying around and they all use port 5577z If you send me your mailing details before Monday (traveling for a bit after that), I'll send you out one of them and we can figure out if it's a network issue or a device issue

@Buonoster
Copy link
Author

Sure, we could try that. I live in Vancouver Canada, is that ok?

I have 4 of these devices at home, and they're all giving me this error in HA. I also remembered that I have a brand new one I never used. So I'm going to try that one later today too.

@bdraco
Copy link
Member

bdraco commented Aug 21, 2022

Sure, we could try that. I live in Vancouver Canada, is that ok?

Yes. Please send your mailing details out to nick@koston.org and I'll ship it out tomorrow.

@bdraco
Copy link
Member

bdraco commented Aug 24, 2022

You should have received an email from USPS with the tracking. Let me know if it didn't come thorough

@Buonoster
Copy link
Author

Yes, I got it the other day, thanks. Let me know if there are any special steps you want me to take for debugging.

@bdraco
Copy link
Member

bdraco commented Aug 24, 2022

I think just setting it up and seeing if Home Assistant can talk to it or not. Then we can rule out if it's a network issue or firmware issue

@Buonoster
Copy link
Author

OK, sounds good. I just tried the other unit I had still in a box. Looks like its communicating on port 34001 as well.

Just to confirm as well, this is the Android App I'm using.
https://play.google.com/store/apps/details?id=com.armacost.wifipro&hl=en_CA&gl=US
It looks like a rebranded version of the Magic Home App.
https://play.google.com/store/apps/details?id=com.zengge.wifi

I don't think that should matter.

@bdraco
Copy link
Member

bdraco commented Aug 25, 2022

Can you send full wireshark dumps of the port 34001 traffic?

@Buonoster
Copy link
Author

Just emailed you the full capture file.

@bdraco
Copy link
Member

bdraco commented Aug 26, 2022

Screen_Shot_2022-08-26_at_12_10_04_PM

The protocol looks the same, but just over a different port.

Unfortunately I don't see a way to discover the port

@bdraco
Copy link
Member

bdraco commented Aug 26, 2022

Can you send debug logs for flux_led from startup?

Maybe the port is in the UDP broadcast somewhere

@bdraco
Copy link
Member

bdraco commented Aug 26, 2022

The app is hard coded to use the other port

Armacost Lighting version uses 34001

smali/com/zengge/wifi/COMM/a/t.smali: const p0, 0x84d1

Magic Home Pro app uses port 5577

smali/com/zengge/wifi/COMM/Protocol/g0.smali: const/16 p0, 0x15c9

@Buonoster
Copy link
Author

OK, interesting, thanks for the investigation. I'll try to get the log this weekend.

@Buonoster
Copy link
Author

I just emailed the debug logs. Hopefully there is something in there you can use.

@bdraco
Copy link
Member

bdraco commented Aug 29, 2022

2022-08-28 21:33:47.643 DEBUG (MainThread) [flux_led.aioscanner] discover: ('X.X.X.X', 48899) <= b'+ok=25_18_20170908_Armacost\r'

That's probably enough to know to switch the port in the lib

@Buonoster
Copy link
Author

I saw these entries in the log. Are they the contents of the TCP packets from the controllers?

So basically, you can use this info from the discovery step, to determine which model of controller/brand it is and have the integration use port 34001 instead of 5577?

bdraco added a commit to bdraco/home-assistant that referenced this issue Aug 29, 2022
These devices use port 34001 instead of 5577 and its
hard coded into the app so we need to detect them
in the model info and switch ports

changelog: Danielhiversen/flux_led@0.28.30...0.28.31

fixes home-assistant#77005
@bdraco
Copy link
Member

bdraco commented Aug 29, 2022

I can't tell for sure if it will fix it because I don't have one to test with, but #77500 should try the other port

@Buonoster
Copy link
Author

I tried using the python utility you updated flux_led I think I'm using it right, but I'm still seeing the error on port 5577.

~$ flux_led -s --debug
DEBUG:flux_led.scanner:udp: ('', 48899) => b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'192.168.1.193,DC4F22E6462E,AK001-ZJ200'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'192.168.1.141,2CF432C8C9A4,AK001-ZJ200'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'192.168.1.193,DC4F22E6462E,AK001-ZJ200'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'192.168.1.141,2CF432C8C9A4,AK001-ZJ200'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'192.168.1.141,2CF432C8C9A4,AK001-ZJ200'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'192.168.1.193,DC4F22E6462E,AK001-ZJ200'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'HF-A11ASSISTHREAD'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'192.168.1.193,DC4F22E6462E,AK001-ZJ200'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'192.168.1.141,2CF432C8C9A4,AK001-ZJ200'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+LVER\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=25_18_20170908_Armacost\r'
DEBUG:flux_led.scanner:udp: ('', 48899) => b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.120', 48899) <= b'AT+SOCKB\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.193', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'
DEBUG:flux_led.aioscanner:discover: ('192.168.1.141', 48899) <= b'+ok=TCP,8806,mhc8806us.magichue.net\r'

~$ flux_led 192.168.1.193 --on --debug
Error while processing {'ipaddr': '192.168.1.193', 'id': 'Unknown ID'}: [Errno 111] Connect call failed ('192.168.1.193', 5577)

bdraco added a commit to Danielhiversen/flux_led that referenced this issue Aug 30, 2022
@bdraco
Copy link
Member

bdraco commented Aug 30, 2022

I'm not sure the CLI will work since it doesn't always feed the discovery data into the client.

Home Assistant has provisions to do that and restore the discovery from cache if it fails on restart

bdraco added a commit to Danielhiversen/flux_led that referenced this issue Aug 30, 2022
@bdraco
Copy link
Member

bdraco commented Aug 30, 2022

I added a test based on your discovery dumps Danielhiversen/flux_led#379

Its setting the port correctly based on the test so you probably have to wait until the PR merges and it comes out in a release or patch the lib manually in the mean time

@Buonoster
Copy link
Author

Awesome, sounds good! I might try to figure out how to patch the lib myself.

Also, to test that the connection works, I changed base_device.py to use DEFAULT_PORT = 34001 and then I was able to use the commands to turn the LED strip on and off with no issue!

Thanks again for your responsiveness and work on this :)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2022
@bdraco
Copy link
Member

bdraco commented Oct 11, 2022 via email

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

Successfully merging a pull request may close this issue.

2 participants