Script For Recurring Chores in Home Assistant
This script creates tasks for your chores and sends notifications.
The function of the script
This script helps you manage recurring household chores in Home Assistant by automatically creating tasks with due dates and sending reminders when tasks are due or overdue.
I have used Perplexity AI for this to work (it took way too many iterations) so please write to me if some of the code originates from somewhere else and I missed a source.
The code of the script
alias: Daily Chore Managerdescription: Manage recurring chores with status checks and remindersmode: queuedsequence:- alias: Set chore variables variables: chores: - name: Pflanzen Gang gießen interval: 14 - name: Bettwäsche wechseln interval: 14 - name: Backofen reinigen interval: 30- alias: Fetch all tasks once target: entity_id: todo.haushalt response_variable: service_response action: todo.get_items data: status: needs_action- alias: Process each chore repeat: for_each: "{{ chores }}" sequence: - alias: Check task existence and details variables: all_tasks: "{{ service_response['todo.haushalt']['items'] | default([]) }}" task_summaries: "{{ all_tasks | map(attribute='summary') | list }}" item_exists: "{{ repeat.item.name in task_summaries }}" existing_task: >- {{ all_tasks | selectattr('summary', '==', repeat.item.name) | list | first | default({}) }} - alias: Create new task if needed if: - condition: template value_template: "{{ not item_exists }}" then: - target: entity_id: todo.haushalt data: item: "{{ repeat.item.name }}" due_date: > {{ (now() + timedelta(days=repeat.item.interval)).strftime('%Y-%m-%d') }} action: todo.add_item - alias: Send due today reminder if: - condition: template value_template: > {{ existing_task.due is defined and existing_task.due.split('T')[0] == now().strftime('%Y-%m-%d') }} then: - data: message: "⏰ Erinnerung: {{ repeat.item.name }} heute fällig!" action: notify.notify- alias: Process overdue tasks variables: today: "{{ now().strftime('%Y-%m-%d') }}" all_tasks: "{{ service_response['todo.haushalt']['items'] | default([]) }}" overdue_tasks: > {{ all_tasks | selectattr('due', 'defined') | selectattr('due', 'string') | selectattr('due', 'lt', today + 'T00:00:00') | rejectattr('due', 'contains', today) | map(attribute='summary') | list }}
- alias: Send overdue tasks notification if: - condition: template value_template: "{{ overdue_tasks | length > 0 }}" then: - service: notify.notify data: title: "⚠️ {{ overdue_tasks | length }} überfällige Aufgaben" message: > {% for task in overdue_tasks -%} • {{ task }}{{ '\n' }} {%- endfor %}
The necessary automation
To use this script effectively, you’ll need to create an automation that runs it daily:
alias: Run Daily Chore Managerdescription: Runs the chore manager script once per daytrigger:- platform: time at: "08:00:00"action:- service: script.daily_chore_manager
You Might Also Like
SWS Snippet #0039: HA Voice
Stuff Worth Sharing #018
This week featuring map porn, Home Assistant, Product Management and personal productivity systems. As I'm going to a wedding this weekend, this is a short episode. If you want a longer one, check out last week's episode or wait for next week's.
Adding Code Previews To Astro
This are the steps I took to add code previews to my .mdx files in Astro.