onlaj / Piano-LED-Visualizer

Piano LED Visualizer: Connect an LED strip to your Raspberry Pi and create an immersive visual experience for your piano playing
MIT License
513 stars 111 forks source link

Possible to Use Visualizer Without Internet Connection? #364

Closed samin50 closed 2 years ago

samin50 commented 2 years ago

Is it possible to use the RPI without an internet connection? I had a look at the python code, and it seems like it requires an active internet connection else it will crash as it will try to connect and fail if it cant. Even if I disable the webinterface, it still seems like the Visualizer expects an Internet connection, but I feel as though this is not intended behaviour.

samin50 commented 2 years ago

I managed to fix it by simply wrapping the 'get_ip_address()' function in the functions.py in the lib folder with a try and except, and the script proceeds with no issues. I would like to request that this be implemented in the next update (unless it already is and for some reason isnt working with my setup). The code is as follows:

def get_ip_address():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(("8.8.8.8", 80))
        local_ip = s.getsockname()[0]
        s.close()
        return local_ip
    except:
        None