📝 Alexa Shopping & To-do Lists Integration

Hey everyone,

I just released my Alexa To-Do Lists integration :tada:.

It allows you to synchronize your Alexa To-do and Shopping lists with Home Assistant. It directly uses the unofficial Alexas APIs (used by the Alexa mobile app) to access the services. In contrast to previous solutions, no additional servers or selenium scripts are necessary.

The API was reverse-engineered by intercepting the Alexa mobile app’s HTTP traffic. I implemented the API client in a separate Python library pyalexatodo so that other projects could also make use of it.

It works very similar to the Alexa Devices Integration which is an official part of Home Assistant. The login workflow is actually adapted from this integration. The setup only requires the Amazon credentials and a current OTP token (generated by authenticator app).

Changes from Home Assistant are reflected immediately on the Alexa side. Changes initiated from the Alexa side (echo device, Alexa app) are only pulled periodically from the Amazon servers. Currently, the sync interval is set to 10 minutes.

The custom integration can be installed via HACS from GitHub (currently as custom repo): GitHub - lonlazer/ha-alexa-todo-lists: Sync Alexa To-Do and Shopping list with Home Assistant · GitHub

So far I could only test it with a German Amazon account. So it would be interesting to know if it works also in other regions seamlessly.

Happy to hear any feedback :slight_smile:

2 Likes

Works with a US Amazon account.

1 Like

It would be great to have an action to call that would sync the list on demand.

2 Likes

Hi @mterry63

Thanks for your feedback :slight_smile:

On demand sync should already be possible by calling the homeassistant.update_entity action.

action: homeassistant.update_entity
data:
  entity_id:
    - todo.alexa_todo_shop

I have a few issues that may be unrelated to the integration but related to Todo entities in general.

My Alexa shopping list had hundreds of checked off items in it, so when I initially loaded the integration it was impacting performance while the list updated. I deleted all the checked off items in the Alexa app, but even if I delete the integration and reload it, they always return to the Todo list. The “Remove completed items” option in the Todo list doesn’t work (nothing happens). I suspect the internal Todo list management can’t handle hundreds, if not thousands, of items. I thought maybe it was a caching issues, so I went to my development system and installed the integration there, but I still get all the checked off items, even though the Alexa app says there are none. I’m not sure how to proceed.

Hi @mterry63

  1. Remove completed items: With this button Home Assistant will just give a list of completed items to the integration. This will result in one API call per item. While this button works for a smaller number of items, for hundreds of items it is indeed not performant enough. I checked the traffic of the Alexa app again: The "Clear Completed " function will also just issue separate API calls per item. There seems to be no endpoint to delete all/multiple items at once. So unfortunately there is not much I can do here for now. Maybe I could add a delay between deleting items, but then it would take forever.
  2. Deleted items are still there: I haven’t been able to reproduce the issue where deleted items continue to sync. The only thing I can think of: the items are being hidden rather than deleted. The Alexa app has two options “Hide” and “Clear”. “Hide” will actually only hide the items locally in the app, but nothing is changed in the backend. Could this be the problem?
    You could also check on the web interface, if the items are still listed in “Completed items” category: Amazon Sign-In

Interesting that you sent the web site link. I had used the “Clear completed” in the App, and even “show completed” and nothing appears. But if I visit the web link it shows “100 completed”. If I delete them (the number decrements) and wait a few seconds it goes back to “100 completed” on it’s own. I think this comes from the fact there may be thousands of completed entries.

Well, that resulted in a real rabbit-hole of a chase.

Seems like using Anylist for years synced 8,000+ completed items to my Alexa Shopping list. I setup an autohotkey script to delete them from the web link you suggested.

Doing some research with Copilot revealed that the Alexa app batches 100 items at a time, and “Clear completed” actually only clears 100 at a time. So it took a while to get 8K items deleted.

It doesn’t appear that the Home Assistant todo list integration deals with sanity checking list size and I got several errors about the attribute size exceeded and recorder errors due to the size of the list.

Just a heads up for anyone else who finds themselves with very large todo lists due to a sync process.

I believe I’m at a more normal state now.

Thanks for the easy to setup integration!

1 Like

This is nice work. Thank you!

FWIW, I think having a refresh icon on the To-Do Lists page, similar to what is available on the Calendars page, would be convenient — and eliminate the need navigate elsewhere to call the service when an immediate update is needed.

1 Like

Thanks for your research. That behavior of the API is interesting.

The To-do list entities hold the entire list in memory, so they are indeed not capable of handling thousands of items. I currently see no way to optimize this, as there is no pagination or similar functionality.

I might just add a hard limit to load only the first x items and show a warning to prevent the system from slowing down.

Glad to hear that it works now!

Good to hear, that you like it so far :slight_smile:

Adding a refresh button is a good idea. However, this would have to be implemented directly in Home Assitant core as this UI is provided by it. It should be quite easy to implement, as it could just call the update function similar to the aforementioned service. But this request has to be raised directly to Home Assistant.

1 Like

Sounds like a reasonable compromise. Currently there is no “wait signal” when you have a big list, the page just hangs and the UI becomes unresponsive until it eventually fills in.