Guide

Send HTTPS heartbeats from an ESP32 or ESP8266 with ESPHome

An ESP32 or ESP8266 can report directly to TurnIt from its firmware. Add an HTTP request on a repeating interval to a device that already has Wi-Fi configured.

A direct signal from the board

This setup is useful for a standalone board or when you want a separate outside signal from the board. Each request shows that its scheduled action ran and reached TurnIt. It does not validate sensor readings or the behavior of attached hardware.

If Home Assistant already manages your ESPHome devices, it can observe their local availability. Use the Home Assistant heartbeat for an external view of Core and the home connection.

Add an HTTP action to your existing configuration

  1. Create an account, then add a device with a name you will recognize in an alert.
  2. Choose and save the heartbeat interval and alert delay. These examples use 60 seconds between requests; match your sender to the saved settings. The alert delay must be at least twice the heartbeat interval and leave room for network delays.
  3. Open Heartbeat setup on the device. The dashboard provides commands with your URL and selected interval already filled in.

Replace YOUR_DEVICE_KEY with the value after v= in your device’s heartbeat URL, including the account and device identifiers. The TurnIt endpoint is already filled in. Keep your personal URL private.

Prefer an ESP32, where ESPHome verifies the HTTPS certificate. ESPHome cannot verify certificates on ESP8266: that variant disables verification and enlarges the TLS receive buffer to 16 KB, because the default buffer cannot hold a full TLS record. These blocks extend an existing device configuration; they are not complete firmware or Wi-Fi settings. Merge existing http_request, time, script, interval, sensor, text_sensor, binary_sensor and button entries instead of adding duplicate top-level keys.

Merge these blocks into a board that already has Wi-Fi configured. Prefer an ESP32 and keep TLS verification enabled. ESPHome cannot verify certificates on ESP8266, so that variant disables verification and needs a 16 KB TLS receive buffer. The board sends a heartbeat at the interval and exposes its last HTTP status, the time of the last accepted heartbeat, Wi-Fi signal, uptime and buttons to restart or send a heartbeat now; with the ESPHome api component, Home Assistant shows them as entities. Add items to your existing lists if you already use any of these keys. Sending manually less than one interval after the last accepted heartbeat returns 429.

ESP32 device YAML
http_request:
  verify_ssl: true
  timeout: 5s

time:
  - platform: sntp
    id: sntp_time

script:
  - id: send_heartbeat
    mode: single
    then:
      - if:
          condition: wifi.connected
          then:
            - http_request.get:
                url: !secret turnit_heartbeat_url
                capture_response: false
                on_response:
                  then:
                    - lambda: |-
                        id(heartbeat_status).publish_state(std::to_string(response->status_code));
                        if (response->status_code == 200) {
                          auto now = id(sntp_time).now();
                          if (now.is_valid()) id(last_heartbeat).publish_state(now.timestamp);
                        }
                on_error:
                  then:
                    - text_sensor.template.publish:
                        id: heartbeat_status
                        state: no response

interval:
  - interval: 60s
    then:
      - script.execute: send_heartbeat

text_sensor:
  - platform: template
    id: heartbeat_status
    name: TurnIt heartbeat status
    icon: mdi:heart-pulse
    update_interval: never

sensor:
  - platform: template
    id: last_heartbeat
    name: Last accepted heartbeat
    device_class: timestamp
    update_interval: never
  - platform: wifi_signal
    name: Wi-Fi signal
    update_interval: 60s
  - platform: uptime
    name: Uptime

binary_sensor:
  - platform: status
    name: Online

button:
  - platform: restart
    name: Restart
  - platform: template
    name: Send heartbeat now
    icon: mdi:send
    on_press:
      - script.execute: send_heartbeat
ESP8266 device YAML
http_request:
  verify_ssl: false
  tls_buffer_size_rx: 16384
  tls_buffer_size_tx: 512
  timeout: 5s

time:
  - platform: sntp
    id: sntp_time

script:
  - id: send_heartbeat
    mode: single
    then:
      - if:
          condition: wifi.connected
          then:
            - http_request.get:
                url: !secret turnit_heartbeat_url
                capture_response: false
                on_response:
                  then:
                    - lambda: |-
                        id(heartbeat_status).publish_state(std::to_string(response->status_code));
                        if (response->status_code == 200) {
                          auto now = id(sntp_time).now();
                          if (now.is_valid()) id(last_heartbeat).publish_state(now.timestamp);
                        }
                on_error:
                  then:
                    - text_sensor.template.publish:
                        id: heartbeat_status
                        state: no response

interval:
  - interval: 60s
    then:
      - script.execute: send_heartbeat

text_sensor:
  - platform: template
    id: heartbeat_status
    name: TurnIt heartbeat status
    icon: mdi:heart-pulse
    update_interval: never

sensor:
  - platform: template
    id: last_heartbeat
    name: Last accepted heartbeat
    device_class: timestamp
    update_interval: never
  - platform: wifi_signal
    name: Wi-Fi signal
    update_interval: 60s
  - platform: uptime
    name: Uptime

binary_sensor:
  - platform: status
    name: Online

button:
  - platform: restart
    name: Restart
  - platform: template
    name: Send heartbeat now
    icon: mdi:send
    on_press:
      - script.execute: send_heartbeat
secrets.yaml
turnit_heartbeat_url: "https://api.turnit.app/api/send?v=YOUR_DEVICE_KEY"

Build, install and check the board

Validate and compile the updated configuration using your usual ESPHome workflow, then install it on the intended board. After Wi-Fi connects and the interval runs, check Last heartbeat in TurnIt. If nothing arrives, inspect ESPHome logs for connection, DNS or HTTPS errors.

What does the board report to Home Assistant?

With the ESPHome api component, Home Assistant shows the HTTP status of the last heartbeat (200 when accepted, 429 when sent too early, or no response for DNS, TLS and connection errors), the time of the last accepted heartbeat, Wi-Fi signal, uptime and online state, plus buttons to restart the board or send a heartbeat now. These entities describe the board from inside your network; TurnIt remains the outside view that still alerts when Home Assistant or the connection is down.

On ESP32, keep verify_ssl enabled so the board checks the server certificate. On ESP8266 the connection stays encrypted but the server is not authenticated, so someone controlling your network could read the heartbeat URL; use it only on networks you trust. The secret entry belongs in the ESPHome configuration’s secrets.yaml. Keep that file private and do not publish your personal heartbeat URL.

What happens when the board sleeps?

A sleeping or powered-off board does not run the periodic action. Match the monitor to the device’s actual operating pattern. This continuous example is intended for a board that remains awake and connected.

Can I change the interval only in TurnIt?

Update both sides: save the monitor settings, copy the new YAML from the dashboard and install the updated firmware. Too-frequent requests can receive 429 without renewing the monitor; the example does not implement a Retry-After backoff, and the heartbeat status entity shows when that happens.

Reference: ESPHome HTTP Request configuration.

Give your device a way to check in

Create a device to get your own heartbeat URL and setup instructions.