madmachinations / home-assistant-alexa-shopping-list

A custom component for Home Assistant which synchronises your Alexa Shopping List
GNU General Public License v3.0
32 stars 3 forks source link

Events not fired #15

Closed alexiri closed 1 month ago

alexiri commented 1 month ago

I'm trying to build some automation around this but it looks like shopping_list_updated events aren't being triggered when the list is updated. Is this a known issue?

madmachinations commented 1 month ago

It's not a known issue for me no, but i also haven't tried.

Which event(s) are you latching onto? Item added/removed etc definitely won't fire I don't think. But the event which just says the shopping list has changed should.

The shopping list is told by this component each time the list changes, and it re-reads the data file to pick-up the new version of the list.

It's possible that event is not attached to the process though.

alexiri commented 1 month ago

I'm subscribing only to shopping_list_updated, and it's not getting triggered.

madmachinations commented 1 month ago

Okay, so that's not really anything to do with this component tbh. That's the shopping list component itself that is not firing it's updated event, when it's told that it has been updated.

What automation are you trying to do? Are you trying to do something only when the list changes, or are you trying to do something each time the list synchronises?

If it's the latter, I think this component exposes a sensor entity which has the "last synchronised time" in it. You could latch onto whenever that changes.

If it's only when the list has changed, then something would need to be added to cover this.

alexiri commented 1 month ago

What I'm trying to do is a two-way sync between the Alexa list and one on Anylist, so I really want to know when the list changes. It doesn't really make sense to have HA in the middle trying to do the sync, but I was hoping it would be the easiest-to-implement option.

madmachinations commented 1 month ago

I see, okay I can add an event for this I'm sure.

madmachinations commented 1 month ago

Alright, if you replace the alexa_shopping_list custom_component you have installed currently with the new on in the repo; An alexa_shopping_list_changed event is fired whenever it synchronises with the alexa shopping list, and the HA shopping list is changed in some way during that process.