X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=myq_renderer.py;h=91e946b9a621291046e56f4e681f2eb80ce9bd74;hb=f2f05b2edb16cc6a8c4e183e5ae3451d291cc428;hp=333c356a6e96891a26ddf8c36f743636c785b155;hpb=3b4fef0ca20b98c670acbaa2899bdb1b35eb12d7;p=kiosk.git diff --git a/myq_renderer.py b/myq_renderer.py index 333c356..91e946b 100644 --- a/myq_renderer.py +++ b/myq_renderer.py @@ -1,5 +1,3 @@ -#!/usr/local/bin/python3.7 - import pymyq from aiohttp import ClientSession import asyncio @@ -14,13 +12,15 @@ class garage_door_renderer(renderer.debuggable_abstaining_renderer): def __init__(self, name_to_timeout_dict): super(garage_door_renderer, self).__init__(name_to_timeout_dict, False) self.doors = None + self.last_update = None def debug_prefix(self): return "myq" def periodic_render(self, key): if key == "Poll MyQ": - asyncio.get_event_loop().run_until_complete(self.poll_myq()) + self.last_update = datetime.datetime.now() + return asyncio.run(self.poll_myq()) elif key == "Update Page": return self.update_page() else: @@ -32,17 +32,17 @@ class garage_door_renderer(renderer.debuggable_abstaining_renderer): secrets.myq_password, websession) self.doors = myq.devices + return len(self.doors) > 0 def update_page(self): f = file_writer.file_writer(constants.myq_pagename) - now = datetime.datetime.now() f.write("""