fbradyirl / openwrt-luci-rpc

Other
34 stars 22 forks source link

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

Closed Code-TT closed 7 months ago

Code-TT commented 9 months ago

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

jmot205 commented 8 months ago

Also getting this error

mrchi commented 8 months ago

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 commented 7 months ago

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

Close issue.