Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active October 20, 2023 01:13
Show Gist options
  • Select an option

  • Save Didgeridrew/eb799db844ff85ac4becf6ccf4b99301 to your computer and use it in GitHub Desktop.

Select an option

Save Didgeridrew/eb799db844ff85ac4becf6ccf4b99301 to your computer and use it in GitHub Desktop.
HA - Use Auto-Entities card for Grocy Chores and Tasks
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