Losing secondary wifi connection on HAOS and RPI4

Hi there.
I use my HA installed with HAOS on a RPI4.
I mainly use wired connection, but lately I needed to connect to a specific device using wifi.
The goal is to control my pellet stove locally, using a custom integration.

I could not set up the secondary wifi connection through the UI, so I used ssh to get the connection up and running.
and it works. So I have my RPI on my home LAN to connect to everything, and the wifi is connected to my pellet stove.

Here is how I did it :

ha network update wlan0 --ipv4-method static --ipv4-address 192.168.120.53 --wifi-ssid MCZ-0142F5201FCE78 --wifi-psk ********** --wifi-auth wpa-psk --wifi-mode adhoc --ipv4-gateway 192.168.120.1

The command works fine and my integration works also, but now and then I loose the connection, and I don’t understand why

Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8669] device (wlan0): Activation: starting connection 'Supervisor wlan0' (6316e937-c92e-438c-802f-35f4fb17336a)
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8671] audit: op="connection-add-activate" uuid="6316e937-c92e-438c-802f-35f4fb17336a" name="Supervisor wlan0" pid=1204 uid=0 result="success"
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8679] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8688] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8698] device (wlan0): Activation: (wifi) access point 'Supervisor wlan0' has security, but secrets are required.
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8699] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8731] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8746] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8758] device (wlan0): Activation: (wifi) connection 'Supervisor wlan0' has security, and secrets exist.  No new secrets needed.
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8759] Config: added 'ssid' value 'MCZ-0142F5201FCE78'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8759] Config: added 'scan_ssid' value '1'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8760] Config: added 'bgscan' value 'simple:30:-70:86400'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8760] Config: added 'key_mgmt' value 'WPA-PSK'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8761] Config: added 'auth_alg' value 'OPEN'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.8761] Config: added 'psk' value '<hidden>'
Nov 16 07:36:20 homeassistant NetworkManager[360]: <info>  [1668584180.9141] device (wlan0): supplicant interface state: inactive -> scanning
Nov 16 07:36:23 homeassistant wpa_supplicant[373]: wlan0: Trying to associate with SSID 'MCZ-0142F5201FCE78'
Nov 16 07:36:23 homeassistant NetworkManager[360]: <info>  [1668584183.7536] device (wlan0): supplicant interface state: scanning -> associating
Nov 16 07:36:26 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Nov 16 07:36:26 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="MCZ-0142F5201FCE78" auth_failures=1 duration=10 reason=CONN_FAILED
Nov 16 07:36:26 homeassistant NetworkManager[360]: <info>  [1668584186.8609] device (wlan0): supplicant interface state: associating -> disconnected
Nov 16 07:36:36 homeassistant NetworkManager[360]: <info>  [1668584196.8866] device (wlan0): supplicant interface state: disconnected -> scanning
Nov 16 07:36:39 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="MCZ-0142F5201FCE78"
Nov 16 07:36:39 homeassistant wpa_supplicant[373]: wlan0: Trying to associate with SSID 'MCZ-0142F5201FCE78'
Nov 16 07:36:39 homeassistant NetworkManager[360]: <info>  [1668584199.6379] device (wlan0): supplicant interface state: scanning -> associating
Nov 16 07:36:42 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Nov 16 07:36:42 homeassistant wpa_supplicant[373]: BSSID 42:f5:20:1f:ce:78 ignore list count incremented to 2, ignoring for 10 seconds
Nov 16 07:36:42 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="MCZ-0142F5201FCE78" auth_failures=2 duration=20 reason=CONN_FAILED
Nov 16 07:36:42 homeassistant NetworkManager[360]: <info>  [1668584202.7355] device (wlan0): supplicant interface state: associating -> disconnected
Nov 16 07:36:45 homeassistant NetworkManager[360]: <warn>  [1668584205.8067] device (wlan0): Activation: (wifi) association took too long
Nov 16 07:36:45 homeassistant NetworkManager[360]: <info>  [1668584205.8069] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:45 homeassistant NetworkManager[360]: <warn>  [1668584205.8086] device (wlan0): Activation: (wifi) asking for new secrets
Nov 16 07:36:45 homeassistant NetworkManager[360]: <warn>  [1668584205.8102] device (wlan0): no secrets: No agents were available for this request.
Nov 16 07:36:45 homeassistant NetworkManager[360]: <info>  [1668584205.8103] device (wlan0): state change: need-auth -> failed (reason 'no-secrets', sys-iface-state: 'managed')
Nov 16 07:36:45 homeassistant NetworkManager[360]: <warn>  [1668584205.8131] device (wlan0): Activation: failed for connection 'Supervisor wlan0'
Nov 16 07:36:45 homeassistant NetworkManager[360]: <info>  [1668584205.8148] device (wlan0): state change: failed -> disconnected (reason 'none', sys-iface-state: 'managed')
Nov 16 07:36:52 homeassistant NetworkManager[360]: <info>  [1668584212.7370] device (wlan0): supplicant interface state: disconnected -> inactive

