custom-components / healthchecksio

Update and display the status of your healthchecks.io checks.
MIT License
52 stars 9 forks source link

How to Ingest Projects/Jobs into HomeAssistant? #28

Closed mathmaniac43 closed 2 years ago

mathmaniac43 commented 2 years ago

Is your feature request related to a problem? Please describe. Hello. I am new to Healthchecks.io, but really like the service. I had manually implemented a very similar (but harder to maintain) solution in Home Assistant using Webhooks and Select entities, but I think that Healthchecks is a more elegant and scalable solution. So, I spun up a self-hosted Docker container and plugged in my scheduled job (which currently run alongside the Webhooks I made already).

I am confused how to integrate data from Healthchecks.io into Home Assistant (version 2022.3.1), if it is possible to do so. Based on the image in the README, I expected to connect the server from Home Assistant and get information for each of my healthchecks. I have installed this integration (version 22.2.0) into HACS and added an instance of it using my API key, which succeeds (my server is self-hosted). However, I end up with an Integration that has no Devices or Entities. It looks like HA will ping my healthchecks per the ID I provide.

Maybe I am confused about what this Integration provides, or it provides different information for web-users vs. self-hosters? The README does not actually describe what this Integration does, or what information/functionality is provided.

Describe the solution you'd like I would like this (or another) Integration to connect to a Healthchecks server from Home Assistant (using the API key, maybe even the read-only one). I would then like some Devices and/or Entities to be provided, with connectivity status (maybe Unknown, Up-to-Date, Grace Period, and Delinquent), the time of the last successful ping, and the time of the last state change.

Either way, if this Integration is not intended to provide that ability, I think it would be helpful to clearly identify exactly what it can do/provide in the README.

Describe alternatives you've considered I have created a similar but cruder solution using Webhooks in Home Assistant. This required manually creating an Input Select and an Input Datetime entity for each healthcheck/job, and a few automations to inspect for out-of-date tasks.

Additional context Thank you for your help.

phidauex commented 2 years ago

Hi, I'm not the author, but it sounds like what you are looking for should already be in this integration. I just set it up myself, using Healthchecks.io (not self hosted yet). I created a Check for HomeAssistant itself, and gave that UUID in the integration as the Check ID. I then turned on the full API (not read-only, though that may work as well), and gave that as the API key. What I get now is all four of my checks, with their current status (just on/off, not the intermediate statuses), and an attribute with the last ping time:

image image

The integration is also sending a 5 minute ping to the check ID I gave it.

image

Are you not getting the info on your other checks? Have you tried reading the API response manually just to see what it is returning?

mathmaniac43 commented 2 years ago

@phidauex Thanks for the response and screenshots, that is helpful! What you get is what I want (and what I assumed I would get), good to confirm.

I noticed an issue with my self-hosted Healthchecks setup earlier, and it looks like I was not persisting data correctly, so my original setup is gone now. I fixed the persistence and am about to try to build it up again and test the integration; hopefully it'll be all systems go.

mathmaniac43 commented 2 years ago

Seems to be working now! I think it was primarily an issue with how I wasn't keeping the database file around, but I also upgraded to v2.0.1.