If a website is unavailable, it could simply be an outage at the provider – or a bigger problem such as a hacker attack. With Home Assistant, you can easily stay informed about downtime.
To do this, we’ll build a new binary sensor based on a command-line call.
|
|
⚠ [affiliate] Keine Produkte mit Cache für default.
Bitte affiliate-sync --lang en ausführen.
We use the command_line platform and call the curl command with it. We configure the call so that we get the response code of the page we want to monitor – in my case https://fricklr.com . A reachable page returns response code 200. The –insecure parameter ensures that the test doesn’t get stuck on an SSL certificate check.
The check is then run every 60 seconds via scan_interval: 60, which you can of course change.
If there are no problems, the new binary sensor entity “fricklr Status” has the status off. If it returns any response code other than 200, it has the status on or problem.
You can then build an automation that, for example, sends an email with a notification, makes the office lights blink, or triggers whatever else you want.
By the way, this solution is more sensible than a simple ping command. A ping would always give a positive response as long as the web server shows any reaction – even if it’s, for example, a 500 error.
What do you think? Leave a comment!
Share your thoughts, questions or experiences with the community.