home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.22k stars 30.58k forks source link

TP-Link Kasa light switches not connecting #97262

Closed m0tSda0hr closed 1 year ago

m0tSda0hr commented 1 year ago

The problem

TP-Link Kasa Smart integration shows Failed Setup, will retry and individual light switches show the same. They are grayed out in dashboard cards.

What version of Home Assistant Core has the issue?

core-2023.7.0

What was the last working version of Home Assistant Core?

core-2023.6.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

TP-Link Kasa Smart

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

TypeError: Options.__init__() got an unexpected keyword argument 'polling_interval_seconds'
2023-07-26 09:07:01.732 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 1169, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/srv/homeassistant/lib/python3.11/site-packages/kasa/discover.py", line 79, in datagram_received
    info = json_loads(TPLinkSmartHomeProtocol.decrypt(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected end of data: line 1 column 409 (char 408)
2023-07-26 09:07:01.744 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 1169, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/srv/homeassistant/lib/python3.11/site-packages/kasa/discover.py", line 79, in datagram_received
    info = json_loads(TPLinkSmartHomeProtocol.decrypt(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected end of data: line 1 column 409 (char 408)
2023-07-26 09:07:01.746 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 1169, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/srv/homeassistant/lib/python3.11/site-packages/kasa/discover.py", line 79, in datagram_received
    info = json_loads(TPLinkSmartHomeProtocol.decrypt(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected end of data: line 1 column 409 (char 408)
2023-07-26 09:07:56.846 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 1169, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/srv/homeassistant/lib/python3.11/site-packages/kasa/discover.py", line 79, in datagram_received
    info = json_loads(TPLinkSmartHomeProtocol.decrypt(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: unexpected end of data: line 1 column 361 (char 360)
2023-07-26 09:07:56.877 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()

2023-07-26 09:07:06.721 WARNING (MainThread) [homeassistant.config_entries] Config entry 'My Fan HS210(US)' for tplink integration not ready yet: Unable to query the device 192.168.0.48: unexpected end of data: line 1 column 536 (char 535); Retrying in background

Additional information

The following change was implemented in 7.0 Bump python-kasa to 0.5.2 #95716 https://github.com/home-assistant/core/pull/95716

home-assistant[bot] commented 1 year ago

Hey there @rytilahti, @thegardenmonkey, mind taking a look at this issue as it has been labeled with an integration (tplink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tplink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tplink` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tplink documentation tplink source (message by IssueLinks)

m0tSda0hr commented 1 year ago

I discovered it only affects devices with an apostrophe in the name. Changing "Tom's Light" to "Toms Light", fixes the problem.

bdraco commented 1 year ago

This is a duplicate

Update to 2023.7.3.

m0tSda0hr commented 1 year ago

This problem still existed for me in 2023.7.3. For clarity, the device was named "Tom's Light" in the TP-Link Kasa app itself, which is where I renamed it.

bdraco commented 1 year ago

This looks like a duplicate of https://github.com/home-assistant/core/issues/96065

rytilahti commented 1 year ago

@m0tSda0hr mind testing if this is fixed in the latest release?

m0tSda0hr commented 1 year ago

No, I'm afraid it's not fixed in 2023.8.0. I have a light named "Tom's Light" in the TP-Link Kasa app. In Home-Assistant, it still shows Failed setup, will retry.

Thank you, Tom

On Thu, Aug 3, 2023 at 6:17 AM Teemu R. @.***> wrote:

@m0tSda0hr https://github.com/m0tSda0hr mind testing if this is fixed in the latest release?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/97262#issuecomment-1663800143, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4H2ERKBDQDQZVGFSLDCZ43XTOCFRANCNFSM6AAAAAA2YVT3TE . You are receiving this because you were mentioned.Message ID: @.***>

bdraco commented 1 year ago

Can you post a new log with the latest version?

m0tSda0hr commented 1 year ago

Sure thing. I have attached it here.

Thanks, Tom

On Thu, Aug 3, 2023 at 10:35 AM J. Nick Koston @.***> wrote:

Can you post a new log with the latest version?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/97262#issuecomment-1664207857, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4H2ERPQ2SRRLJQXOSL6CZLXTPALRANCNFSM6AAAAAA2YVT3TE . You are receiving this because you were mentioned.Message ID: @.***>

bdraco commented 1 year ago

Was "here" supposed to be a link?

m0tSda0hr commented 1 year ago

Sorry, I wrongly assumed attaching it to the e-mail chain would also attach the log.

home-assistant_tplink_2023-08-03T15-47-46.127Z.log

bdraco commented 1 year ago

This looks like a different problem than https://github.com/home-assistant/core/issues/96065 since its happening over UDP and not TCP

bdraco commented 1 year ago

Is the device with original issue at 192.168.0.48 now working?

bdraco commented 1 year ago

Can you check which version of kasa-crypt you have installed in the container?

docker exec -it homeassistant /bin/bash
pip3 show kasa-crypt
m0tSda0hr commented 1 year ago

Sure thing!

Name: kasa-crypt Version: 0.2.0 Summary: Fast kasa crypt Home-page: https://github.com/bdraco/kasa-crypt Author: J. Nick Koston Author-email: @.*** License: Apache Software License 2.0 Location: /srv/homeassistant/lib/python3.11/site-packages Requires: Required-by:

On Thu, Aug 3, 2023 at 1:24 PM J. Nick Koston @.***> wrote:

Can you check which version of kasa-crypt you have installed in the container?

docker exec -it homeassistant /bin/bash pip3 show kasa-crypt

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/97262#issuecomment-1664436058, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4H2ERMNYFLFDIOJI5MUZZTXTPUEPANCNFSM6AAAAAA2YVT3TE . You are receiving this because you were mentioned.Message ID: @.***>

m0tSda0hr commented 1 year ago

I just upgraded to 0.3.0. That fixed my problem. Sorry for the rabbit hole. FYI...I am running Core, so I manually had to upgrade via pip3 --upgrade.

Thanks, Tom

On Fri, Aug 4, 2023 at 2:58 PM Tom Rhoads @.***> wrote:

Sure thing!

Name: kasa-crypt Version: 0.2.0 Summary: Fast kasa crypt Home-page: https://github.com/bdraco/kasa-crypt Author: J. Nick Koston Author-email: @.*** License: Apache Software License 2.0 Location: /srv/homeassistant/lib/python3.11/site-packages Requires: Required-by:

On Thu, Aug 3, 2023 at 1:24 PM J. Nick Koston @.***> wrote:

Can you check which version of kasa-crypt you have installed in the container?

docker exec -it homeassistant /bin/bash pip3 show kasa-crypt

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/97262#issuecomment-1664436058, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4H2ERMNYFLFDIOJI5MUZZTXTPUEPANCNFSM6AAAAAA2YVT3TE . You are receiving this because you were mentioned.Message ID: @.***>

bdraco commented 1 year ago

Ahh.. I didn't think to ask that before because you specified Home Assistant OS