puttyman / hass-amplifi

A home assistant integration for Ubiquiti Amplifi
27 stars 16 forks source link

ETHERNET_PORT_TO_DEVICE_IDX #55

Open plesetsk opened 1 week ago

plesetsk commented 1 week ago

After update to version 2.1.1 integration does not start.

I see this in logs

`Error doing job: Task exception was never retrieved (None) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 255, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners update_callback() File "/config/custom_components/amplifi/coordinator.py", line 101, in extract_ethernet_devices raw_device_to_eth_index = self.data[ETHERNET_PORT_TO_DEVICE_IDX][router_mac_addr]


KeyError: '74:ac:b9:2c:fc:d4' `

thanks for support
hawksj commented 1 week ago

Hi @plesetsk,

Terribly sorry you've experienced this. I will investigate today. We did not encounter this issue in testing. Do you use an Alien or an AmpliFi HD?

If you feel comfortable, it would aid my troubleshooting if you could send me your info-async file from your router. Please see the steps below and feel free to send it to me privately if you don't want to post it here. Please email to 58028821+hawksj@users.noreply.github.com.

  1. Login to http://amplifi.lan/info.php
  2. On Chrome open your developer console
  3. Click on the network tab
  4. Click on info-async.php
  5. Click on preview tab and expand
  6. Copy all content into a text file or download the file from the browser

Thanks for your support, apologies again for the inconvenience. We will get this patched ASAP. You should be fine to redownload 2.1.0 or earlier to resolve the issue in the meantime.

Sam

plesetsk commented 1 week ago

Hi Sam,

Thanks for your response. I use an AmpliFi HD.

Here is info-async.php in attachment.

Thank you very much. info-async.php.txt

hawksj commented 1 week ago

Thanks @plesetsk. Ignore previous comment, I hadn't seen your response before posting.

The formatting is a little broken in your attachment (it should be JSON) but it's readable enough that it seems to confirm my suspicion that, for some reason, the MAC address is being reported comma-separated. Are you on the latest firmware for your router?

The section that is causing the error is the section that lists which port an Ethernet device is connected to which router. It lists the routers like this where the top level MAC is the MAC of the router and the children are the connected devices and their port. This section appears to be hyphen separated hence the key error. I need to get a current file from my own router to make sure this is still correct.

    {
        "9D-7A-72-7E-B0-34": {
            "13-B4-39-74-2D-22": 0,
            "C1-2C-87-51-AF-8D": 2,
            "A8-5E-2D-66-00-C7": 0,
            "CC-CD-48-22-62-F4": 1,
            "29-44-B5-04-F4-64": 3
        }
    }

If you're not on the latest firmware, please update or if that is not possible, could you perform the same steps as before to get the info-async.php file and instead of previewing, right click it in the developer tools window and click Save As and attach the JSON formatted version? With a full version of your info-async, I can see if the MAC actually is reported as comma separated or if the function that finds the MAC address is reading the wrong section. image

I'll also double check the format with my router tonight when I am home. Thanks for your help.

plesetsk commented 1 week ago

Hi @hawksj

Thanks for your support.

Unfortunately I do not have save as option

image 42.json

Current firmware version is 4.0.3

Please let me know what else I can do.

Thanks again

hawksj commented 1 week ago

Thanks very much @plesetsk. It seems you don't have any Ethernet devices connected, is that right? That's a bit of an oversight on my part with the recent addition so apologies for that.

I'll work on a fix today if I can. @atudor2 just tagging you to make you aware of this issue. It seems if the section that lists the Ethernet port for connected devices is empty, you get this error. Need a check to make sure it's not empty.

It's also worth noting I was completely wrong about the whole comma/hyphen separated thing. Everything is comma separated, but as long as it's the same it doesn't matter which way round it is.

hawksj commented 1 week ago

Hi again @plesetsk

I have added a simple line which I think will ensure the key exists before trying to read from it. I've made a hasty 2.1.2 beta release. Please could you try installing this version through HACS (you may need to tick to enable pre-release versions) and let me know if it fixes the issue for you?

Thanks, Sam

plesetsk commented 1 week ago

Ciao @hawksj,

I have installed 2.1.2 beta.

Works fine ✔️ Thanks

hawksj commented 1 week ago

Amazing, thanks for the confirmation. Glad that worked. I will make a PR and get that change merged into a full release later.