Git Product home page Git Product logo

nhl_goal_light's People

Contributors

anomalyzero avatar arim215 avatar francisbonneau avatar quantifiedcode-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nhl_goal_light's Issues

Small change to accommodate Covid-19 playoffs

The check_season() function in nhl.py could be updated to accommodate the 2020 playoffs.

def check_season():

# Get current time
now = datetime.datetime.now()
if now.month in (7, 8) **and now.year <> 2020**:
    return False
else:
    return True

allow choosing team

Need to find a reliable Team name to Team ID source... Team_id.txt has current ID, but need to be future proof with expantion.

using PI lib creates loop

Using the lib/gpio when not on a RPI, the input fonction creates an infinite loop. (only if there is game on day)

Scoring total and other ideas

First of all thanks for this, I've been looking for a trigger for my Ambilight goal lights for awhile now. Favorite team affiliations aside, i had a few thoughts on what you have here.

In looking at your code for the score it looks as though you set the score back to zero if the new_score is less than old_score. I'm curious how this functions on disallowed goals? I question because I am a Bluejackets fan and the third goal of home games is the chili goal (everyone gets free chili with ticket stub the next day). Nothing crazy but the goal horn/song is different for it. So theoretically i would listen for score and tally it up and play one goal song for each unless it is the 3rd goal in which it would get a special case. Could you perhaps have some form of time based reset by way of after first score update trigger a score reset 8 hours later? (long enough to not obstruct current game, short enough to be reset before a back to back game.)

Another piece i am thinking about adding to what you have is listening for the powerplay. I see it is a var in the api. Depending on when it gets set to true, it could be fun to have a separate audio clip to play. (in arena announcer "Jackets....Ooooonnnnnnn theeeeee POWERPlaaaaaaaaay")

Lastly a piece to possibly implement would be a period beginning soon warning. Intermissions are 18 minutes. You could listen for the end of the period and call an audio que to happen in 15 minutes to give you a 3 minute warning.

I'm not a heavy backend developer. I am an interaction designer by day, but i love to tinker and have hacked my way this far with my goal light setup. This is an older video and it now runs on a separate pi but you can see my "faked trigger" light effect. (...if you were curious...) https://youtu.be/r_088QRyY-s?t=84

Thanks again and great work!

Mike

Trouble with end_game

As i mentioned previously I am still quite the newb when it comes to this, but for the life of me i cannot get it working. I run the flask_api and that works fine. I cleared the team id in the settings so that way i can test it with any game going on. I input the team i want, but it keeps getting hung up here...

Traceback (most recent call last):
File "nhl_goal_light.py", line 118, in
game_end = response.json()['end_game']
File "/usr/lib/python3/dist-packages/requests/models.py", line 793, in json
return json.loads(self.text, **kwargs)
File "/usr/lib/python3.4/json/init.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

I should mention i also edited the light.py to incorporate my light function, but this to me seems erroring when its checking end game. If there was no game today it closes out fine. But at any rate my goal trigger function looks like this...

""" Function to activate GPIO for goal light and plar random audio clip. """

# add to def activate_goal_light
score = requests.get("http://statsapi.web.nhl.com/api/v1/schedule?teamId=29")
team_id = 29
score = score.text[score.text.find('id\" : {}'.format(team_id)) - 37:score.text.find('id\" : {}'.format(team_id)) - 36]
score = int(score)
print(score)
trigger_goal_lights = 'hyperion-remote -a _ipAddress_ -e Goal -d 40000'
os.system(trigger_goal_lights)  # Play lights
if score == 3:
    # MAKE SURE 3rd Goal audio is names 3rdgoal.mp3 in /audio folder
    command_play_song = 'sudo mpg123 -q ./audio/goal_horn_3.mp3'
else:
    command_play_song = 'sudo mpg123 -q ./audio/goal_horn_1.mp3'
os.system(command_play_song)  # Play sound

python ^m error on exc...

The issue is not EOF but EOL. The shell sees a ^M as well as the end of line and thus tries to find /usr/bin/python^M .

The usual way of getting into this state is to edit the python file with a MSDOS/Windows editor and then run on Unix. The simplest fix is to run dos2unix on the file or edit the file in an editor that explicitly allows saving with Unix end of lines.

Team ID lookup

Team ID gets fetched every time we want to know any info...

could be optimized to lookup once and always send team ID to flask API to avoid unnecessary lookups and save compute time...

requests error, connection aborted

Traceback (most recent call last):
File "auto_nhl_goal.py", line 108, in
(game_id,team_abr)=check_if_game(team)
File "auto_nhl_goal.py", line 49, in check_if_game
MTL=requests.get(url)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 67, in get
return request('get', url, params=params, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 426, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))

Error running nhl_goal_light.py on raspberry pi

flask_api.py works good but nhl_goal_light.py give error when entering team

$ sudo python nhl_goal_light.py
Enter team you want to setup (without city) (Default: Canadiens)
Canadiens
Traceback (most recent call last):
File "nhl_goal_light.py", line 42, in
team = input("Enter team you want to setup (without city) (Default: Canadiens) \n")
File "", line 1, in
NameError: name 'Canadiens' is not defined

Datetime formatin

import datetime
d = datetime.datetime(2010, 7, 4, 12, 15, 58)
'{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'

Forking Micropython Version

Just letting you know I like the project and am working on a fork for ESP8266 running Micropython. The idea is to make it more foolproof with embedded hardware, as well as cheaper.

Main work in porting has involved working around datetime, as it is just too big to import on ESP8266 with its limited RAM. Mostly datetime seems to be used to calculate the 'sleeps', so I just replaced them with a fixed wait time of an hour for now.

ESP8266 has enough GPIO to allow use of DIP switches to set the team and a potentiometer to set the delay. I figure "average Joe" might be OK with visiting the hosted AP to configure their wireless info, but probably isn't going to find whatever DHCP gives it to go back and set the team and delay time.

If enough people want it, I may do a board with a 12 to 5V buck converter and a relay, so you can use whatever 12V beacon light you want.

Version 3.1

Your new code in the nhl_goal_light.py file has issues. At least for me. I updated to your latest 3.1 version and executed in terminal and it gets hung up on "do you want to update current delay". when I answer yes or no and hit enter it once again asks the same question. I can never get pasted it. I also didn't get the trigger to set off the light and audio during a goal. I am running the goal light on a 2012 Raspberry Pi 1 B w/ Stretch. Previous versions worked but this version doesn't. Please help.
Goal light

NHL Goal Light Install Questions

I have a question on what the function of the momentary switch is? I have the normally open switch connected to pins 9 and 11. When I press it nothing happens either when the NHL Goal Light is in ready mode or when it is running the light and audio clip. I have the NHL Goal Light installed on a Raspberry Pi 1 Model B board with Raspbian Stretch OS. Also does the switch connection need a resister in line with it?
20210205_080839

Goal counter error

Goal detection methode not working. Currently using text parssing of goalsummary and counting goal text repetition to compare woth previous amount of repetions.

Getting:

File "auto_nhl_goal.py", line 33, in fetch_score
score=score.cout('t1...MTL')
AttributeError: 'unicode' object has no attribute 'cout'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.