Skip to content
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

Multiple stations, walking time filter, metro hero api support, off hours configuration #8

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

scottiegarcia
Copy link

My fork based off of the terrific contributions of @erikrrodriguez . Changes include.

Added

  • Multiple station support
  • Walk time filtering
  • Optional off hours configuration
  • MetroHero API Support

Changed

  • Updated lib.zip files to CircuitPython 7

@scottiegarcia scottiegarcia changed the title Multiple stations, walking time filter, metro hero api support, off hours configuration WIP - Multiple stations, walking time filter, metro hero api support, off hours configuration Jan 14, 2022
@scottiegarcia scottiegarcia changed the title WIP - Multiple stations, walking time filter, metro hero api support, off hours configuration Multiple stations, walking time filter, metro hero api support, off hours configuration Jan 24, 2022
@smchrist2
Copy link

Hello, thanks for these great additions. I might be running into a bug that I wanted to flag to you. I am pulling data from two stations with my walk times both set at zero, and everything runs smoothly, until the top-most train moves on past "ARR"--at that point, the trains go blank (only the LN / DEST / MIN headers remain), and then a few minutes later the screen will repopulate with trains. What could be causing this refresh gap?

Perhaps relatedly, when I set my walk times to anything above zero (e.g., 2 and 5), no trains populate, and the screen only shows the red LN / DEST / MIN headers.

I am using Adafruit 7.3.3. Thanks.

Metro Hero Fix, Added off hours ability
For reference: the previous code attempted to do math on the arrival["Min"] values, but they can be strings (like "ARR" or "BRD"). So the "if arrival.isdigit()" check is required.
@erikrrodriguez
Copy link

Hey smchrist2, I just pushed a change to fix your first issue. The previous code was trying to do math on strings like "ARR" 🙃 Let me know if the change works for you

Your second issue, I'm not sure about. Can you tell me what station_codes and train_groups you're using in your config file? I can try and diagnose. I have noticed trains being absent in WMATAs API response until they're very close, but it seems to be station dependent

Merged the additions by Scott Garcia, thanks Scott!

Also fixed a bug found by smchrsit02.

For reference: the previous code attempted to do math on the arrival["Min"] values, but they can be strings (like "ARR" or "BRD"). So the "if arrival.isdigit()" check is required.
Was encountering the following timeout error when getting the current time:

Traceeback (most recent call last):
  File "code.py", line 72, in <module>
  File "code.py", line 42, in is_off_hours
  File "adafruit_esp32spi/adafruit_esp32spi_wifimanager.py", line 225, in get
  File "adafruit_requests.py", line 698, in get
  File "adafruit_requests.py", line 556, in request
  File "adafruit_requests.py", line 414, in _get_socket
  File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 43, in getaddrinfo
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 608, in get_host_by_name
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 325, in _send_command_get_response
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 292, in _wait_response_cmd
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 271, in _wait_spi_char
RuntimeError: Timed out waiting for SPI char
@smchrist2
Copy link

smchrist2 commented Mar 19, 2023

Thanks, @erikrrodriguez, for your help. I tried the change that you pushed but now it appears that no trains are populating (just the LN / DEST / MIN header). Any sense of the issue? I double checked that I had all my WiFi an other inputs correct. Thanks again.

@erikrrodriguez
Copy link

Hmm, not off the top of my ahead. If your walking times are set too high, then any trains returned from the WMATA API call will be filtered out and the none will show on the board. The MetroHero API returns trains further into the future, but they are shutting down their API in July, so it's not a good long term solution.

Do you know if the original code works (from https://github.com/metro-sign/dc-metro) instead of my forked code?

If you tell me what you have set for your metro_station_codes, train_groups, and walking_times in your config file I could help debug further. Feel free to email to me at [email protected] if you don't want to post them publicly.

@defrank1
Copy link

Hi @erikrrodriguez - I'm having some trouble as well. I also have the disappearing right after "ARR" issue -- I'm new to this platform and can't tell. I started this project in May, does that mean I'm likely using the version from after the above back-and-forth on this same issue?

Also, instead of turning off the display at night, it goes to a pink and blue ADAFRUIT display with a flamingo and other things like that. Is this a known issue?

Thank you!

@erikrrodriguez
Copy link

Hi @defrank1 sorry for the delayed response. I haven't pushed any updates since March, so you should be using the latest version. If you think you might have made changes to files other than config.py, try replacing them.

For your first issue, if you tell me what values you have set for your metro_station_codes, train_groups_1, train_groups_2, swap_train_groups, and walking_times in your config.py file I can try to diagnose.

Your second issue means the code is crashing. Can you tell me what you have set for your display_on_time and display_off_time

@defrank1
Copy link

Hi @defrank1 sorry for the delayed response. I haven't pushed any updates since March, so you should be using the latest version. If you think you might have made changes to files other than config.py, try replacing them.

For your first issue, if you tell me what values you have set for your metro_station_codes, train_groups_1, train_groups_2, swap_train_groups, and walking_times in your config.py file I can try to diagnose.

Your second issue means the code is crashing. Can you tell me what you have set for your display_on_time and display_off_time

Thanks Erik. I really appreciate the reply.

Here's what I have:

Metro Station Code

'metro_station_codes': ['A03','A03'],

# Metro Train Group
'train_groups': ['1','1'],

#Walking Distance Times, ignore trains arriving in less than this time
# [2, 12]
'walking_times': [0, 0],

And here's what I have for the Off Hours Config

#############################
# Off Hours Configuration #
#############################

# adafruit io settings, necessary for determining current time to sleep
# An account is free to set up, instructions below
# https://learn.adafruit.com/adafruit-magtag/getting-the-date-time
'aio_username': 'defrank',
'aio_key': 'aio_wvXQ55WfBgl4RUVBDwyi7r6XpyPi',

# Time of day to turn board on and off - must be 24 hour "HH:MM"
'display_on_time': "06:00",
'display_off_time': "21:30",

Thank you!

@erikrrodriguez
Copy link

First, you should edit your post to remove your aio_key, just in case someone wants to steal it :)

Second, if that's what your config file looks like then you are indeed using an older version of the code. This chat thread we're in right now is not actually based on my latest repository.

Go to https://github.com/erikrrodriguez/dc-metro to get the latest code. You'll also need to update your libraries to CircuitPython 8, because I think you might have 7 installed.

Third, you don't need to dupe your stations like you are right now because you're showing the same information. It should look like

'metro_station_codes': ['A03'],

# Metro Train Group
'train_groups': ['1'],

#Walking Distance Times, ignore trains arriving in less than this time
# [2, 12]
'walking_times': [0],

And when you update to the latest version of the code it should look like

# Metro Station Codes
'metro_station_codes': ['A03'],

# Metro Train Groups
'swap_train_groups': False,
'train_groups_1': ['1'],
'train_groups_2': ['1'],


# Walking Distance Times, ignore trains arriving in less than this time
# [2, 12]
'walking_times': [0],

Let me know if you still have issues after all that.

@defrank1
Copy link

defrank1 commented Jul 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants