Closed MReschenberg closed 9 months ago
Hey there @vividboarder, mind taking a look at this issue as it has been labeled with an integration (nextbus
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
nextbus documentation nextbus source (message by IssueLinks)
FWIW, I used to use the recommended sfmuni-sandbox
but that stopped working and now supplies no predictions even when there are trains out and about (I think the agency has migrated)
The sfmuni-sandbox
does appear to occasionally return no predictions. It usually comes back eventually. Unfortunately, it seems like the API being used is considered “legacy” and they are adding new features to a new, authenticated internal API.
I emailed them a few years ago to ask about getting an API key, but never got a response.
I dug a bit more.Still protected by an API key. I could possibly enhance the py_nextbus client to spoof a browser request to get the cookie and API key and use that with the new APIs, or possibly use the ADA site, which is server side rendered, and scrape values.
Alternatively, while it appears that SFMuni has outsourced their predictions to Umo (formerly by NextBus), the Muni website has a predictions API that is not authenticated. This could probably be supported as a new integration separate from the NextBus/Umo one.
Where can I find the Muni predictions API? I'm happy to take a stab at using that for now / writing something new
You can go here, pick any stops to get a prediction, then inspect the network requests. You should be able to see them there: https://www.sfmta.com/getting-around/muni/routes-stops
Thanks :)
I did some poking around and found there's a separate (mixed?) API that gets accessed via queries to the ADA version of the website here. The queries seem to use the same abbreviated syntax as the nextbus api but they support the new agency tag.
Unfortunately, the request returns an HTML doc instead of a nicely parsable JSON or XML file, but the HTML is semantic so 🤷♀️ maybe something is possible there. There's no key required for this API.
This URL is the equiv for the request I was originally trying to make:
https://retro.umoiq.com/predictor/adaPrediction.jsp?a=sfmta-cis&r=K&d=K_0_var2&s=6991
There's also a hardcoded agency list in the js on the predictions index.html source (view-source:https://retro.umoiq.com/predictor/)
agencies = ["jhu-apl","appcart","tl-bccf","ccrta","chapel-hill","oxford-ms","west-hollywood","da","dumbarton","charles-river","elon","escalon","fast","glendale","great","tl-hbl","indianapolis-air","jfk","kean","lga","tl-l","lincolnlab","maine-med","manteca-transit","mit","merida","montclair","ewr","nova-se","omnitrans","pvpta","sria","pct","portland-sc","reno","roosevelt","salisbury","bawt","sfmta-cis","links","seattle-sc","selkirk","slippery-rock","stl","sct","geg","tahoe","ttc","ucla","unitrans","ucb","unh","vacaville","vmc","wcu","wku","winston-salem",0];
While technically one can consider that an API that returns HTML, but it would typically just be considered a webpage. Using that as an API source is not possible as a part of homeassistant/core
since it would qualify as webscraping: https://github.com/home-assistant/architecture/blob/b85484512dd8f27338c6ae2ff28e9a7cf78abb2f/adr/0004-webscraping.md
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
I'm trying to use a sensor config corresponding to the URL:
https://retro.umoiq.com/#!/sfmta-cis/K/K_0_var2/6991
however when I supply "sfmta-cis" as the agency param in my yaml sensor config like this:
I get the following error in logs:
What version of Home Assistant Core has the issue?
core-2023.9.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
NextBus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/nextbus/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response