home-assistant-padavan-tracker icon indicating copy to clipboard operation
home-assistant-padavan-tracker copied to clipboard

Not working?

Open milindpatel63 opened this issue 2 years ago • 2 comments

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 353, in async_device_tracker_scan

    found_devices = await scanner.async_scan_devices()

  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 827, in async_scan_devices

    return await self.hass.async_add_executor_job(self.scan_devices)

  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run

    result = self.fn(*self.args, **self.kwargs)

  File "/config/custom_components/padavan_tracker/device_tracker.py", line 60, in scan_devices

    self._update_info()

  File "/config/custom_components/padavan_tracker/device_tracker.py", line 125, in _update_info

    debug.append({'mac': values[0], 'rssi': rssi, 'psm': values[9], 'time': values[10],

IndexError: list index out of range

milindpatel63 avatar May 31 '22 01:05 milindpatel63

I'm no longer have a device to test and fix. You can fix it and make a PR.

PaulAnnekov avatar Jun 03 '22 20:06 PaulAnnekov

Issue was, I was using the router in access point mode with 5Ghz in Client Mode....

So the 5Ghz page looked like this in HTML

Operation Mode : AP-Client
WPHY Mode : 11n/ac
Channel Main : 36
AP-Client Connection
----------------------------------------
BSSID PhyMode BW MCS SGI LDPC STBC TRate RSSI

The PSM and Connect Time Columns were missing....

So I modified the code by separating the two pages HTML output and in 5ghz, removed those 2 values... Like this


self.last_results = []
debug = []
res2gh = r_2g['text']
res5gh = r_5g['text']
for line in res2gh.split('\n'):
    m = re.match("^((.{2}:){5}.{2}) ", line)
    if m:
        values = line.split()
        rssi = int(values[8])
        debug.append({'mac': values[0], 'rssi': rssi, 'psm': values[9], 'time': values[10],
                      'bw': values[2], 'mcs': values[3], })
        if self.rssi_min and rssi < self.rssi_min:
            continue
        self.last_results.append(m.group(1))

for line in res5gh.split('\n'):
    m = re.match("^((.{2}:){5}.{2}) ", line)
    if m:
        values = line.split()
        rssi = int(values[8])
        debug.append({'mac': values[0], 'rssi': rssi,
                      'bw': values[2], 'mcs': values[3], })
        if self.rssi_min and rssi < self.rssi_min:
            continue
        self.last_results.append(m.group(1))

_LOGGER.info('results %s', str(debug))

But this won't work for other people....

I'm not that good in coding....you could modify it to work better.... Or if someone has similar issue, they might find this comment helpful.

milindpatel63 avatar Jun 06 '22 05:06 milindpatel63