Skip to content

Commit

Permalink
more info on station selection
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasJoKuJonas committed Mar 29, 2024
1 parent c18da07 commit dd1f90a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 22 additions & 20 deletions custom_components/trias/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,29 @@ async def async_step_search_station(

stop_points = {}

if "Location" in data["Location"]:
stop_point_names = [
"search",
data["Location"]["Location"]["StopPoint"]["StopPointName"]["Text"],
]
stop_points = {
data["Location"]["Location"]["StopPoint"]["StopPointName"][
"Text"
]: data["Location"]["Location"]["StopPoint"]["StopPointRef"]
}

else:
stop_point_names = ["search"]
self._stop_points = {}
for stop in data["Location"]:
stop_point_names.append(
stop["Location"]["StopPoint"]["StopPointName"]["Text"]
if "Location" in data:
locations = data["Location"]

if isinstance(locations, list): # Handling multiple locations
for stop in locations:
_LOGGER.warning(stop)
stop_point_name = (
stop["Location"]["LocationName"]["Text"]
+ ", "
+ stop["Location"]["StopPoint"]["StopPointName"]["Text"]
)
stop_point_id = stop["Location"]["StopPoint"]["StopPointRef"]
stop_points[stop_point_name] = stop_point_id
else: # Handling single location
stop_point_name = (
locations["Location"]["LocationName"]["Text"]
+ ", "
+ locations["Location"]["StopPoint"]["StopPointName"]["Text"]
)
stop_points[
stop["Location"]["StopPoint"]["StopPointName"]["Text"]
] = stop["Location"]["StopPoint"]["StopPointRef"]
stop_point_id = locations["Location"]["StopPoint"]["StopPointRef"]
stop_points[stop_point_name] = stop_point_id

stop_point_names = ["search"] + list(stop_points.keys())

self._search_data["stop_points"] = stop_points

Expand Down
2 changes: 1 addition & 1 deletion custom_components/trias/trias_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def location_information_request(
probability = float(
result["LocationInformationResponse"]["Location"]["Probability"]
)
if probability < 0.75:
if probability < 0.75 and probability > 0.0:
found = result["LocationInformationResponse"]["Location"][
"Location"
]["StopPoint"]["StopPointName"]["Text"]
Expand Down

0 comments on commit dd1f90a

Please sign in to comment.