Skip to content
New issue

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

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

Already on GitHub? # to your account

TPLink WR841N - Error setting up platform legacy tplink_router #11

Closed
ReneHlouzek opened this issue Mar 20, 2023 · 2 comments · Fixed by #12 or #15
Closed

TPLink WR841N - Error setting up platform legacy tplink_router #11

ReneHlouzek opened this issue Mar 20, 2023 · 2 comments · Fixed by #12 or #15

Comments

@ReneHlouzek
Copy link

Hello,
can you help me with this issue?
Device tracker doesnt work with my router.

Logger: homeassistant.components.device_tracker
Source: custom_components/tplink_router/device_tracker.py:451
Integration: Device tracker (documentation, issues)
First occurred: 10:10:07 AM (1 occurrences)
Last logged: 10:10:07 AM

Error setting up platform legacy tplink_router
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 282, in async_setup_legacy
scanner = await hass.async_add_executor_job(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/tplink_router/device_tracker.py", line 56, in get_scanner
scanner = cls(config[DOMAIN])
File "/config/custom_components/tplink_router/device_tracker.py", line 83, in init
self.success_init = self._update_info()
File "/config/custom_components/tplink_router/device_tracker.py", line 451, in _update_info
session.get(base_url, headers=header)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 573, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
p.prepare(
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 369, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 491, in prepare_headers
check_header_validity(header)
File "/usr/local/lib/python3.10/site-packages/requests/utils.py", line 1037, in check_header_validity
raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part ('User-Agent') from {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0'} must be of type str or bytes, not <class 'multidict._multidict.istr'>

Thank you

@menahishayan
Copy link
Owner

menahishayan commented Mar 21, 2023

Hi, I have created a branch that potentially addresses this issue. Please clone that branch and replace your custom_components/tplink_router folder with the contents of the same folder in the device-tracker-user-agent-fix branch to verify if the fix is working.

Once verified, please confirm so that this can be merged into master.

@ReneHlouzek
Copy link
Author

Hi, unfortunately this change doesn't work for me. I copied your data, then I also turned on "switch:", "sensor" and"device_tracker" in configuration.yaml and then I received multiple error messages:

Logger: homeassistant.helpers.entity
Source: custom_components/tplink_router/switch.py:213
Integration: TP-Link C50 (documentation)
First occurred: 11:46:32 AM (26 occurrences)
Last logged: 11:59:02 AM

Update for switch.tplink_router_wan fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
raise exc
File "/config/custom_components/tplink_router/switch.py", line 213, in async_update
self._state = result['[1,1,1,0,0,0]0']['connectionStatus'] == 'Connected'
KeyError: '[1,1,1,0,0,0]0'

This error originated from a custom integration.

Logger: homeassistant.helpers.entity
Source: custom_components/tplink_router/switch.py:159
Integration: TP-Link C50 (documentation)
First occurred: 11:46:32 AM (26 occurrences)
Last logged: 11:59:02 AM

Update for switch.tplink_router_5ghz fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
raise exc
File "/config/custom_components/tplink_router/switch.py", line 159, in async_update
self._state = result['[1,2,0,0,0,0]0']['enable'] == '1'
KeyError: '[1,2,0,0,0,0]0'

This error originated from a custom integration.

Logger: homeassistant.helpers.entity
Source: custom_components/tplink_router/switch.py:105
Integration: TP-Link C50 (documentation)
First occurred: 11:46:32 AM (26 occurrences)
Last logged: 11:59:02 AM

Update for switch.tplink_router_24ghz fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
raise exc
File "/config/custom_components/tplink_router/switch.py", line 105, in async_update
self._state = result['[1,1,0,0,0,0]0']['enable'] == '1'
KeyError: '[1,1,0,0,0,0]0'

Logger: homeassistant.components.device_tracker
Source: custom_components/tplink_router/device_tracker.py:466
Integration: Device tracker (documentation, issues)
First occurred: 11:46:06 AM (1 occurrences)
Last logged: 11:46:06 AM

Error setting up platform legacy tplink_router
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 282, in async_setup_legacy
scanner = await hass.async_add_executor_job(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/tplink_router/device_tracker.py", line 57, in get_scanner
scanner = cls(config[DOMAIN])
File "/config/custom_components/tplink_router/device_tracker.py", line 84, in init
self.success_init = self._update_info()
File "/config/custom_components/tplink_router/device_tracker.py", line 466, in _update_info
session.get(base_url, headers=header)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 573, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
p.prepare(
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 369, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 491, in prepare_headers
check_header_validity(header)
File "/usr/local/lib/python3.10/site-packages/requests/utils.py", line 1037, in check_header_validity
raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part ('User-Agent') from {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'} must be of type str or bytes, not <class 'multidict._multidict.istr'>

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tplink_router/switch.py:213
Integration: TP-Link C50 (documentation)
First occurred: 11:46:02 AM (1 occurrences)
Last logged: 11:46:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/tplink_router/switch.py", line 213, in async_update
self._state = result['[1,1,1,0,0,0]0']['connectionStatus'] == 'Connected'
KeyError: '[1,1,1,0,0,0]0'

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tplink_router/switch.py:105
Integration: TP-Link C50 (documentation)
First occurred: 11:46:02 AM (1 occurrences)
Last logged: 11:46:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/tplink_router/switch.py", line 105, in async_update
self._state = result['[1,1,0,0,0,0]0']['enable'] == '1'
KeyError: '[1,1,0,0,0,0]0'

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tplink_router/switch.py:159
Integration: TP-Link C50 (documentation)
First occurred: 11:46:02 AM (1 occurrences)
Last logged: 11:46:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/tplink_router/switch.py", line 159, in async_update
self._state = result['[1,2,0,0,0,0]0']['enable'] == '1'
KeyError: '[1,2,0,0,0,0]0'

This error originated from a custom integration.

Logger: custom_components.tplink_router.switch
Source: custom_components/tplink_router/switch.py:18
Integration: TP-Link C50 (documentation)
First occurred: 11:46:02 AM (1 occurrences)
Last logged: 11:46:02 AM

Metadata Update Error.

This error originated from a custom integration.

Logger: custom_components.tplink_router.sensor
Source: custom_components/tplink_router/sensor.py:19
Integration: TP-Link C50 (documentation)
First occurred: 11:46:02 AM (1 occurrences)
Last logged: 11:46:02 AM

Metadata Update Error.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants