#Shipment Tracking
1 messages · Page 1 of 1 (latest)
Also if I were to make it exist... It technically couldn't run locally without cloud access? Like if I made the code do all the scraping locally it'd still communicate out to all the carriers so instead of making some kind of web service hosted in the cloud, it may as well just do the scraping itself
Shipment Tracking
in the end, It'd be great to integrate into the new fancy Calendar integration to show deliveries on that
hey. i have no experience coding for HA, but a quick search gives me this: https://developer.amazon.com/docs/amazon-pay-api-v2/delivery-tracker.html for amazon, https://developers.aliexpress.com/en/doc.htm?docId=30120&docType=2 for aliexpress
once we have the tracking numbers, getting shipment status will be easy. i can have a look at how to retrieve order details for amazon and AE
i'll have a look and see how difficult this would be
if you were putting the tracking numbers in manually, a 17Ship integration would work best
but there's just no way in heck I'm going to do that. Why make automations that you have to do manually ?
the main advantage here is if anything anyone orders anywhere is going to end up at your front door at some point in time... Show it here
that's what i'm hoping the amazon and aliexpress APIs would let us do
i'll have a look tomorrow
for the amazon api, the trackingNumber is a required field... Judging by it's format it will not be parsable from the email and looks like it'd have to be manually input... Continuing to look down the scraping path (which is super lame, but when they don't give you what you want, you take it I guess)
tried a series of urls and order numbers as suggested in the FAQ using parcelsapp.com that I could potentially yoink from emails but none of those work either
fired up the lib https://www.npmjs.com/package/amazon-order-reports-api and tried to use it, it couldn't login, so I followed the steps it would normally take, took forever to generate the report, finally got an email, clicked the link, Amazon gives me a 401... Not liking this path
just a bunch of junk trash connecting to other junk trash
looks like this will be harder than expected... Brought the actual tracking number to AfterShip just to see what should be available and... Not found
Leads me to believe, tracking Amazon packages specifically is going to be the most difficult as they're the biggest garbage producer so it looks like I'll need to make a scraper login to the actual amazon account and grab as much details as possible
from what I read, another option is Tasker, which for crappy Amazon, that may be great to listen for phone notifications and shoot them over to node-red or some such
oh well, the amazon link i had was for another amazon product 😄
mh yeah so there's https://developer-docs.amazon.com/sp-api/ but that's for sellers, not consumers
anyway. i can't find how to retrieve the tracking number for a given order with amazon using web dev tools. can you find anything? another approach would be selenium. ugly and slow, but that could be a way
I'm using puppeteer, logging in, going to orders page, grabbing the orders, so far so good, got a few bugs, like every 10 or so times it tries it'll give me a captcha so I need to save the cookies and use them as much as possible but so far so good, I may be able to make a simple module just for amazon to pull as much product details as possible, then something else can use that to bring it further
i'll see what i can do this afternoon either with selenium or hopefully without
didn't have too much time today to have a proper look. but i just tried to GET the page for an order's tracking info (amazon website > orders > select one that has a physical shipment > track order ; something like that) with a python requests session that has all the cookies set. interesting result: first attempt: mostly garbage suggesting i wasn't logged in. second attempt with the exact same cookies, session object, etc, and i have this somewhere in the result:
To discuss automated access to Amazon data please contact api-services-support@amazon.com.
For information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.fr/ref=rm_c_sv, or our Product Advertising API at https://partenaires.amazon.fr/gp/advertising/api/detail/main.html/ref=rm_c_ac for advertising use cases.
-->
i didn't modify my requests session's User-Agent though
well, all this to say, with a bit of work i think it's achievable. i'll try and find time to work on this
it's a super interesting project
I've got it working in js world
now trying to learn how to make an actual HA integration, thinking this would just be "amazon-orders" under brand "Amazon", to simply collect order data and nothing else
need a better way to do headless browser integrations with python, I'm more of a JS dude
judging by how long it takes to restart hass I sure hope the development cycle is that slow or I'd say goooooodbye
going to work on just making a little python project that matches the js first
ok, requests is immediately out as it doesn't support javascript, poop on that, next up is selenium which has some really dumb instructions for installing drivers, as in, going to their distribution page and or wgetting them or some such.... That's not going to work in a hass install, grr, why are people so dumb?
need to be able to identify the OS and install something appropriate, not just bundle some dumbass elf executable into your repo and slap a done sticker on it
the more I read, the more I don't like it, there's no way I'd be like "ok, next step in setup is go to this url that doesn't exist anymore and install this thing that doesn't work on your platform or isn't compatible with our library anymore and pull your hair out trying to get it running"
"just find the arm64 v7 binary over here where it used to be"
ok, back to a service with polling, I'm going to stick with javascript that uhmmm... Works, then from a hass integration we can poll with the dumb python, the smart javascript
ok, a command line process is available at https://www.npmjs.com/package/amazon-orders-scraper as an example, I'm just going to use command line integration to run it, parse the result and stuff the data where it goes