Help Automation Reconect Wifi -- ha network update wlp1s27u2

Sorry for my English…

Is there a way to launch an automation that executes this command:
ha network update wlp1s27u2 --wifi-auth wpa-psk --wifi-mode infrastructure --wifi-ssid SSIDTEXT --wifi-psk PASS

I have a wifi that goes down sometimes, I have created a sensorbynario that pings to know its status.

With the command that I passed via shell I can reconnect the Wi-Fi, but I don’t know how to automate it.

Any ideas?


I have an issue with Home Assistant Supervised losing the DNS setting for static IP settings in network settings on every reboot and I have concocted this workaround you can use for your issue as well.

  1. Install SSH Addon, I use the “Advanced SSH & Web Terminal”
  2. Setup a port, username and password for SSH
  3. Install GitHub - AlexxIT/SSHCommand: SSH exec service for Home Assistant
  4. Setup an Automation to run on Home Assistant Start (On ping loss in your case).

My Automation is:

alias: DNS Update
description: Updates HA DNS server at boot to workaround bug of lost setting.

  • platform: homeassistant
    event: start
    condition: [ ]
  • service: ssh_command.exec_command
    metadata: {}
    port: 23
    user: root
    pass: password
    command: ha network update eth0 --ipv4-nameservers --ipv6-method auto
    mode: single

Obviously change username, port and password above to match your setup for “Advanced SSH & Web Terminal”

host: works for ha network and other ha cli commands.

In your case the automation trigger would be your ping fail and
command: ha network update wlp1s27u2 --wifi-auth wpa-psk --wifi-mode infrastructure --wifi-ssid SSIDTEXT --wifi-psk PASS

Another way to do this is to setup password-less SSH and use a shell_command but AlexxIT’s SSHCommand is easier to setup, just not as secure as the password is in plain text in the automation.

Cheers, JC.