Feature request: Display connection status inside Home Assistant dashboards? #543
Closed
eigenbaunerd
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Unfortunately, it is not possible for an add-on to provide entities in HA. This only works via (custom) integrations. However, since cloudflared comes with an integrated metrics server, the status in HA can be displayed as binary_sensor or sensor via a command_line integration. Here are two examples that should work. Further sensors and information could also be added via the other API endpoints (see comments in the coding). ---
# Use command_line integration to leverage Cloudflared add-on metrics
# https://www.home-assistant.io/integrations/command_line/
#
# http://9074a9fa-cloudflared:36500 if you use the stable repo add-on
# http://ffd6a162-cloudflared:36500 if you use the edge repo add-on
# available API endpoints:
# /ready --> used for this sensor
# /healthcheck
# /metrics
command_line:
# Binary sensor which shows on/off depending on Cloudflare tunnel connection
- binary_sensor:
name: Cloudflare Tunnel Connected
unique_id: cloudflare_tunnel_connected
scan_interval: 60
icon: >
{{ 'mdi:cloud-check' if is_state("binary_sensor.cloudflare_tunnel_connected", "on") else 'mdi:cloud-cancel' }}
command: "curl -fs http://9074a9fa-cloudflared:36500/ready || echo '{}'"
value_template: >
{% if value_json.readyConnections | default(0) > 0 -%}
ON
{%- else -%}
OFF
{%- endif %}
# Sensor with more tunnel connection information
- sensor:
name: Cloudflare Tunnel Status
unique_id: cloudflare_tunnel_status
scan_interval: 60
icon: >
{{ 'mdi:cloud-check' if is_state("sensor.cloudflare_tunnel_status", "Connected") else 'mdi:cloud-cancel' }}
command: "curl -fs http://9074a9fa-cloudflared:36500/ready || echo '{}' "
value_template: >
{% if value_json.readyConnections | default(0) > 0 -%}
Connected
{%- else -%}
Disconnected
{%- endif %}
json_attributes:
- status
- readyConnections
- connectorId
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
for a remote installation of Home Assistant I would love to be able to show the connection status of the cloudflare tunnel to the local users on a dashboard.
Can there be a binary sensor that shows the connection status?
Beta Was this translation helpful? Give feedback.
All reactions