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

Use local status of the ampel. #1

Open
lemoer opened this issue May 22, 2016 · 0 comments
Open

Use local status of the ampel. #1

lemoer opened this issue May 22, 2016 · 0 comments

Comments

@lemoer
Copy link

lemoer commented May 22, 2016

Your doorIsOpen() function polls the door status on the webserver. Using the local status directly on the Ampel would be better. If the Pi would loose it's internet connection your status won't update anymore..

The communication is done with a unix socket. Here is our snippet to do this:

def notify(cmd, path='/var/run/ampel.sock'):
    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    s.connect(path)
    s.send(cmd.encode())
    res = s.recv(1024).decode()
    s.close()
    return res

Maybe you could simply import our foreman.py to do this job.

import foreman
print(foreman.notify("Status")) # prints OpenLab, CloseLab or BlinkLab
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

1 participant