Sync your Alexa/Todoist shopping list to the Home Assistant shopping list!

Thanks for the great integration. I have everything working with one exception.
I have 2 way sync enabled with webhook updates from Todoist. When I add an item via HA using the standard Add item field in the Shopping List, it syncs to Todoist. Great! However i created some frontend buttons to add specific items to the shopping list calling the shopping_list.add_item service. These show up in the HA Shopping List but do not sync to Todoist. If i type wine using Add Item it does sync.
Not good with python so dont know where to look to see if it is not possible with the current script.

Unfortunately, calling the service directly doesn’t fire an event which the script listens to. This seems to only fire when using the UI.

Thanks. Ill work around it. Any ideas?

If you can work this into your automation for the button: Script Syntax - Home Assistant

And have it the same format as this event:

{
    "event_type": "shopping_list_updated",
    "data": {
        "action": "add",
        "item": {
            "name": "test",
            "id": "xxxxx",
            "complete": false
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-23T17:14:37.382140+00:00",
    "context": {
        "id": "xxxxx",
        "parent_id": null,
        "user_id": null
    }
}

Thats exactly what i was thinking to do and Bob’s your uncle. Works a charm thanks.

Is there any way to do the same thing for Google Keep?

I don’t know. This project wouldn’t be the best, as it is not possible to sync an Alexa or Google Assistant shopping list to Google keep.

Its working pretty good for me except it only syncs from todoist to HA when i add an item in HA then the other items in todoist show up in HA and the item i added in HA shows up in todoist, same with deleting and editing. i also can manually call the service to sync. Im doing it through a todoist webhook from HA cloud so that might be my problem, if that is there an easy way to do the same thing with HA Cloud? i dont wanna open any ports on my router plus im already paying for the cloud service

I love how this works thanks but I was hoping it would also sync from HA to todoist, is this possible please? @MrLemur

It syncs both ways.

It should work fine if you setup a webhook in the same way as the instructions show.

IT DOES! Sorry. This is amazing, thank you so much.

It works! Great idea! Thanks for sharing

First I must say great solution and documented steps easy and straightforward!

I did have trouble with the two-way sync at first. My HA list did update/overwrite from Todoist/Alexa but then I tried editing items in Todoist and they did not sync. I then tried adding in Todoist and they did not sync and also vice-versa. Deleted all HA items, then Todoist items and re-added them in Todoist and then HA sync’d. I then added a new item via HA and it sync’d so not sure what the issue was along the way…

I am having this error now and the list is not syncing…

This error originated from a custom integration.

Logger: custom_components.pyscript.file.shopping_list_sync.sync_shopping_list
Source: custom_components/pyscript/eval.py:480
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 4:50:19 PM (5 occurrences)
Last logged: 4:53:31 PM

Exception in <file.shopping_list_sync.sync_shopping_list> line 23: status_code = response.status_code ^ NameError: name 'response.status_code' is not defined

It finally synced.

I don’t know if this is a new change in policy for Todoist, but the webhook recently stopped working for me, and I believe this is why -

https://developer.todoist.com/sync/v8/#webhooks

For security reasons, Todoist only allows webhook urls that have HTTPS enabled and no ports specified in the url.

Just a heads-up in case anyone else is experiencing this issue (I worked around it by routing my webhook call via IFTTT).

1 Like

It keeps showing an error in the logs.

Everything else is working as expected. Adding or deleting items from HA updates todoist that updates Alexa. Any were I update, updates the other two.

> Logger: homeassistant.util.async_
> Source: util/async_.py:150
> First occurred: 16:55:45 (3 occurrences)
> Last logged: 16:55:48
> 
> Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom component author for pyscript doing blocking calls at custom_components/pyscript/eval.py, line 1906: return func(*args, **kwargs)

Info:
Pi4
Home Assistant OS 7.6
core-2022.4.0
supervisor-2022.03.5

3 Likes

Thanks for this awesome script! It mostly works for me, however:

When adding an item via Todoist, the shopping list in HA won’t get synced by itself. Only after adding another item via the HA shopping list, the list syncs and shows both the recently added item and the item added before via Todoist.

Any ideas what the issue could be here?

Check the webhook, that could be the problem