core: Cannot connect Twinkly anymore
The problem
Whenever I fill in the host of the twinkly lights. The next step is just empty and I have only the option to close. Does this mean my Twinkly Light with firmware 2.3.5 is no longer working with Home Assistant? Is there no way to get basic integration with on/of/brightness back, as it was last year?
What version of Home Assistant Core has the issue?
2023.11.3
What was the last working version of Home Assistant Core?
2022.12
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Twinkly
Link to integration documentation on our website
https://www.home-assistant.io/integrations/twinkly
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
There is absolutely nothing in the logs.
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 5
- Comments: 28 (7 by maintainers)
There seems to be something fishy going on with the tcp implementation in the Twinklys.
I did a packet capture of when one of my devices (I have three, and they work most of the time, but will disconnect and reconnect about once every hour or so).
So lets take this in sequence:
Packet 7067 - 7071 shows a regular (working) TCP session being torn down with a FIN - FIN-ACK -ACK sequence.
30 seconds later - in packet 7182, HA tries to connect to the same Twinkly. We ssee that it sends a SYN packet. It reuses the TCP source port - that is perfectly legal and normal.
However, when Twinkly reponds (7184), it respnds with an ACK as if this was an establised session, but it SHOULD create a new session and respond with a SYN-ACK.
Naturally HA rejects the ACK in packet 7185 (there is no estalished session - it was torn down in 7067-7071), and responds with a RST.
HA then tries to retransmit tha SYN, Twinkly responds with the same ACK, which HA again rejects.
This goes on for a few times, before HA give up, and logs an error:
In my case, HA then tries again after 30 seconds, and this time it succeeds:
So to me it seems like the TCP implementation on Twinkly is faulty. Depending on other factors in your network, this could cause various levels of unstability when connecting to the lights.
I don’t really know why HA tries to esablish a new session, though. As it should use the aiohttp clientsession from HA which as far as I understand should keep the TCP session running:
Maybe there are some tweaks that can be done there?
One could possibly try to remove the clientsession, and force a reconnect every time to see if Twinkly handles that better.
It seems to be a problem with the devices. I think there is a limitation where they only accept one connection at the time (I remember having issues when I started using them, where HA would disconnect the app, and the app would disconnect HA). I see a lot of “Not reachable” and then a bit later later “Now available” in my logs. Will try to investigate a bit.
An update, I downgraded to Core 2023.11.3 and the issue is gone. So this problem (at least for me) is isolated to 2023.12
Can confirm its working, with the fix/workaround mentioned. Since then its working perfectly
Can someone confirm that they are using this integration without issues in 2023.12 ?
I wonder if there are two separate issues. The going unavailable on and off again every 3 minutes definitely was fixed by reverting the version
Just one here, no good still. Tried deleting and starting over, nope. At no time is the entity NOT greyed out.
I have disable too during year… Delete the extension and add again and it works ! Thanks
@robkirk I only have one Twinkly Xmas light string from 2019, with firmware 2.3.5. This on worked last year but this year it doesn’t work. Over the last year I did some “cleaning” and uninstalled the integration, but I am not sure it was the integration from the Core or the one from HACS. This year when I wanted to add the Integration, it asks for the IP address (I have only one, as I only have string) and then you get the empty screen. No errors in the Log book or anything.