now everythig is OK
This might well be a silly question but what’s the difference between this and the one on the add-on store?
The HA add-on is just a dockerized version of Uptime Kuma. Same code.
For anyone who has used webhooks to send up/down notifications from Uptime Kuma to HA, could you share some of the POST URL formatting on the Uptime side and then how you passed that to a notification in a HA automation?
I have a very static config running for a few monitored services using a 1:1 mapping between webhook and automation but I assume there has to be a better way by passing data in the POST.
Thanks!
In the 42 minutes since I made that post, it seems that using MQTT may be easier. I did have to build a docker image for Uptime Kuma adding MQTT but that was pretty straightforward.
Uptime Kuma notification config.
I run the Mosquito Broker add-on in HA.
HA Automation is really simple. Listens for the topic as a trigger:
Then fires a notification via push including the payload:
And voila!
Note that the docker image build is really simple and taken from a Uptime Kuma Git issue.
FROM louislam/uptime-kuma:latest
RUN apt update
RUN apt --yes install python3
RUN apt-get install python3-setuptools
RUN pip3 install --no-cache --upgrade pip paho-mqtt
You can grab this image here:
https://hub.docker.com/repository/docker/jasonshearer/uptime-kuma-mqtt
Hey All,
I didn’t realise I could use the integration to send an mqtt message out. I’ve configured the alert as below however I’m seeing the error “No output from Apprise” when I try to test the configuration.
Any hints would really be appreciated.
Thanks,
Paul
Paul…did you deploy uptime kuma from the default repo? If so, it does not have a MQTT client. See my note above around how I added MQTT.
hi Jason,
I’m a touch “dumb” when it comes to understanding docker images, but I don’t think my system setup supports them. I’m using HA OS on a Pi 4, don’t run docker. Or maybe I’m just not understanding it correctly.
For those interested in using webhooks, I inspected the contents with of a Kuma webhook with tcpflow -p -c port 80
. This is what is sent when a Kuma monitor detects a system is DOWN:
{
"heartbeat":{"monitorID":7,"status":0,"time":"2022-09-18 21:02:58.073","msg":"ping: <hostname>: Temporary failure in name resolution\n","important":true,"duration":8},
"monitor":{"id":7,"name":"ping-test","url":"https://","method":"GET","hostname":"<hostname>","port":null,"maxretries":0,"weight":2000,"active":1,"type":"ping","interval":20,"retryInterval":20,"resendInterval":0,"keyword":null,"expiryNotification":false,"ignoreTls":false,"upsideDown":false,"maxredirects":10,"accepted_statuscodes":["200-299"],"dns_resolve_type":"A","dns_resolve_server":"1.1.1.1","dns_last_result":null,"pushToken":null,"docker_container":"","docker_host":null,"proxyId":null,"notificationIDList":{"2":true},"tags":[],"mqttUsername":"","mqttPassword":"","mqttTopic":"","mqttSuccessMessage":"","databaseConnectionString":null,"databaseQuery":null,"authMethod":null,"authWorkstation":null,"authDomain":null,"radiusUsername":null,"radiusPassword":null,"radiusCalledStationId":null,"radiusCallingStationId":null,"radiusSecret":null},
"msg":"[ping-test] [.... Down] ping: <hostname>: Temporary failure in name resolution\n"
}
A similar message is sent when the system is detected UP (except that status
is set to 1).
For my use case, I have individual sensors for each service that I’m monitoring (requires a bit of boilerplate in Kuma and HA), but this is an example from what my configuration looks like in HA for two services that I’m monitoring in Kuma (I’m monitoring Kuma itself to be able to distinguish between all services being down, and Kuma itself being down)
template:
- binary_sensor:
- name: "Kuma Status"
state: "{{ trigger.json.heartbeat.status }}"
icon: >
{% if trigger.json.heartbeat.status == 1 %}
mdi:check-network-outline
{% else %}
mdi:close-network-outline
{% endif %}
device_class: connectivity
trigger:
- platform: webhook
webhook_id: kuma-status
- binary_sensor:
- name: "Nextcloud Status"
state: "{{ trigger.json.heartbeat.status }}"
icon: >
{% if trigger.json.heartbeat.status == 1 %}
mdi:check-network-outline
{% else %}
mdi:close-network-outline
{% endif %}
device_class: connectivity
trigger:
- platform: webhook
webhook_id: nextcloud-status
Hello, can You share how You achieve that cards?
I don’t have the same layout as before, but similar.
You need to create template sensors, then add them using the button cards in whatever layout you like.
Template Sensors
template:
- sensor:
- name: "Up"
state_class: total
icon: hass:cloud-upload
unique_id: uptimekumaup
state: "{{ states.sensor | selectattr( 'state', '==', 'up' ) | selectattr('attributes.icon', 'defined') | selectattr( 'attributes.icon', '==', 'mdi:television-shimmer' ) | list | length }}"
- name: "Down"
state_class: total
icon: hass:cloud-download
unique_id: uptimekumadown
state: "{{ states.sensor | selectattr( 'state', '==', 'down' ) | selectattr('attributes.icon', 'defined') | selectattr( 'attributes.icon', '==', 'mdi:television-off' ) | list | length }}"
- name: "Paused"
state_class: total
icon: hass:cloud
unique_id: uptimekumapaused
state: "{{ states.sensor | selectattr( 'state', '==', 'pause' ) | selectattr('attributes.icon', 'defined') | selectattr( 'attributes.icon', '==', 'mdi:television-shimmer' ) | list | length }}"
Cards
type: custom:vertical-stack-in-card
cards:
- type: markdown
content: |-
![Image](/local/images/uptime_kuma_header_logo3.png)
- type: horizontal-stack
cards:
- show_name: true
show_icon: true
type: button
entity: sensor.up
show_state: true
tap_action:
action: more-info
hold_action:
action: none
- show_name: true
show_icon: true
type: button
entity: sensor.down
show_state: true
tap_action:
action: more-info
hold_action:
action: none
This is what it looks like currently
Thank You very much. Works great. It’s possible to make visible if some service is down? I mean to display the name of that service?
not sure I understand what you mean by “service”?
- type: entity-filter
show_empty: true
entities:
- entity: sensor.01
secondary_info: last-changed
- entity: sensor.02
secondary_info: last-changed
- entity: sensor.03
secondary_info: last-changed
state_filter:
- down
- paused
- unknown
- unavailable
card:
title: Loations Offline
You need to use your sensors in place of sensor.01, sensor.02, etc…
Ohh Yeah sorry. I hope there’s some simpler way. I have many sensors in Uptime-kuma
Thanks for Your help.
Regards.
This should work.
type: markdown
content: >-
# Locations Offline
{% for state in states.sensor -%} {% if state.state == 'down' %} {{
state.attributes.friendly_name }} {{'\n'}} {% endif %} {%- endfor %}
Looks Like
Wow, You’re great, thank You so much!!!