#Grocy Chore/Task Notifications

1 messages · Page 1 of 1 (latest)

hasty hawk
#

Hello!

So i'm unsure if this has been asked before/i have no idea how i would search for it. But I am trying to create a automation that looks at the Grocy Chore or Task list, and pulls the name of each chore, along with the date, to push notifications to the related user's phone.

With the integration, there is a entity called grocy chores, with the following attributes:

Chores
- id: 1
name: Take Trash Out
description: null
period_type: weekly
period_config: monday
period_days: 1
track_date_only: false
rollover: true
assignment_type: in-alphabetical-order
assignment_config: '3'
next_execution_assigned_to_user_id: 3
userfields: null
last_tracked_time: null
next_estimated_execution_time: '2025-03-24T07:30:00'
last_done_by: null
track_count: 0
next_execution_assigned_user:
id: 3
username: Name2
first_name: Name2
last_name: no
display_name: Name2
- id: 2
name: Take Trash Back
description: null
period_type: weekly
period_config: monday
period_days: 1
track_date_only: false
rollover: true
assignment_type: in-alphabetical-order
assignment_config: '2'
next_execution_assigned_to_user_id: 2
userfields: null
last_tracked_time: null
next_estimated_execution_time: '2025-03-24T11:30:00'
last_done_by: null
track_count: 0
next_execution_assigned_user:
id: 2
username: Name1
first_name: Name1
last_name: no
display_name: Name1
- id: 3
name: Take Recycling Out
description: null
period_type: weekly
period_config: thursday
period_days: 1
track_date_only: false
rollover: true
assignment_type: in-alphabetical-order
assignment_config: '3'
next_execution_assigned_to_user_id: 3
userfields: null
last_tracked_time: null
next_estimated_execution_time: '2025-03-20T07:30:00'
last_done_by: null
track_count: 0
next_execution_assigned_user:
id: 3
username: Name2
first_name: Name2
last_name: no
display_name: Name2
- id: 4
name: Take Recycling Back
description: null
period_type: weekly
period_config: thursday
period_days: 1
track_date_only: false
rollover: true
assignment_type: in-alphabetical-order
assignment_config: '2'
next_execution_assigned_to_user_id: 2
userfields: null
last_tracked_time: null
next_estimated_execution_time: '2025-03-20T11:30:00'
last_done_by: null
track_count: 0
next_execution_assigned_user:
id: 2
username: Name1
first_name: Name1
last_name: no
display_name: Name1

Count
4
#

so for example the automation would loop through all of the for chore ids, look at when the estimated execution time is, check if that is the same date/time as right now, and then trigger a notification on the associated username's phone.

forest saffron
#

You'll probably want to use a repeat/for_each loop on that attribute

hasty hawk
# forest saffron You'll probably want to use a repeat/for_each loop on that attribute

so, like i got a couple ideas of how to do this but i'm not quite sure on what would work best in HA...

repeat:
  for_each:
    "{{ state_attr('sensor.grocy_chores', 'chores') }}"
  sequence:
    - action: notify.mobile_app
      metadata: {}
      data:
        message: "{{ repeat.item.name }} by {{ as_datetime(repeat.item.next_estimated_execution_time).strftime('%H:%M %p') }}"
        title: "New Chore"

at the moment I have this in a script... but how would I go about making this schedule the notifications or trigger the automation on the date time

forest saffron
#

Do you only want to notify on chores that are currently due?

hasty hawk
#

well like... ideally it would be something like... a hour before the item is due or the day of, notify.

forest saffron
#

a hour before the item is due

I'd probably just trigger every hour, and then do the repeat, and then for each item check if it is due within the next hour, and send notification if true.

hasty hawk
#

But I guess at that point I can just do a if and check the time/date before sending the notification... and then have the script trigger ever hour?

#

ah

#

yeah

#

mkay... lemme see if i can figure that out...

#

i know like java and all that stuff but never messed with yaml/anything like this... its a lil too abstracted for my brain to understand at the moment haha

forest saffron
#

Just look for "Time Pattern Trigger"

midnight gulch
hasty hawk
#

sooo

#
alias: Hourly Chore Notifications
description: ""
triggers:
  - trigger: time_pattern
    hours: "*"
conditions:
  - condition: time
    after: "06:30:00"
actions:
  - repeat:
      for_each: "{{ state_attr('sensor.grocy_chores', 'chores') }}"
      sequence:
        - if:
            - condition: and
              conditions:
                - condition: template
                  value_template: >-
                    {{ (now()+ timedelta(hours = 1)) >=
                    as_local(as_datetime(repeat.item.next_estimated_execution_time))
                    }}
                - condition: template
                  value_template: >-
                    {{ now() <=
                    as_local(as_datetime(repeat.item.next_estimated_execution_time))
                    }}
          then:
            - choose:
                - conditions:
                    - condition: template
                      value_template: >-
                        {{ repeat.item.next_execution_assigned_to_user_id == 2
                        }}
                  sequence:
                    - action: notify.mobile_app_anon
                      data:
                        message: >-
                          {{ repeat.item.name }} by {{
                          as_datetime(repeat.item.next_estimated_execution_time).strftime('%-I:%M
                          %p') }}
                        title: New Chore
                - conditions:
                    - condition: template
                      value_template: >-
                        {{ repeat.item.next_execution_assigned_to_user_id == 3
                        }}
                  sequence:
                    - action: notify.mobile_app_obamaphone
                      data:
                        message: >-
                          {{ repeat.item.name }} by {{
                          as_datetime(repeat.item.next_estimated_execution_time).strftime('%-I:%M
                          %p') }}
                        title: New Chore
mode: single

#

this is what i ended up on

#

i didn’t use the visual at all