lambtho
(Lambtho)
February 22, 2020, 2:49pm
1
Healthchecks.io is a very nice service that allows you to monitor the status of some automatic tasks (backups,…). It can also be used to check regularly that a device is still running and online (heartbeat). Healthchecks integrate with multiple services (mail, telegram, whatsapp,…) so it can send messages if some check fails.
On top of that, it can also be polled by API to check the status of the various checks implemented.
I think it would be a very nice integration witrh HA. First as a sensor: HA could poll healthcheck API in order to check the status of the different checks. A second option would be to make it so healthcheck can directly send alerts to home-assistant instead of telegram, so it could trigger actions in HA later on.
ludeeus
(Ludeeus)
February 22, 2020, 3:43pm
2
1 Like
lambtho
(Lambtho)
February 24, 2020, 9:34am
3
So far I am using the RESTful sensor and template sensors in order to get everything. This works quite well, but would definitely be better if integrated directly.
Jayk34
September 3, 2020, 12:46pm
4
where do you do the config of this. I have copied the folder and added the integration but cant find anywhere to setup the config for this.
thanks
Romanmir
(Chris)
October 11, 2020, 3:01pm
5
I’m currently working on this, and am having trouble getting the auth keys correctly configured. Would you be willing to post a sanitized version of your sensor/template config?
lambtho
(Lambtho)
December 7, 2020, 9:24am
6
Hi, sorry for the delay. I did not check these forums for quite some time… If it stills interest you, here is the sensor I am using
- platform: rest
name: healthcheck_backups
resource: https://healthchecks.io/api/v1/checks/
value_template: 'OK'
json_attributes:
- checks
headers:
X-Api-Key: !secret healthchecks_api
Content-Type: application/json
User-Agent: Home Assistant REST sensor
Accept: application/json
scan_interval: 300
force_update: true
Then I use a template sensor in order to parse the output and have something nice to display in HA.
- platform: template
sensors:
helathchecks_sensor1:
friendly_name_template: "{{states.sensor.healthcheck_backups.attributes.checks[0].name}}"
value_template: "{{states.sensor.healthcheck_backups.attributes.checks[0].status}}"
attribute_templates:
next_ping: >-
{% if states.sensor.healthcheck_backups.attributes.checks[0].next_ping == none %}
None
{% else %}
{{((as_timestamp(states.sensor.healthcheck_backups.attributes.checks[0].next_ping)-as_timestamp(now())) | float/(24*60*60)) | round(1)}}
{% endif %}
icon_template: >-
{% if states.sensor.healthcheck_backups.attributes.checks[0].status == "up" %}
mdi:check-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "down" %}
mdi:close-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "paused" %}
mdi:pause-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "started" %}
mdi:play-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "grace" %}
mdi:clock
{% else %}
mdi:help-circle
{% endif %}
It is probably not that complicated to port such a simple logic to a full blown healthchecks integration that would generate the sensors properly from the API result. I just do not have time to do it now or anytime soon.
5 Likes
woodmj74
(Mike Wood)
March 8, 2021, 9:07am
7
@ludeeus thanks for this, just found it!
1 Like
Townsmcp
(James T)
January 27, 2024, 12:06pm
8
Just in case anyone comes across this and wants an updated template sensor, here is my code (many thanks to @lambtho )
template:
- sensor:
- name: "HealthCheck.io Status"
unique_id: 04f8f434-805e-4548-9c12-1ee97d98aa0c
state: "{{states.sensor.healthcheck_backups.attributes.checks[0].status}}"
attributes:
next_ping: >-
{% if states.sensor.healthcheck_backups.attributes.checks[0].next_ping == none %}
None
{% else %}
{{((as_timestamp(states.sensor.healthcheck_backups.attributes.checks[0].next_ping)-as_timestamp(now())) | float/(24*60*60)) | round(1)}}
{% endif %}
icon: >-
{% if states.sensor.healthcheck_backups.attributes.checks[0].status == "up" %}
mdi:check-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "down" %}
mdi:close-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "paused" %}
mdi:pause-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "started" %}
mdi:play-circle
{% elif states.sensor.healthcheck_backups.attributes.checks[0].status == "grace" %}
mdi:clock
{% else %}
mdi:help-circle
{% endif %}
1 Like
henfri
(Hendrik Friedel)
March 23, 2024, 9:10am
9
Hello,
how do you ping a healthcheck via homasssistant?
Greetings,
Hendrik
lambtho
(Lambtho)
April 9, 2024, 6:59pm
10
See the first part here in my previous comment.
The rest sensor pings the URL automatically by simply checking it.
You then use a template sensor to render everything properly in Home Assistant
Hi, sorry for the delay. I did not check these forums for quite some time… If it stills interest you, here is the sensor I am using
- platform: rest
name: healthcheck_backups
resource: https://healthchecks.io/api/v1/checks/
value_template: 'OK'
json_attributes:
- checks
headers:
X-Api-Key: !secret healthchecks_api
Content-Type: application/json
User-Agent: Home Assistant REST sensor
Accept: application/json
scan_interval: 300
force_update: true
Then I use a te…