rootnegativ1 / unifi-wifi

Home Assistant integration to change wireless passwords on UniFi Network controllers
MIT License
3 stars 0 forks source link

Setting up image suddenly not working #36

Open backisen opened 2 months ago

backisen commented 2 months ago

Setting up the QR image stopped working. I haven’t change anything as far as I can remember. Output in the log:

Logger: homeassistant.components.image Källa: helpers/entity_platform.py:356 integration: Bild (dokumentation, ärenden) Inträffade först: 17:48:47 (1 händelser) Senast loggade: 17:48:47

Error while setting up unifi_wifi platform for image Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/unifi_wifi/image.py", line 104, in async_setup_platform entities.append(UnifiWifiImage(hass, x, wlan[CONF_NAME], wlan[CONF_FILL_COLOR], wlan[CONF_BACK_COLOR])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/unifi_wifi/image.py", line 122, in init CONF_HIDE_SSID: self.coordinator.wlanconf[idssid][CONF_HIDE_SSID],


KeyError: 'hide_ssid'
rootnegativ1 commented 2 months ago

The hide_ssid value is pulled from the WLAN configuration which itself is pulled from the actual network controller. Getting KeyError suggests this key-value pair no longer exists on the controller for that specific SSID. I can't get this error to occur on my test system when connecting to either my UDM or standalone (test) network controller. Both of these are running the most recent official release (8.1.113) of the Network Application. I wonder if UI changed something in the latest EA releases. What version is your network controller?

backisen commented 2 months ago

The hide_ssid value is pulled from the WLAN configuration which itself is pulled from the actual network controller. Getting KeyError suggests this key-value pair no longer exists on the controller for that specific SSID. I can't get this error to occur on my test system when connecting to either my UDM or standalone (test) network controller. Both of these are running the most recent official release (8.1.113) of the Network Application. I wonder if UI changed something in the latest EA releases. What version is your network controller?

I’m running 8.1.113 as well.

rootnegativ1 commented 2 months ago

I just pushed a beta release v2.1.1b1 to output the wlanconf for each image entity. You may need to toggle the "Show beta versions" switch for this repo in HACS. Once downloaded:

This new output will happen before the KeyError: 'hide_ssid' error does, but the error will still occur. At least this way we can see what the component sees and figure out why it can't find this key.

backisen commented 2 months ago

I just pushed a beta release v2.1.1b1 to output the wlanconf for each image entity. You may need to toggle the "Show beta versions" switch for this repo in HACS. Once downloaded:

  • enable debug logging for the component
    logger:
    logs:
      custom_components.unifi_wifi: debug
  • change the EXTRA_DEBUG to True in \config\custom_components\unifi_wifi\image.py

This new output will happen before the KeyError: 'hide_ssid' error does, but the error will still occur. At least this way we can see what the component sees and figure out why it can't find this key.

This is the output in the log after updating to new beta and changing the logger and debug options:

2024-04-22 09:08:08.980 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _update_info Updating info for klubben319 2024-04-22 09:08:10.021 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _request method post on path https://192.168.1.102:8443/api/login (status 200) 2024-04-22 09:08:10.140 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _request method get on path https://192.168.1.102:8443/api/s/default/stat/sysinfo (status 200) 2024-04-22 09:08:10.144 ERROR (MainThread) [tibber.home] Error in rt_subscribe Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/tibber/home.py", line 439, in _start async for data in self._tibber_control.realtime.sub_manager.session.subscribe( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Client' object has no attribute 'session' 2024-04-22 09:08:10.218 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _request method get on path https://192.168.1.102:8443/api/s/default/rest/networkconf (status 200) 2024-04-22 09:08:10.248 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _request method get on path https://192.168.1.102:8443/api/s/default/rest/wlanconf (status 200) 2024-04-22 09:08:10.347 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] _request method post on path https://192.168.1.102:8443/api/logout (status 200) 2024-04-22 09:08:10.348 DEBUG (MainThread) [custom_components.unifi_wifi.coordinator] Finished fetching klubben319 data in 1.368 seconds (success: True) 2024-04-22 09:08:10.348 DEBUG (MainThread) [custom_components.unifi_wifi.image] wlanconf for image.klubben319_klubben319_guest_wifi: [{'setting_preference': 'manual', 'dtim_6e': 3, 'wpa3_support': True, 'wpa_mode': 'wpa2', 'minrate_na_advertising_rates': False, 'minrate_setting_preference': 'auto', 'minrate_ng_advertising_rates': False, 'hotspot2conf_enabled': False, 'optimize_iot_wifi_connectivity': True, 'b_supported': False, 'radius_das_enabled': False, 'group_rekey': 3600, 'pmf_mode': 'optional', 'wpa3_transition': True, 'passphrase_autogenerated': False, 'private_preshared_keys': [], 'bc_filter_enabled': True, 'usergroup_id': '5df61640a291cddfefc98191', 'schedule_enabled': False, 'country_beacon': True, 'iapp_enabled': True, 'name': 'klubben319_guest', 'site_id': '5df6163ca291cddfefc98182', 'wlan_band': 'both', '_id': '5dfbbc6ea291cd03695dbbbc', 'no2ghz_oui': True, 'x_iapp_key': '44bff64d24cc24494d3b31ea72d3c4a9', 'auth_cache': True, 'networkconf_id': '5df61640a291cddfefc98190', 'dtim_na': 3, 'is_guest': True, 'minrate_na_enabled': False, 'enabled': True, 'wlan_bands': ['2g', '5g'], 'mac_filter_policy': 'allow', 'security': 'wpapsk', 'wep_idx': 1, 'minrate_ng_enabled': True, 'ap_group_ids': ['60957b13e9d29101dd84755b'], 'minrate_ng_data_rate_kbps': 1000, 'bss_transition': True, 'ap_group_mode': 'all', 'pmf_cipher': 'auto', 'fast_roaming_enabled': False, 'wpa_enc': 'ccmp', 'x_passphrase': 'afraid-pond-egging-essay', 'mac_filter_list': [], 'dtim_mode': 'default', 'schedule': [], 'bc_filter_list': [], 'minrate_na_data_rate_kbps': 6000, 'mac_filter_enabled': False, 'dtim_ng': 1}] 2024-04-22 09:08:10.351 ERROR (MainThread) [homeassistant.components.image] Error while setting up unifi_wifi platform for image Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/unifi_wifi/image.py", line 104, in async_setup_platform entities.append(UnifiWifiImage(hass, x, wlan[CONF_NAME], wlan[CONF_FILL_COLOR], wlan[CONF_BACK_COLOR])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/unifi_wifi/image.py", line 130, in init CONF_HIDE_SSID: self.coordinator.wlanconf[idssid][CONF_HIDE_SSID],


KeyError: 'hide_ssid'
rootnegativ1 commented 2 months ago

hmmm there are a couple keys in your conf I'm not sure about: optimize_iot_wifi_connectivity: True and country_beacon: True'.

I vaguely recall the "Optimize IoT WiFi connectivity" setting when it was released in 6.4.64, but thought it had been removed some time later. Never having played with that setting, I'm not sure what all it does/did. Do you still have this option?

I found "Beacon Country" in advanced wifi settings when switching to the legacy interface but that didn't seem to affect the existence of the hide_ssid key.

An interesting observation: initially my conf did not have the country_beacon key. However once I played with this setting the key remained regardless of its state. I wonder if you toggle the "Hide WiFi Name" wifi setting, will that cause the key to appear in the wlanconf output. Would you mind toggling this setting to see if it appears?