-
-
Save artbird309/eef1fcad6555cf83cba887a1e1dea91c to your computer and use it in GitHub Desktop.
Homeassistant Blueprint for SSL-Certificate renewal
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
| --- | |
| blueprint: | |
| name: Renew Let's Encrypt Certificate | |
| description: Renew certificate when due date is below given value and send Telegram notification. | |
| domain: automation | |
| input: | |
| cert_expiry_sensor: | |
| name: Certificate Expiry Sensor | |
| description: Sensor from the Certificate Expiry Integration (https://www.home-assistant.io/integrations/cert_expiry) | |
| selector: | |
| entity: | |
| integration: cert_expiry | |
| renew_date: | |
| name: Certificate renewal date | |
| description: Date when the SSL-Certificate will be renewed | |
| selector: | |
| number: | |
| min: 1 | |
| max: 29 | |
| mode: slider | |
| unit_of_measurement: days | |
| default: 5 | |
| time_to_check_cert: | |
| name: Certificate check time | |
| description: Time when the certificate date will be checked. | |
| selector: | |
| time: | |
| restart_ha_after_renewal: | |
| name: Restart Home Assistant | |
| description: Restarts the Home Assistant when the certificate is renewed. (if | |
| enabled) | |
| selector: | |
| boolean: | |
| default: true | |
| minutes_until_ha_restart: | |
| name: Minutes until restart | |
| description: Minutes until restart of Home Assistant if restart is enabled | |
| selector: | |
| number: | |
| min: 1 | |
| max: 60 | |
| mode: slider | |
| unit_of_measurement: minutes | |
| default: 5 | |
| notification_chat_id: | |
| name: Telegram Chat ID to notify | |
| description: Chat ID which will be notified. | |
| selector: | |
| text: | |
| notification_message: | |
| name: Notification message | |
| description: Notification message, sent when the certificate has been renewed. | |
| default: Home Assistant SSL certificate renewed | |
| alias: Renew SSL Cert | |
| description: 'Renew SSL Certificate, optionnaly: restart HA, send notification' | |
| trigger: | |
| - platform: time | |
| at: !input time_to_check_cert | |
| condition: | |
| - condition: template | |
| value_template: '{{ expire_days_var < var_check }}' | |
| action: | |
| - service: hassio.addon_start | |
| data: | |
| addon: core_letsencrypt | |
| - service: telegram_bot.send_message | |
| data: | |
| target: !input notification_chat_id | |
| message: '{{ message_var }}' | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: '{{ restart_ha_after_renewal_var }}' | |
| sequence: | |
| - delay: | |
| hours: 0 | |
| minutes: !input minutes_until_ha_restart | |
| seconds: 0 | |
| milliseconds: 0 | |
| - service: hassio.host_reboot | |
| default: [] | |
| mode: single | |
| variables: | |
| certificate_var: !input cert_expiry_sensor | |
| var_check: !input renew_date | |
| message_var: !input notification_message | |
| restart_ha_after_renewal_var: !input restart_ha_after_renewal | |
| expire_days_var: >- | |
| {{ ((as_timestamp(states(certificate_var)) - as_timestamp(now())) / 60 / 60 / | |
| 24 ) | int }} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simplify the blueprint by removing Nginx config and force notification that is migrated to Telegram.