This project is based on (https://github.com/jtbnz/amazon_shopping_list/) by https://github.com/jtbnz
If you want to use as a Home Assistant Addon, use the link below:
https://github.com/thiagobruch/HA_Addons
The project scrapes the Amazon Shopping List page and add the items to the Home Assistant Shopping List (todo list) every 3 minutes (this can be changed in the file script.sh)
You will need the Amazon Email and Password that you use to Login, the OTP Secret Key and the Home Assistant Webhook URL. Please find the instructions on how to get the OTP Secret Key and the Home Assistant Webhook URL:
1 - Login to Amazon https://www.amazon.com/
2 - Go to Your Account => Login & Security and click on "Turn On" under 2-step verification
3 - Select the Authentication App
4 - Click on "Can't scan the barcode" and save the Key (13 sets of 4 characters each)
5 - Remove the spaces of the Key (you will have something like this "ASDMASDFMSKDMKSFMKLASDDADABB6JNRNF7WFEHQW23H238R7843")
1 - Login to Amazon https://www.amazon.com/
2 - Go to Your Account => Login & Security and click on "Manage" under 2-step verification
3 - Under Authenticator App, click on Add New App
4 - Click on "Can't scan the barcode" and save the Key (13 sets of 4 characters each)
5 - Remove the spaces of the Key (you will have something like this "ASDMASDFMSKDMKSFMKLASDDADABB6JNRNF7WFEHQW23H238R7843")
1 - Go to your Home Assistant interface and go to Settings, Automations & Scenes, Automations
2 - Click on "+ Create Automation" and select "Create new automation"
3 - Click on Add Trigger and select Webhook
4 - Click on the copy symbol on the right to get the URL and save it (example: http://homeassistant.local:8123/api/webhook/-hA_THs-Yr5dfasnnkjfsdfsa)
You'll have to use the internal URL
5 - Switch the view to YAML (three dots on the top right - Edit in YAML)
6 - Delete the line "action: []" and aste the following code:
action:
- action: todo.get_items
data:
status:
- needs_action
- completed
response_variable: todo
target:
entity_id: todo.shopping_list
- if:
- condition: template
value_template: |-
{{trigger.json.name not in todo['todo.shopping_list']['items'] |
map(attribute='summary') | list}}
then:
- data_template:
item: "{{ trigger.json.name }}"
target:
entity_id: todo.shopping_list
action: todo.add_item
mode: parallel
max: 100
7 - Click on Save and give a name to the Automation
Once you have the information above, you can use two methods:
1 - Docker Image already built
2 - Create your own Docker Image
Pull Image(around 800MB):
docker pull thiagobruch/amazon-scrape-tb
Start Image:
docker run -d \
--name amazon-scraper \
-e AMZ_LOGIN='<YOUR_AMAZON_EMAIL>' \ # your email address used to login at amazon in this format 'email@email.com' including single quotes.
-e AMZ_PASS='<YOUR_AMAZON_PASSORD>' \ # your password used to login at amazon in this format 'mypassword1234' including single quotes.
-e AMZ_SECRET='<YOUR_OTP_APP_SECRET>' \ # your OTP App Secret in this format 'mypassword1234' including single quotes. More instructions above.
-e HA_WEBHOOK_URL='<HOME_ASSISTANT_WEBHOOK_URL' \ # your Home Assistant Webhook URL including single quotes. More instructions above.
-e Amazon_Sign_in_URL='<Amazon_SIGNIN_URL>' \ # The Sign-In Page for your amazon Account. More instructions on the address below
-e Amazon_Shopping_List_Page='<Amazon_SHOPPING_LIST_URL>' \ # The Shopping list Page for your amazon Account. More instructions on the address below
-e polling_interval='180' \ # The pooling interval in seconds. We recommend using 180 seconds or more.
-e delete_after_download=true \ # When set to true, the items will be delete from Amazon Shopping list once they are added to HA.
thiagobruch/amazon-scrape-tb
1 - Save all the file in a single directory
2 - Run the following command:
docker build -t amazon-scrape-tb .
3 - It will take a while to create the image (around 850MB)
4 - Once it is completed, run the docker run command with the variables to start the container:
docker run -d \
--name amazon-scraper \
-e AMZ_LOGIN='<YOUR_AMAZON_EMAIL>' \ # your email address used to login at amazon in this format 'email@email.com' including single quotes.
-e AMZ_PASS='<YOUR_AMAZON_PASSORD>' \ # your password used to login at amazon in this format 'mypassword1234' including single quotes.
-e AMZ_SECRET='<YOUR_OTP_APP_SECRET>' \ # your OTP App Secret in this format 'mypassword1234' including single quotes. More instructions below.
-e HA_WEBHOOK_URL='<HOME_ASSISTANT_WEBHOOK_URL' \ # your Home Assistant Webhook URL including single quotes. More instructions below.
-e Amazon_Sign_in_URL='<Amazon_SIGNIN_URL>' \ # The Sign-In Page for your amazon Account. More instructions on the address below
-e Amazon_Shopping_List_Page='<Amazon_SHOPPING_LIST_URL>' \ # The Shopping list Page for your amazon Account. More instructions on the address below
-e polling_interval='180' \ # The pooling interval in seconds. We recommend using 180 seconds or more.
-e delete_after_download=true \ # When set to true, the items will be delete from Amazon Shopping list once they are added to HA.
amazon-scrape-tb
e.g. United States:
"https://www.amazon.com/ap/signin?openid.pape.max_auth_age=3600&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Falexaquantum%2Fsp%2FalexaShoppingList%3Fref_%3Dlist_d_wl_ys_list_1&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=amzn_alexa_quantum_us&openid.mode=checkid_setup&language=en_US&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0"
e.g. Italy:
"https://www.amazon.it/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.it%2Fref%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=itflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0"
e.g. Germany:
"https://www.amazon.de/ap/signin?openid.pape.max_auth_age=3600&openid.return_to=https%3A%2F%2Fwww.amazon.de%2Falexaquantum%2Fsp%2FalexaShoppingList%3Fref_%3Dlist_d_wl_ys_list_1&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=amzn_alexa_quantum_de&openid.mode=checkid_setup&language=de_DE&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0"
e.g. United States:
"https://www.amazon.com/alexaquantum/sp/alexaShoppingList?ref_=list_d_wl_ys_list_1"
e.g. Italy:
"https://www.amazon.it/alexaquantum/sp/alexaShoppingList?ref_=list_d_wl_ys_list_1"
e.g. Germany:
"https://www.amazon.de/alexaquantum/sp/alexaShoppingList?ref_=list_d_wl_ys_list_1"
Add the following to the "docker run" command:
-e debug_log=true -p 8888:8888
Because this is a one way sync (from Amazon Shopping List to Home Assistant), I have an automation that clear Amazon Shopping list every night at midnight. Here is the Automation in YAML:
description: ""
mode: single
trigger:
- platform: time
at: "00:00:00"
condition: []
action:
- service: media_player.volume_set
data:
volume_level: 0.01
target:
entity_id: media_player.my_alexa
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: media_player.play_media
data:
media_content_type: custom
media_content_id: "clear my shopping list"
enqueue: play
target:
entity_id: media_player.my_alexa
enabled: true
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
enabled: true
- service: media_player.play_media
data:
media_content_type: custom
media_content_id: "yes"
enqueue: play
target:
entity_id: media_player.my_alexa
enabled: true