Skip to content

Use local status of the ampel. #1

@lemoer

Description

@lemoer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions