I’ve setup an automation that calls a rest_command service once an NFC tag is scanned.
The automation has a mapping variable between every tag id and an “chore id”, which is used for the rest api call.
That part works well, but I’d like to add a phone notification with a description of the “chore”, which I would like to fetch from the api.
But I’m not sure how to articulate that. Seems “rest” platform has a “resource_template” but I’m not sure how to pass the choreid (url is like /api/chores/{{ chore_id}}), except maybe via an input helper.
But I’m not really sure creating sensors and input helpers are a good way to go, since I would ideally keep things as much isolated as possible.
I don’t really understand this statement. Isolating grocy from HA and vice versa just makes automating more complicated. For example:
By not taking advantage of HA sensors, helpers, and/or custom integrations you will have to manually update your variable map every time you add or remove chores.
I use the custom integration, which creates a sensor containing a list of all the chores. This makes achieving a notification like you want a, relatively, simple matter of a template.
service: notify.mobile_app_phone
data:
title: Grocy Chore
message: |-
{{ state_attr('sensor.grocy_chores', 'chores') | selectattr('id', 'eq', chore_id)
| map(attribute='name') | first }} has been completed.
Thanks ! I’m using homeassistant core so I think I’ll have a bit more work, but the sensor.grocy_chores seems like a nice approach. I’ll try to do follow that way.