mikemountain / nfl-led-scoreboard

NFL LED scoreboard! This project can display live scores of your favourite football teams!
GNU General Public License v3.0
101 stars 29 forks source link

Getting to rotate #60

Open Irishking03 opened 11 months ago

Irishking03 commented 11 months ago

@mikemountain or anyone

Where is the setting to rotate the game. I currently have this in the config.json

{ "preferred": { "teams": ["PHI", "DAL", "WASH", "NYG"] }, "rotation": { "enabled": true, "only_preferred": false, "rates": { "live": 15.0, "final": 10.0, "pregame": 10.0 }, "while_preferred_team_live": { "enabled": false, "during_halftime": false } }, "scrolling_speed": 2, "use_helmet_logos": false, "debug": "true" }

BUT I CANT GET THE GAMES TO ROTATE LIKE THEY NORMALLY DO.

alexanderthebadatcoding commented 11 months ago

try changing "while_preferred_team_live": { "enabled": true, "during_halftime": true

Irishking03 commented 11 months ago

@alexanderthebadatcoding WOULD HELP IF I Wasn't and idiot. I fixed that and also the PHL for eagles is PHI (SMACKS HEAD).. However now the eagles upcoming game comes up but I also have commanders, giants and dallas as preferred. But not rotating.

Irishking03 commented 11 months ago

It Looks like whatever I put in Preferred team as the last team (example "team": ["PHI", "LAR", "DAL", "NYG"]) will populate only. Like in this example is NYG.. If i remove NYG just Dallas populates.. So wierd.

Irishking03 commented 11 months ago

I don't know what I did but it is rotating now.

{ "preferred": { "teams": ["PHI", "WAS"] }, "rotation": { "enabled": true, "only_preferred": false, "rates": { "live": 15.0, "final": 10.0, "pregame": 10.0 }, "while_preferred_team_live": { "enabled": true, "during_halftime": false } }, "scrolling_speed": 2, "use_helmet_logos": false, "debug": "true" }

alexanderthebadatcoding commented 11 months ago

I think there is a bug in the code, there's a post saying that the while preferred_team_live settings can cause an Issue. I think what is happening is that the code checks if a preferred team is playing, but then shows the first result returned from the API: http://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard, which for this week is Dallas vs Seattle.

thats what my guess is. I just made sure to have rotation "enabled": true, and "while_preferred_team_live": { "enabled": true, "during_halftime": true }.

That way It will just always rotate the games shown.

Irishking03 commented 10 months ago

Now issue is the board with randomly turn off after a period of time. I have to log back in the pi (SSH) and re-enter the code.

alexanderthebadatcoding commented 10 months ago

You could try to set a Supervisor task to run the script continuously, and if it crashes then restart it. sudo apt-get install -y supervisor sudo service supervisor start then in /etc/supervisor/conf.d/ add a start.conf file

[program:scoreboard]
command=sudo python3 led.py
directory=/home/pi/
autostart=true
autorestart=true
stderr_logfile=/home/pi/boot.err.log
supervisorctl reread
supervisorctl update
sudo supervisorctl start scoreboard

More information here: https://serversforhackers.com/c/monitoring-processes-with-supervisord

Also I created a script that switches between the NFL and NBA scoreboard etc. But you might need to edit the settings a little bit to get it working. What I did was created and led.py script and then set that to run on boot.

and then the led.py script has:

import subprocess
import os

# Define the paths to the two scripts you want to switch between
nfl = '/home/pi/nflscore/main.py'
nba = '/home/pi/nba-led-scoreboard/main.py'

def run_script(script_path, duration):
    try:
        # Run script
        process = subprocess.Popen(["python3", script_path])
        # print("Loading " + script_path)

        # Wait for the specified duration
        time.sleep(duration)
        # Terminate the subprocess
        process.terminate()

    except Exception as e:
        print(f"An unexpected error occurred: {e}")
        # Handle the unexpected error, for example, exit the script
        exit(1)

while True:
        # Run NBA
        print("Showing NBA Scoreboard")
        run_script(nba, 200)

         # Run NFL
         print("Showing NFL Scores")
         run_script(nfl, 100)

However for this to work I did have to edit the renderer files to change the paths for the logos. But maybe there is a way around that.