-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blisko source #3011
base: master
Are you sure you want to change the base?
Add blisko source #3011
Conversation
I do not like that you need to provide ids you need to obtain yourself. You could then hardcode a list of ownerIDs to select from or provide your own (the edpevent_se source does basically the same). And you can then add them to EXTRA_INFO so they show up in the README and source selection This way users can just search for their area and have an easy way to search for their region I found some IDs to use: List of regions I found
Found IDs usingimport requests
import time
url = "https://gateway.sisms.pl/akun/api/owners/{id}/info"
for i in range(300):
r = requests.get(url.format(id=i))
if r.status_code != 200:
# print(i, "not found")
continue
data = r.json()
if "TIMETABLE" not in data["tabs"]:
print(i, data.get("NAME", "no name"), "has no timetable")
continue
print(i, data["name"])
time.sleep(.1) |
Oh man that's awesome; thanks a lot for that. I'll adjust the PR later today. |
Provide a helper utility to find `formattedId`
@5ila5 Update PR; I've added a helper script https://github.com/btaczala/hacs_waste_collection_schedule/blob/blisko/custom_components/waste_collection_schedule/waste_collection_schedule/service/Blisko_searcher.py that can/must be used to figure out |
I like your script, but we try to move away from these kinds of scripts as a lot of seem to not be able to run them properly, so I think integrating this functionality directly in the source is a better idea as it integrates better in the GUI configuration. I still think hard-coding the region is the way to go: Hardcoded regions and allow directly passing region, city, street, house_number arguments: def __init__(
self,
regionId: str | int | None = None,
formattedId: str | None = None,
region: str | None = None,
city: str | None = None,
street: str | None = None,
house_number: str | None = None,
): and then some checks like if not regionId:
if not region:
raise SourceArgumentRequiredWithSuggestions(
argument="region",
message="Region or Region ID is required",
suggestions=[str(region["region_name"]) for region in REGIONS],
)
for region_item in REGIONS:
if region.replace(" ", "") == region_item[
"region_name"
].lower().replace(" ", ""):
regionId = region["id"]
break and calling your funtions from the script (maybe a bit modified to better fit this use case). you could put them into the service folder. verifing the arguments and setting the attribute I know it isn't quite as clean but we do not have a good way to show custom wizards to configure sources throug the GUI (and I don't have that much time to work on one atm.) |
if args.region and args.city: | ||
streets_json = all_street_per_city(args.region, args.city) | ||
if streets_json: | ||
print(streets_json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing with print(json.dumps(streets_json, indent=2))
produces a way better readable result
(same in other printing functions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ddb45dd
I think one piece is missing. In such case, we should directly request town addresses: In result, we can use the formatted town address, like this: Other than that, great job! I tested it, and it works fine. |
Done in bb49ada 😄 |
What about my comment above? Are you interested in implementing it that way? I'd still prefer this approach, but the current state is usable and making it more user-friendly could be done when there is a way to have real custom configuration forms in the GUI setup. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@5ila5 yeah sure I can restructure that in a way that fits project needs. Will try to change it during the weekend. |
No description provided.