Created
February 6, 2025 13:08
-
-
Save MXMLN-sec/541b6bb48c032976b47cd401664238af to your computer and use it in GitHub Desktop.
Home Assistant certificate expiry notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upcoming_cert_expiry: | |
name: "TLS Zertifikat läuft bald ab" | |
entity_id: binary_sensor.<cert-name>_cert_renew_required | |
state: "on" | |
repeat: | |
- 1440 | |
can_acknowledge: true | |
skip_first: false | |
title: > | |
{% set state = (states('binary_sensor.<cert-name>_cert_renew_required')) %} | |
{% if state == 'on' %} | |
⚠️ TLS Zertifikat läuft bald ab | |
{% else %} | |
✅ TLS Zertifikat wurde erneuert | |
{% endif %} | |
message: > | |
Das Zertifikat <cert-name> läuft in {{ states('sensor.<cert-name>_cert_valid_days') }} Tagen am {{ as_timestamp(states('sensor.<cert-name>_cert_expiration_date')) | timestamp_custom('%d.%m.%y') }} ab! | |
done_message: > | |
Das Zertifikat <cert-name> wurde erneuert und ist noch {{ states('sensor.<cert-name>_cert_valid_days') }} Tage bis zum {{ as_timestamp(states('sensor.<cert-name>_cert_expiration_date')) | timestamp_custom('%d.%m.%y') }} gültig. | |
notifiers: | |
- grp_notify | |
data: | |
tag: upcoming-cert-expiry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if int(states('sensor.<cert-name>_cert_valid_days')) is number %} | |
{% set valid_days = states('sensor.<cert-name>_cert_valid_days') %} | |
{{ iif(int(valid_days) <= 14, true, false) }} | |
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if states('sensor.<cert-name>_cert_expiration_date') is not in ["unknown", "unavailable", ""] %} | |
{% set expiration_date = states('sensor.<cert-name>_cert_expiration_date') %} | |
{{ (as_datetime(expiration_date) | as_local - today_at()).days }} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Home Assistant config notifies you 14 days before an TLS certificates expires. It requires
the Certificate Expiry
integration which monitors the expiration date of an certificate.
The monitored certificate in the integration has an ID like this:
sensor.<cert-name>_cert_expiration_date
Replace
<cert-name>
in all the configurations with your preferred name.