fixing bugs. As usual...

This commit is contained in:
chrissy 2026-04-02 09:33:07 +02:00
parent 2c5550cf05
commit e433ca81df
1 changed files with 61 additions and 47 deletions

View File

@ -15,7 +15,7 @@ statusData = None # initialize variables...
tripData = None
# Your Travelynx-Api-token goes here
tlApiToken = "YOUR API TOKEN"
tlApiToken = "[YOUR TRAVELYNX API TOKEN GOES HERE…]"
# Known SSIDs for some regional train Wifis...
ssid_regio = [
@ -37,6 +37,7 @@ ssid_regio = [
"Wifi@start",
"alex WiFi",
"trilex WiFi",
"DBLounge",
]
@ -114,6 +115,8 @@ def get_speed_cd():
# Figure out, whats the next station and filter the output for this.
def get_next_db():
try:
if tripData["trip"]["stopInfo"] == None:
return "No TripInfo"
else:
@ -137,20 +140,32 @@ def get_next_db():
+ ") @ "
+ nextStationTrack
)
except:
tripinfo = "Unavail"
return tripinfo
def get_next_tl():
try:
if len(tripDataTl["intermediateStops"])==0:
tripinfo = tripDataTl["toStation"]["name"]
else:
for i in tripDataTl["intermediateStops"]:
if i["realArrival"] >= time.time():
if i["realArrival"] == None:
next
nextStopArrival=i["scheduledArrival"]
else:
nextStopArrival=i["realArrival"]
if nextStopArrival >= time.time():
nextStationName = i["name"]
uScheduledTime = i["scheduledArrival"]
uScheduledTime = ["scheduledArrival"]
uActualTime = i["realArrival"]
if uActualTime == None:
arrivalDelay="-"
else:
arrivalDelay = "{:+.0f}".format(((uActualTime - uScheduledTime) / 60))
arrivalTime = datetime.fromtimestamp(uActualTime, tz=timezone).strftime(
arrivalTime = datetime.fromtimestamp(nextStopArrival, tz=timezone).strftime(
"%H:%M"
)
tripinfo = (
@ -158,11 +173,9 @@ def get_next_tl():
)
break
else:
nextStationName = tripDataTl["toStation"]["name"]
tripinfo = nextStationName
next
except:
nextStationName = tripDataTl["toStation"]["name"]
tripinfo = nextStationName
tripinfo = tripDataTl["toStation"]["name"]
return tripinfo
@ -174,15 +187,16 @@ def get_trainInfo_db():
trainType = tripData["trip"]["trainType"]
trainNumber = tripData["trip"]["vzn"]
finalStationName = tripData["trip"]["stopInfo"]["finalStationName"]
return trainType + " " + trainNumber + " " + finalStationName
return trainType + " " + trainNumber
# Get the Trainnumber and final station of your current travelynx trip
def get_trainInfo_tl():
checkin_tl()
trainType = tripDataTl["train"]["type"]
trainNumber = tripDataTl["train"]["no"]
fromStationName = tripDataTl["fromStation"]["name"]
#fromStationName = tripDataTl["fromStation"]["name"]
fromStationDS100=tripDataTl['fromStation']['ds100']
toStationDS100=tripDataTl['toStation']['ds100']
toStationName = tripDataTl["toStation"]["name"]
toStationTrack = tripDataTl["toStation"]["platform"]
uScheduledTime = tripDataTl["toStation"]["scheduledTime"]
@ -194,9 +208,9 @@ def get_trainInfo_tl():
+ " "
+ trainNumber
+ " | "
+ fromStationName
+ fromStationDS100
+ ""
+ toStationName
+ toStationDS100
+ " "
+ arrivalTime
+ " ("