Calling shopping_list.add_item service from HA Assist

Hello,

does someone tried to make custom sentence in HA Assist for adding item to Shopping list compontent using shopping_list.add_item service? Basically we need just to call shopping_list.add_item service with argument X from Assis (Add X to shopping list).

Thanks

1 Like

I’ve tried also to overwrite existing HassShoppingListAddItem intent but whetever I do I just can’t pass “item” param to intent_script or responses: intents: custom configuration in config file.

I tried the same thing whilst creating a new intent, the doc states that only a few ootb intents have been incorporated …not shoppinglist

According the Assist documentation this should be possible but my Assist just dies immediately after I type in something that cannot be resolved, dies as in: if takes a few seconds for the first request and then comes back with “Sorry, I couldn’t understand that” and any request after is immediately followed with the same.
Assist - Custom Sentences - Home Assistant (home-assistant.io)

What I did was create a yaml in config/custom_sentences/en

language: "en"
intents:
  ShoppingListAdd:
    data:
      - sentences:
        - "Add {shop_item} to shopping list"
        
lists:
  shop_item:
    values:
      - in: "egg"
        out: "egg"
      - in: "wine"
        out: "wine"

and added this to configuration.yaml

intent_script:  
  ShoppingListAdd:
    action:
      service: "shopping_list.add_item"
      data:
        name: "{{shop_item}}"

…does not work and opened a topic on one of the channels, no response yet

I think old intents still work:

Deprecated but still there. And they are also available in shopping_list component code:

I was able to overwrite “HassShoppingListLastItems” with my sentence and it was responding with shopping list items. Only thing which I was not able to solve was to pass item param.

Can you send me your code please, I may miss the whole point here :slight_smile:

Nothing big here. In file:

/config/custom_sentences/pl/shopping_list.yaml

I have added:

intents:
  HassShoppingListLastItems:
    data:
      - sentences:
        - "co jest na mojej liście zakupów"

and it returns whats on my shopping list so I was hoping that instead creating a new intent I could reuse one which is hardcoded in shopping_list component:

HassShoppingListAddItem

but I could’t pass item param in this intent too.

got it working, my instance was on en GB and for some reason that does not match “en”, need to look into that later
in the yaml

language: "en"
intents:
  ShoppingListAddItem:
    data:
      - sentences:
        - "Add {shop_item} to shopping list"  
        
lists:
  shop_item:
    values:
        - "egg"
        - "wine"

in configuraiton.yaml

intent_script:      
  ShoppingListAddItem:
    action:
      service: "shopping_list.add_item"
      data:
        name: "{{shop_item}}"
    speech:
      text: "{{shop_item}} added to shopping list"  

image

It works :slight_smile: (I didn’t tried list before). Any idea how to modify it so it will accept any words for shopping list item instead of ones from list?

1 Like

Started the very same question on discord as maintaining a list is not what I want too

1 Like

There is also working override to HassShoppingListAddItem but I have no idea how to put variable from sentence to slot name

  HassShoppingListAddItem:
    data:
      - sentences:
          - "add something to shopping list"
        slots:        
          item: "some item"
          type: "ShoppingListItem"

After passing “add something to shopping list” to Assist we are getting response:

I've added some item to your shopping list

For the moment I have stopped, if I really have to provide a list of items then this is not what I will continue with. Especially since the request has to be ‘exact’. For me, adding ‘whatever string’ should be allowed

1 Like

I was hoping to have some kind of possibility to use {{ something }} inside sentence phrase and pass this variable to slots: item: param (since this variable is passed to internal intent of shopping_list component). Maybe it can be done but I have no idea how.

3 Likes

Hey!! Have you guys managed to figure this out? I’ve test your method and so far works like a charm. I’ve used chatgpt to create a grocery list and added it to the list but it still misses a bunch of stuffs because my family is used to add things like (sons name + cookies).
My current solution was syncing Alexa to the home assistant shop list (integrated alexa to todoist app then used a webhook to sync all shoplists) So my family adds grocery’s through my echo show in the kitchen or in the living room and it updates my HA. Really happy because my zones automation for whenever I’m near the supermarket shows all items added via alexa, todoist or home assistant.

I’m just missing this {{ something }} template so they are able to use only HA to manage all list via companion app or through the home dashboards and only use the echos for whenever they are near one inside the house.

1 Like

Yes, please, can anyone get this working? I mean, how difficult can it be to implement? :slight_smile:

came across this just now trying to figure out something similar…
mostly got it working by adding

intents:
...  
  sentences:
    - "remind me to {reminder}"
  slots:
    reminder: defaultvalue

lists:
  reminder:
    wildcard: true

I’m hoping to have a button on my dashboard that I can press then say an item and have that added to a specific shopping list.

So for instance, press the button, say “milk” and milk is added to my grocery list.

I can add a button that starts Assist and I can say “add milk to my groceries list” which works but I want to shortcut it a bit so it is easy to just walk past and quickly add items.

Any ideas out there?