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

Error reconnecting within script: 403 Client Error: Forbidden for url: http://xxx.xxx.x.xx/app/request?seq=116114337 #19

Open
bunbunet opened this issue Jan 21, 2024 · 1 comment

Comments

@bunbunet
Copy link

Hello, I wrote a script that control a lamp color based on the decibel levels measured by a microphone. I'm using it to help customers of a winery out of my windows to control the loudness of their voices. The script runs automatically every night in a raspberry pi. To deal disconnections and reconnections I added to the script a function that goes like this

connection=False
def connect_lamp():
    try:
        global l530sec
        l530sec = PyL530.L530("xxx.xxx.xxx", "me@mymail", "mypassowrd")

        l530sec.handshake() #Creates the cookies required for further methods
        l530sec.login() #Sends credentials to the plug and creates AES Key and IV for further methods
        global connection
        connection=True
    
    except Exception as e:
        #print(e)
        connection=False
        return
    
while connection==False:
    connect_lamp()

This function work perfectly if the lamp is offline when the script is started, but if the connection is lost afterwards it give the 403 Client Error: Forbidden for etc..
I can share the entire script here or on my github, any suggestion will be greatly appreciated, having this script running properly is of vital importance!!

Thank you very much

Federico

@almottier
Copy link
Owner

Hello,

handshake() and login() are deprecated in this fork. You may not need them.
Why not create a new l530sec whenever you want to change the color ?

l530sec = PyL530.L530("xxx.xxx.xxx", "me@mymail", "mypassowrd")
l530sec.setColor(...)

I do this on a low-end raspberry pi zero, it is very fast.

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

No branches or pull requests

2 participants