Count items on the shopping list

Hi all,

Hoping I am overlooking something here, but I’ve checked through the developer area, but can’t find anything.
I wanting to know if there is a way to count the number of uncheck items on the Shopping List?

I have an automation that when at a Supermarket a notification is fired off to the person there if they want to check the shopping list, but ideally would like this only if there are actually items on the list, and do it as a prompt.

Thanks.

2 Likes

This question gets asked pretty often. I’ve seen the following suggested as a solution.

sensor:
  - platform: command_line
    name: "Shopping List"
    unit_of_measurement: "items"
    command: "jq '[.[] | select(.complete==false) | .name] | length' .shopping_list.json"

Might be worth updating the documentation if this works.

See:

2 Likes

Thank you for posting this. It does work

1 Like

Silly question but where does this go in the configuration.yaml?

When I put it in I get a dup key error which is obviously because I have the same as the sensor below? I am starting to think that my config file probably needs a re-org with all my sensors in one place under the sensor heading?

OK ignore me, I was being stupid. I have sorted it… It was too many “sensor” tags…