This commit is contained in:
Tanner Collin 2022-06-27 17:31:45 -06:00
parent bbf04d6397
commit 5a7ca0f0e9

14
main.py
View File

@ -37,7 +37,7 @@ async def play_sound(filename):
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
async def bark(sound): async def barkbark(sound):
global COOLDOWN global COOLDOWN
if time.time() - COOLDOWN < 5.0: if time.time() - COOLDOWN < 5.0:
logging.info('Cooldown skipping.') logging.info('Cooldown skipping.')
@ -65,17 +65,17 @@ async def process_mqtt(message):
logging.info('Invalid json, returning') logging.info('Invalid json, returning')
return return
id_ = str(data.get('id', '')) serial = str(data.get('serial', ''))
if id_ not in CAMERAS: if serial not in CAMERAS:
logging.info('Invalid id, returning') logging.info('Invalid serial, returning')
return return
camera = CAMERAS[id_] camera = CAMERAS[serial]
logging.info('Ringing %s...', camera['name']) logging.info('Barking %s...', camera['name'])
await ring_bell(doorbell['sound']) await barkbark(camera['sound'])
async def fetch_mqtt(): async def fetch_mqtt():