Remove watchdog
This commit is contained in:
parent
055b12ee05
commit
8fa91a9c55
13
main.py
13
main.py
|
@ -1,6 +1,5 @@
|
||||||
import os, logging
|
import os, logging
|
||||||
DEBUG = os.environ.get('DEBUG')
|
DEBUG = os.environ.get('DEBUG')
|
||||||
NO_WATCHDOG = os.environ.get('NO_WATCHDOG')
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
||||||
level=logging.DEBUG if DEBUG else logging.INFO)
|
level=logging.DEBUG if DEBUG else logging.INFO)
|
||||||
|
@ -26,8 +25,6 @@ import settings
|
||||||
RELAY_ON = False
|
RELAY_ON = False
|
||||||
RELAY_OFF = True
|
RELAY_OFF = True
|
||||||
|
|
||||||
allow_watchdog = False
|
|
||||||
|
|
||||||
cooldown_time = time.time()
|
cooldown_time = time.time()
|
||||||
|
|
||||||
def set_relay(pin, state):
|
def set_relay(pin, state):
|
||||||
|
@ -40,11 +37,7 @@ def pulse_relay(pin):
|
||||||
set_relay(pin, RELAY_OFF)
|
set_relay(pin, RELAY_OFF)
|
||||||
|
|
||||||
def ring_bell(camera):
|
def ring_bell(camera):
|
||||||
global allow_watchdog, cooldown_time
|
global cooldown_time
|
||||||
|
|
||||||
if not allow_watchdog and not DEBUG and not NO_WATCHDOG:
|
|
||||||
logging.info('Enabling watchdog...')
|
|
||||||
allow_watchdog = True
|
|
||||||
|
|
||||||
if time.time() - cooldown_time < 2:
|
if time.time() - cooldown_time < 2:
|
||||||
logging.info('Cooldown skipping.')
|
logging.info('Cooldown skipping.')
|
||||||
|
@ -58,10 +51,6 @@ def ring_bell(camera):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.error('Doorbell %s not found!', camera)
|
logging.error('Doorbell %s not found!', camera)
|
||||||
|
|
||||||
def feed_watchdog():
|
|
||||||
with open('/dev/watchdog', 'w') as wdt:
|
|
||||||
wdt.write('1')
|
|
||||||
|
|
||||||
|
|
||||||
async def process_message(msg):
|
async def process_message(msg):
|
||||||
if msg.get('type', '') != 'ring':
|
if msg.get('type', '') != 'ring':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user