Skip to content

Instantly share code, notes, and snippets.

@jtaseff
Last active March 4, 2024 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtaseff/8335c1ae106092d82cafebcc3d7e1750 to your computer and use it in GitHub Desktop.
Save jtaseff/8335c1ae106092d82cafebcc3d7e1750 to your computer and use it in GitHub Desktop.
RemindMe engine for Home Assistant - task creator script
alias: RemindMe Creator
description: Create a to-do task based on a voice intent
sequence:
- service: persistent_notification.create
metadata: {}
data:
message: on_day {{ on_day}}, partofday {{ partofday }}
enabled: true
- service: calendar.create_event
metadata: {}
data:
summary: "{{ reminder }}"
start_date_time: "{{ now() + timedelta(minutes = int(duration)*int(units)) }}"
end_date_time: "{{ now() + timedelta(minutes = int(duration)*int(units) + 10) }}"
target:
entity_id: calendar.todocal
enabled: false
- service: todo.add_item
metadata: {}
data:
item: |-
{% if reminder[:3] == 'to ' %}
{{ reminder[3:] }}
{% else %}
{{ reminder }}
{% endif %}
due_datetime: |-
{% if duration|string|length > 0 %}
{% set duedatetime = now() + timedelta(minutes = int(duration)*int(units)) %}
{% elif on_day|string|length > 0 %}
{% if on_day|int > 5 %}
{% set daysuntildesday = (on_day - now().strftime("%w")|int) % 7 %}
{% if daysuntildesday == 0 %} {% set daysuntildesday = 7 %} {% endif %}
{% set duedatetime = now() + timedelta(days=daysuntildesday) %}
{% else %}
{% set duedatetime = now() + timedelta(days=int(on_day)) %}
{% endif %}
{% else %}
{% set duedatetime = now() + timedelta(hours = 1) %}
{% endif %} {% if partofday|string|length > 0 %}
{% set duedatetime = duedatetime.replace(hour=partofday|int, minute=0, second=0, microsecond=0) %}
{% endif %} {{ duedatetime }}
target:
entity_id: todo.remind_me
enabled: true
mode: single
icon: mdi:reminder
fields: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment