Advice on Https connection to Healthchecks.io

Hi, I recently discovered the service Healthchecks.io which I now use on my main HA configuration and this is working well. I would now like to extend this and use this to check one of my ESP32 devices to ensure it is still alive and active.

I simply need to do a call to HTTP to an address, example below.

https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx

I would like the ESP32 to connect to that address every 30 minutes.

If the ESP32 does not connect Healthchecks.io can be configured to alert me.

Any guidance on the code for this much appreciated.

Thanks

Hi thank you for the pointer, I am very much a novice in this area and have through trial and error managed to get the code below installed on my ESP32 and installed without errors.
I’m uncertain which HTTP request method to use. I’ve tried a number of them but all show an error in the log as below. I can see the interval is working as the error only appears every minute. Any advice if I’m on the right track appreciated.
Literally I just need to ping that address.
Thanks

[23:00:34][W][http_request:087]: HTTP Request failed; URL: https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx; Error: connection refused; Duration: 3 ms


http_request:
  useragent: esphome/device
  timeout: 10s
  

interval:
  - interval: 60s
    then:
      - http_request.send:
          url: https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx
          verify_ssl: false 
          method: PUT

Does it work in your browser? Or with curl?

Yes, if I just go to https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx in my browser on laptop or mobile it shows an ok message. I can then see on the Healthchecks.io dashboard that a connection has been made and appears as a ‘last ping’ update.

I thought this would be a neat way to remotely monitor my ESPhome devices (ESP32 based) for connectivity.
Thanks

(Note the last 4 characters xxxx in url are changed for privacy)

You should be using HEAD, GET or POST not PUT https://healthchecks.io/docs/http_api/

1 Like

You didn’t answer my question about curl, but @ludeeus is probably right on the button.

Hi Sorry for not coming back in the curl question. I’ll be honest and have no experience of using curl. It’s on my learning list…
So interesting developments on this. The code I posted used PUT but I had previously tried GET and POST without success. Thanks Ludeeus for confirming the correct method. This put me on the right path.
I was still having no joy so started again with a new ESP32. I was surprised to see this worked using the code below

http_request:
  useragent: esphome/device
  timeout: 10s
  
interval:
  - interval: 5min
    then:
      - http_request.get:
          url: https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx
          verify_ssl: false 

Adding this to the ESP32 I have setup that I want to monitor still gave the connection refused error reported. Head scratching time!
Comparing ESP32’s the only difference is the one that did not work I had assigned a static i.p using the code:

  manual_ip:
    static_ip: 192.168.0.138
    gateway: 192.168.0.1
    subnet: 255.255.255.0 

Removing this code resulted in a success and I can now successfully ‘ping’ my Healthchecks.io dashboard. This is reporting correct operation.

This ESP32 is connected to hardware that monitors my wireless smoke alarms and can alert me on any alarm conditions to my mobile phone. Having the Healthchecks.io is an extra layer that the ESP32 is alive and connected to the internet. Pleased with this.

I’m confused however why fixing the i.p would cause an issue?

The only other question I have is the logging on esphome reports the following even though its working fine. Is this an area of concern ?

[11:55:53][D][http_request:099]: HTTP Request completed; URL: https://hc-ping.com/96775fbe-c3d3-4d38-b527-xxxx; Code: 200; Duration: 70 ms
[11:55:53][W][component:214]: Component interval took a long time for an operation (0.09 s).
[11:55:53][W][component:215]: Components should block for at most 20-30ms.

Many thanks for the guidance.

possibly because the static setting doesn’t specify a dns server.

when you delete the static, the device will use dhcp, which will tell it what dns server to use.

I really dont understand why are you complicating things. You can use uptime kuma and set all the monitoring you can think off. You can also configure it to send you notification on ie. telegram account.