I have found in this forum this procedure:
- Create a Shell Script:
In the Terminal add-on or in a SSH terminal from another PC, go in /config dir:
cd config
in the /config directory I made a file call checkping.sh
with
nano checkping.sh
The file looks like this:
#! /bin/bash
ping -w 5 8.8.8.8 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Success"
else
echo "Fail"
fi
For save this, use CTRL+X
then confirm with Y
and press Return
.
The script pings google five times and reports after its done. After you have that done you have to make it executable with:
chmod +x checkping.sh
Finally, modify your path to add the directory where your script is located (/config under /root in Hass.io):
export PATH=$PATH:/root/config/
To test it, you can run from any directory:
sh checkping.sh
it should return “Success” or “Fail”.
- Create a Sensor in
configuration.yaml
:
binary_sensor:
platform: command_line
scan_interval: 30
name: WAN
command: "/root/config/checkping.sh"
payload_on: "Success"
payload_off: "Fail"
I used the scan_interval in my setup but I am not sure if it is doing anything.
- Create an Automation in
configuration.yaml
automation:
- alias: Reboot when internet goes down
trigger:
platform: state
entity_id: sensor.wan
to: 'off’
action:
- service: hassio.host_reboot
# A notice on telegram:
- service: notify.telegram
data:
title: '*Server Offline*'
message: Home Assistant is offline, rebooting...
Well… I did all this things, yesterday night, I left my RPi on, and today I tried to connect to Home Assistant: not working! I connected an HDMI monitor to it and, again, it showed an infinity scroolling loop text with:
brcmfmac: brcmf_proto_bcdc_query_dcmd: brcmf_proto_bcdc_msg failed w/status -110
brcmfmac: brcmf_proto_bcdc_query_dcmd: brcmf_proto_bcdc_msg failed w/status -110
brcmfmac: brcmf_cfg80211_get_station: GET STA INFO failed, -110
So, not solved with automation… I think that there would be a check from system, running in background, not in Home Assistant, that reboot if obtain this specific error… I read like cron
service… but I don’t know how, because cron
is not installed on Hass.io.
Any possible idea?