2018-10-18 21:56:13 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
"""
|
|
|
|
Doorlockd -- Binary Kitchen's smart door opener
|
|
|
|
|
|
|
|
Copyright (c) Binary Kitchen e.V., 2018
|
|
|
|
|
|
|
|
Author:
|
|
|
|
Thomas Schmid <tom@binary-kitchen.de>
|
|
|
|
|
|
|
|
This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
the LICENSE file in the top-level directory.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pydoorlock.EventClient import EventClient
|
|
|
|
from pydoorlock.Door import DoorState
|
2020-10-08 21:27:18 +02:00
|
|
|
|
2018-10-18 21:56:13 +02:00
|
|
|
import json
|
2020-10-08 21:27:18 +02:00
|
|
|
import threading
|
2018-10-18 21:56:13 +02:00
|
|
|
|
|
|
|
state = DoorState(0)
|
|
|
|
|
2020-10-08 21:27:18 +02:00
|
|
|
def push_handler():
|
|
|
|
ec = EventClient("http://localhost:5000/push")
|
2018-10-18 21:56:13 +02:00
|
|
|
for event in ec.events():
|
|
|
|
data = json.loads(event['data'])
|
|
|
|
state = DoorState(data['status'])
|
|
|
|
print(state)
|
2020-10-08 21:27:18 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
status_thread = threading.Thread(target=push_handler)
|
|
|
|
status_thread.start()
|
|
|
|
status_thread.join()
|