core: Luci device tracker: AttributeError: 'list' object has no attribute 'upper'
The problem
My Luci device tracker was running well yet. I updated my HA and now I get this error:
Logger: homeassistant
Source: components/luci/device_tracker.py:94
First occurred: 5. Januar 2024 um 23:53:25 (74 occurrences)
Last logged: 00:05:35
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 432, in async_device_tracker_scan
found_devices = await scanner.async_scan_devices()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 952, in async_scan_devices
return await self.hass.async_add_executor_job(self.scan_devices)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/luci/device_tracker.py", line 67, in scan_devices
self._update_info()
File "/usr/src/homeassistant/homeassistant/components/luci/device_tracker.py", line 94, in _update_info
result = self.router.get_all_connected_devices(only_reachable=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openwrt_luci_rpc/__init__.py", line 42, in get_all_connected_devices
return self.router.get_all_connected_devices(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openwrt_luci_rpc/openwrt_luci_rpc.py", line 178, in get_all_connected_devices
device_entry['hostname'] = utilities.get_hostname_from_dhcp(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openwrt_luci_rpc/utilities.py", line 28, in get_hostname_from_dhcp
host = [x for x in dhcp_result.values()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openwrt_luci_rpc/utilities.py", line 32, in <listcomp>
and x['mac'].upper() == mac]
^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'upper'
What version of Home Assistant Core has the issue?
core-2024.1.1
What was the last working version of Home Assistant Core?
core-2023.11…
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Luci Device Tracker
Link to integration documentation on our website
No response
Diagnostics information
On Openwrt: LuCI openwrt-23.05 branch (git-23.357.58018-024e7ab) / OpenWrt 23.05.2 (r23630-842932a63d) luci-mod-rpc | git-21.020.56896-af422b1
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 3
- Comments: 40 (8 by maintainers)
With the new release here is a modified procedure to perform the update, with a new proposal for the fix that is more generic
replace and x[‘mac’].upper()==mac)] by and str(x[‘mac’]).upper().find(mac) != -1]
I’ve just released version 1.1.17 for openwrt_luci_rpc to fix above issue.
Tomorrow I will submit a PR to home-assistant. Goodnight everyone.
Hi,
I have exactly the same problem with an AX3600 with OpenWRT. I am using HAOS, and I can’t locate the phyton folder.
Does anyone know where it is?
That’s fine mrchi I have invited you to the repo so you can merge and release the new version, etc.
PR https://github.com/home-assistant/core/pull/112796 created.
Yesterday on my OpenWRT router I uninstalled: openwrt_luci_rpc i.e. opkg remove luci-mod-rpc, restarted the router and reinstalled with the command: opkg install luci-mod-rpc and it didn’t help. I’ll do it again soon then.
Folks I don’t have capacity any more to maintain this module. If anyone is interested then please let me know and I can make you a collab on my repo and you can be made owner of the HA integration also.
Looks like a problem with the brackets. Please check if the number of left and right brackets from line 28 to line 32 matches. Do you have two left tabs at the beginning of the block you inserted? (( isinstance(x[‘mac’],list) and x[‘mac’][0].upper()==mac) or (isinstance(x[‘mac’],str) and x[‘mac’].upper()==mac) )]
Hello, I have the same issue. It seems that openwrt can now send a list or a string and this is not handled by the lib openwrt_luci_rpc used by this module. I tried to patch the issue this way: In the ssh windows
replace and x[‘mac’].upper()==mac)] by and (( isinstance(x[‘mac’],list) and x[‘mac’][0].upper()==mac) or (isinstance(x[‘mac’],str) and x[‘mac’].upper()==mac) )]
This way there is no exception. As this is my first attempt to use this module I do not know if this really fix the issue.
Hello, same problem for me
same problem
Same problem