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

Not working? #13

Open
milindpatel63 opened this issue May 31, 2022 · 2 comments
Open

Not working? #13

milindpatel63 opened this issue May 31, 2022 · 2 comments

Comments

@milindpatel63
Copy link

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
@PaulAnnekov
Copy link
Owner

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

@milindpatel63
Copy link
Author

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.

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

2 participants