Last active
October 20, 2023 01:13
-
-
Save Didgeridrew/eb799db844ff85ac4becf6ccf4b99301 to your computer and use it in GitHub Desktop.
HA - Use Auto-Entities card for Grocy Chores and Tasks
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
| type: vertical-stack | |
| cards: | |
| - type: custom:mushroom-title-card | |
| title: '' | |
| subtitle: | | |
| Chores & Tasks | |
| - type: custom:auto-entities | |
| card: | |
| type: entities | |
| title: Chores | |
| filter: | |
| template: | | |
| {% set ns = namespace(chores=[])%} | |
| {% set t = now().date() -%} | |
| {% set my_sensor ='sensor.grocy_chores' -%} | |
| {%- for attr in states[my_sensor].attributes.chores | |
| | sort(attribute='next_estimated_execution_time') -%} | |
| {%- set date = attr.next_estimated_execution_time|as_datetime -%} | |
| {%- if date.date() <= t + timedelta(days=2) | |
| and attr.next_execution_assigned_to_user_id in [2, none]-%} | |
| {% set ns.chores = ns.chores + [ { | |
| 'type': 'button', | |
| 'entity': my_sensor, | |
| 'attribute': attr, | |
| 'name': attr.name ~ (' - OVERDUE' if (date.date() <= t) else ' - Due: '~date.date().strftime('%m/%d')), | |
| 'tap_action': { | |
| 'action': 'call-service', | |
| 'service': 'grocy.execute_chore', | |
| 'service_data': { | |
| 'chore_id': attr.id, | |
| 'done_by': attr.next_execution_assigned_to_user_id or 2, | |
| } } } ] %} | |
| {% endif %}{%- endfor %} | |
| {{ ns.chores }} | |
| - type: custom:auto-entities | |
| card: | |
| type: entities | |
| title: Tasks | |
| filter: | |
| template: | | |
| {% set ns = namespace(tasks=[])%} | |
| {% set SENSOR = 'sensor.grocy_tasks' -%} | |
| {%- for attr in states[SENSOR].attributes.tasks -%} | |
| {% set ns.tasks = ns.tasks + [ | |
| { | |
| 'type': 'button', | |
| 'entity': SENSOR, | |
| 'attribute': attr, | |
| 'name': attr.name, | |
| 'tap_action': | |
| { | |
| 'action': 'call-service', | |
| 'service': 'grocy.complete_task', | |
| 'service_data': | |
| { | |
| 'task_id': attr.id, | |
| } | |
| } | |
| } | |
| ] %} | |
| {%- endfor %} | |
| {{ ns.tasks }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment