64 lines
2.4 KiB
YAML
64 lines
2.4 KiB
YAML
#:########################################################################################:#
|
|
# Package: Node-RED Health Checks
|
|
# File: health_checks.yaml
|
|
# Version: v1.2.0
|
|
# Date: 2025-08-25
|
|
#
|
|
# Purpose:
|
|
# Monitors the Node-RED Panda instance through independent HTTP and MQTT health
|
|
# signals and combines them into one connectivity status.
|
|
#
|
|
# Behaviour:
|
|
# - Polls the HTTP health endpoint every 30 seconds with a three-second timeout.
|
|
# - Tracks the MQTT birth/will topic with QoS 1 and a 180-second expiry.
|
|
# - Reports the combined check as available when either source is available.
|
|
# - Reports the combined check as connected when either source is connected.
|
|
#
|
|
# Dependencies:
|
|
# - Reachability of the configured Node-RED HTTP health endpoint.
|
|
# - Home Assistant MQTT integration and the Node-RED birth/will publisher.
|
|
#
|
|
# Version History:
|
|
# - v1.2.0 (2025-08-25): Reduced MQTT expiry to 180 seconds and clarified the
|
|
# combined HTTP/MQTT sensor name.
|
|
# - v1.1.0 (2025-08-22): Split HTTP and MQTT probes and added a combined sensor.
|
|
# - v1.0.0 (2025-08-21): Initial Node-RED health-check package.
|
|
#:########################################################################################:#
|
|
|
|
# ---- HTTP health probe ----
|
|
binary_sensor:
|
|
- platform: rest
|
|
name: Node-RED Panda Up (HTTP)
|
|
resource: http://192.168.3.200:1880/healthz
|
|
method: GET
|
|
device_class: connectivity
|
|
value_template: "{{ value_json.status == 'ok' }}"
|
|
timeout: 3
|
|
scan_interval: 30
|
|
|
|
# ---- MQTT Will/Birth probe ----
|
|
mqtt:
|
|
binary_sensor:
|
|
- name: "Node-RED Panda Up (MQTT)"
|
|
unique_id: "nodered_panda_up_mqtt"
|
|
state_topic: "nodered/panda/status"
|
|
payload_on: "online"
|
|
payload_off: "offline"
|
|
device_class: connectivity
|
|
qos: 1
|
|
# Optional: avoid stale 'online' if no updates arrive
|
|
expire_after: 180
|
|
|
|
# ---- Combine them (true if either is up) ----
|
|
template:
|
|
- binary_sensor:
|
|
- name: "Node-RED Panda Up (HTTP/MQTT)"
|
|
unique_id: "nodered_panda_up_combined"
|
|
device_class: connectivity
|
|
state: >
|
|
{{ is_state('binary_sensor.node_red_panda_up_http','on')
|
|
or is_state('binary_sensor.node_red_panda_up_mqtt','on') }}
|
|
availability: >
|
|
{{ states('binary_sensor.node_red_panda_up_http') not in ['unknown','unavailable']
|
|
or states('binary_sensor.node_red_panda_up_mqtt') not in ['unknown','unavailable'] }}
|