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

Luci device tracker: AttributeError: 'list' object has no attribute 'upper' #60

Closed
Code-TT opened this issue Jan 14, 2024 · 3 comments
Closed

Comments

@Code-TT
Copy link

Code-TT commented Jan 14, 2024

I recently started having problems with the Luci Device Tracker in Home Assistant.
The error occurs regardless of whether openWRT uses SSL or not. Does anyone have any idea what the problem could be?

[LuCI openwrt-23.05 branch (git-24.006.68745-9128656)](https://github.com/openwrt/luci) / [OpenWrt 23.05.2 (r23630-842932a63d)](https://openwrt.org/)

luci-mod-rpc | git-21.020.56896-af422b1
rpcd-mod-luci | 20230123-1

ERROR:

Logger: homeassistant
Source: components/luci/device_tracker.py:94
First occurred: 18:50:21 (5 occurrences)
Last logged: 18:51:01

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'

My Config in Homeassistant:

device_tracker:
  - platform: luci
    host: 192.168.21.1
    username: !secret router_user
    password: !secret router_password
    ssl: true
    verify_ssl: false
    interval_seconds: 10
    consider_home: 180

HomeAssistant
Core 2024.1.3
Supervisor 2023.12.0
Operating System 11.3

Tinigriffy added a commit to Tinigriffy/openwrt-luci-rpc that referenced this issue Jan 23, 2024
It seems that openwrt can now send a list or a string. I do not know if we could have multiple mac in the list. We simply pick up the first one.
Tinigriffy added a commit to Tinigriffy/openwrt-luci-rpc that referenced this issue Jan 23, 2024
@Tinigriffy Tinigriffy mentioned this issue Jan 23, 2024
@jmot205
Copy link

jmot205 commented Feb 19, 2024

Also getting this error

mrchi pushed a commit that referenced this issue Feb 23, 2024
@mrchi
Copy link
Collaborator

mrchi commented Feb 23, 2024

I've just merged PR #61, but I've found that there are some test failures that must be fixed before a new version can be released.

@mrchi
Copy link
Collaborator

mrchi commented Mar 4, 2024

I've just fixed the test case that caused the CI failure and released version 1.1.17.

Close issue.

@mrchi mrchi closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants