Open liakjim opened 3 days ago
From some research i discovered that it was the xml file.
I am using this one -> https://spotthestation.nasa.gov/sightings/xml_files.cfm?filename=Greece_None_Athens.xml
When i am running at my pc , it gives this error ->
C:\Users\liakj\Desktop>python spot_the_next_station.py Traceback (most recent call last): File "C:\Users\liakj\Desktop\spot_the_next_station.py", line 60, in <module> next_event = extract_spot_the_station_info() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\liakj\Desktop\spot_the_next_station.py", line 46, in extract_spot_the_station_info duration_minutes = int(duration_str.split()[0]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'less'
If i use another xml like this one -> https://spotthestation.nasa.gov/sightings/xml_files.cfm?filename=Greece_None_Thessaloniki.xml everything is working fine. Strange.
Ok the issue is at line 46. In the Athens xml the duration is less than 1 minute
that gives the error.
I tried the chatgpt and it gave me the following solution ->
# Calculate end time by adding duration to start time
duration_str = info_dict.get("Duration", "").lower().strip()
try:
# Handle special cases like "less than 1 minute"
if "less than" in duration_str:
duration_minutes = 1 # Assume minimum duration of 1 minute
else:
# Extract the numeric value from duration_str
duration_minutes = int(duration_str.split()[0])
except (ValueError, IndexError):
# Default to 0 minutes if duration_str is invalid
print(f"Warning: Invalid duration format '{duration_str}'")
duration_minutes = 0
event_end = event_start + timedelta(minutes=duration_minutes)
This code works fine.
Hello, this sensor was working great for some months now and recently i discovered that there was an error and the sensor stayed at unknown state.
When i manually do an update from actions, i get this error in logs
and this warning