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?

Yes,

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.
trigger:

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

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

host: 172.17.0.1 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.