Shopping_list state attributes are gone with today's HA update

Hello,

I always used an automation to send the shopping-list items to my phone like described here:

After todays update to HA Core 2023.6.1 I the sensor.shopping_list has only 1 attribute, which contains the number of active items in the list, but not the item names anymore.

Is it possible, to get it working like before?

My configuration.yaml:

# shopping list
command_line:
  - sensor:
      name: "Shopping List"
      unit_of_measurement: "items"

      json_attributes: 
        - name
        - complete

      command: "jq -r '.[] | select(.complete==false) | .name' .shopping_list.json"

thanks for posting this as I didnā€™t notice that it was broken

I managed to fix it (for now) by changing command_line config in yaml to the following:

command_line:
  - sensor:
      command: "jq -r '{complete: [.[] | select(.complete==true) | .name], incomplete: [.[] | select(.complete==false) | .name]}' .shopping_list.json"
      name: shopping_list
      unique_id: shopping_list_sensor
      scan_interval: 15
      json_attributes:
        - complete
        - incomplete
      value_template: "{{ value_json.incomplete | length }}"

and also this has to be deleted from automation as shopping_list sensor now become unavailable whenever I reload command_line integration:

  - service: command_line.reload
    data: {}

hopefully this will work for you as well

1 Like

This also brings only the number of items in the shopping_list in the message.

I tried in terminal jq -r '.[] .name' .shopping_list.json and i get listed all the names of the items on my shopping list. But if I use the same command in my .yaml, the message is ā€œ9 to buyā€ instead of ā€œButter, Milk to buyā€.

Can someone explain this to me, please?

I am not sure what is the cause of the problem you experience, just wanted to note that this looks fine on my HA instance
shopping_list_sensor

Finally Iā€™ve got it to work again after changing the order of the lines in my configuration.yaml
Thank you!

Is there anyway to create multiple ā€œShopping Listsā€ based on the name prefix to use in automations?

For example, if I have items ā€œGiant - Milkā€ and ā€œTarget - Deoderantā€ and I have each place set up as a location in HA, if I went to Giant it would only return the list of items starting with ā€œGiantā€? I think it would be a new json_attribute, but Iā€™m not sure how Iā€™d go about filtering the list down. Any thoughts?

Hereā€™s a condition I use with a zone enter trigger around my local shop:

    - condition: and
      conditions:
      - condition: trigger
        id: hill_st
      - condition: template
        value_template: "{{ '### HILL ST ###' in states('sensor.shopping_list_items')}}"

It would be a lot easier if we had multiple lists.

1 Like

Is it possible to do this with the new integration with the to-do list?

I have not updated yet but I think what I am going to do is have separate todo lists for each shopping zone. The state of the todo list is the number of unchecked items, so the condition should be able to be simplified to something like this:

   - condition: and
      conditions:
      - condition: trigger # zone trigger
        id: hill_st
      - condition: numeric_state
        entity_id: todo.hill_st
        above: 0

I apologize for the confusion, but my question was about creating the sensor with items in the attributes for the new TODO list integration.

1 Like

I canā€™t find the file that stores the data for the TODO list. Only the ā€˜.shopping_list.jsonā€™ is visible.

Look for a local todo .ics file.

1 Like

Iā€™ve already found the files locally in the .storage folder, but I couldnā€™t find the ones from Google Tasks

Google tasks does not have any local storage.

I am using Node-RED to filter the data contained in the file to obtain the list of items in this case, I can only use the ā€œlocalā€ listsā€¦

Is there any update planned to be able to obtain the data stored in each list? A good option would be to have in each list all entities, the items in the attributes field with both completed and uncompleted. Itā€™s basically what Iā€™m doing through Node-RED.

If/when itā€™s added, it will be a responding service. Just like getting calendar events.

2 Likes

It was great to see this implemented as soon as possible.

1 Like

Fully agree! Either as attributes or as a service similar to ā€œCalendar.list_eventsā€, but for todo-items.

Currently, it seems there is no way to include for example to-do list items in an email or notification text :frowning:

Really hope a solution will come around!

Okay, I have looked for the local to do list but cannot figure out where the data itself is stored. As I understand from the above discussion, there is no solution to this yet right?

The data is stored in a ics file in the .storage folder. Itā€™s a file called ā€œlocal_todo.[your todo list name].icsā€. But there isnā€™t yet a smooth way to extract the attributes, yet.

3 Likes