Created
February 16, 2024 17:23
-
-
Save lukasjakobi/ff67ee77767222d291b1addff1629023 to your computer and use it in GitHub Desktop.
Jinja2 Template for Vacuum Mop Attach/Detach Notification
This file contains 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
{% set now = now() %} | |
{% set earliest_reminder = '05:00:00' %} | |
{% set latest_reminder = '21:00:00' %} | |
{% set start_time = '15:00:00' %} | |
{% set end_time = '11:00:00' %} | |
{% set current_weekday = now.weekday() %} | |
{% set current_time = now.strftime('%H:%M:%S') %} | |
{% set water_box_attached = state_attr('vacuum.roborock_qrevo', 'waterBoxCarriageStatus') == 1 %} | |
{% set weekdays = [0, 3] %} | |
{% set ns = namespace(notification=False, message="") %} | |
{% for weekday in weekdays %} | |
{% set weekday_before = (weekday - 1) % 7 %} | |
{% set notify_weekday_before = current_weekday == weekday_before and current_time >= start_time and not water_box_attached %} | |
{% set notify_weekday_morning = current_weekday == weekday and current_time <= end_time and current_time >= earliest_reminder and not water_box_attached %} | |
{% set notify_weekday_afternoon = current_weekday == weekday and current_time >= start_time and current_time <= latest_reminder and water_box_attached %} | |
{% if notify_weekday_before %} | |
{% set ns.message = "Leonardo möchte morgen wischen, bitte montiere die Wischmopps" %} | |
{% endif %} | |
{% if notify_weekday_morning %} | |
{% set ns.message = "Leonardo wird heute wischen, montiere jetzt die Wischmopps!" %} | |
{% endif %} | |
{% if notify_weekday_morning %} | |
{% set ns.message = "Die Wischmopps von Leonardo müssen noch entfernt werden" %} | |
{% endif %} | |
{% if notify_weekday_before or notify_weekday_morning or notify_weekday_afternoon %} | |
{% set ns.notification = true %} | |
{% endif %} | |
{% endfor %} | |
{{ ns.message }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment