doorlock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 03f281401a2b90de080d1bd399ff017568c7e100
parent ef2493f1dfb90ee67fabd413eab8ca31dfc0b444
Author: rob <rob@tarina.org>
Date:   Tue, 14 Feb 2023 11:12:26 +0000

working

Diffstat:
Mdoorlock.py | 16+++++++++++-----
Minstall.sh | 6+++---
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/doorlock.py b/doorlock.py @@ -39,7 +39,10 @@ def save_passcodes(passcodes): def load_passcodes(): global folder - passcodes = pickle.load(open(folder+'/.doorlock.p', 'rb')) + try: + passcodes = pickle.load(open(folder+'/.doorlock.p', 'rb')) + except: + passcodes = '' return passcodes def check_if_open(): @@ -85,9 +88,12 @@ def keylogger(code): return def doordebug(): - global apikey, open_door + global apikey, open_door, keypass print('sending debug info to bygdis.fi api') - url = 'https://bygdis.fi/dorrkoderapi?apikey='+apikey+'&doorstate='+str(check_if_open()) + doorstate=check_if_open() + print(doorstate) + debug=str(keypass) + url = 'https://bygdis.fi/dorrkoderapi?apikey='+apikey+'&doorstate='+str(doorstate)+'&debug='+str(debug) try: resp = requests.get(url=url) print(resp) @@ -160,8 +166,8 @@ get_code_time = time.time() while 1: run_time = time.time() - start_time update = time.time() - get_code_time - time.sleep(0.2) - if update > 5: + time.sleep(0.1) + if update > 15: get_code_time = time.time() if is_webz_on(): passcodes = getcodes() diff --git a/install.sh b/install.sh @@ -13,7 +13,7 @@ After=multi-user.target [Service] Type=simple ExecStart=$installfolder/remoteconnect.sh -User=pi +User=root Restart=always RestartSec=3 StandardInput=tty-force @@ -30,7 +30,7 @@ After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/python3 $installfolder/doorlock.py -User=pi +User=root Restart=always RestartSec=3 StandardInput=tty-force @@ -40,6 +40,6 @@ TTYPath=/dev/tty1 WantedBy=multi-user.target EOF systemctl enable doorlock -systemctl enable remoteconnect +#systemctl enable remoteconnect systemctl daemon-reload