Here is what happen when I start the connection manually

Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.1994] device (wlan0): Activation: starting connection 'Supervisor wlan0' (bcdce0a7-1b7c-4fcb-b464-f0398c4adc77)
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.1998] audit: op="connection-add-activate" uuid="bcdce0a7-1b7c-4fcb-b464-f0398c4adc77" name="Supervisor wlan0" pid=1204 uid=0 result="success"
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2011] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2033] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2046] device (wlan0): Activation: (wifi) access point 'Supervisor wlan0' has security, but secrets are required.
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2046] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2091] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2118] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2134] device (wlan0): Activation: (wifi) connection 'Supervisor wlan0' has security, and secrets exist.  No new secrets needed.
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2139] Config: added 'ssid' value 'MCZ-0142F5201FCE78'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2139] Config: added 'scan_ssid' value '1'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2140] Config: added 'bgscan' value 'simple:30:-70:86400'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2140] Config: added 'key_mgmt' value 'WPA-PSK'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2141] Config: added 'auth_alg' value 'OPEN'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2143] Config: added 'psk' value '<hidden>'
Nov 16 07:47:24 homeassistant NetworkManager[360]: <info>  [1668584844.2565] device (wlan0): supplicant interface state: inactive -> scanning
Nov 16 07:47:26 homeassistant wpa_supplicant[373]: wlan0: Trying to associate with SSID 'MCZ-0142F5201FCE78'
Nov 16 07:47:27 homeassistant NetworkManager[360]: <info>  [1668584847.0245] device (wlan0): supplicant interface state: scanning -> associating
Nov 16 07:47:29 homeassistant wpa_supplicant[373]: wlan0: Associated with 42:f5:20:1f:ce:78
Nov 16 07:47:29 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-CONNECTED - Connection to 42:f5:20:1f:ce:78 completed [id=0 id_str=]
Nov 16 07:47:29 homeassistant kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Nov 16 07:47:29 homeassistant NetworkManager[360]: <info>  [1668584849.8904] device (wlan0): supplicant interface state: associating -> completed
Nov 16 07:47:30 homeassistant wpa_supplicant[373]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Nov 16 07:47:29 homeassistant NetworkManager[360]: <info>  [1668584849.8906] device (wlan0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "MCZ-0142F5201FCE78"
Nov 16 07:47:29 homeassistant NetworkManager[360]: <info>  [1668584849.8921] device (wlan0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:29 homeassistant NetworkManager[360]: <info>  [1668584849.9058] device (wlan0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:29 homeassistant systemd[1]: Starting Network Manager Script Dispatcher Service...
Nov 16 07:47:30 homeassistant systemd[1]: Started Network Manager Script Dispatcher Service.
Nov 16 07:47:30 homeassistant NetworkManager[360]: <info>  [1668584850.4586] device (wlan0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:30 homeassistant NetworkManager[360]: <info>  [1668584850.4593] device (wlan0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Nov 16 07:47:30 homeassistant NetworkManager[360]: <info>  [1668584850.4669] device (wlan0): Activation: successful, device activated.

Why does it fail reconnecting automatically ?

Thx a lot for your help

Did you find a way to reconnect the wifi using the ha command?

Hello yes I have found a solution but very specific to my set up to connect to my stove and the solution was to get rid of home assistant for the network connection :grimacing:

See my post here