Merge pull request #6 from janolehuebner/dev

addd timer to force restart
This commit is contained in:
Jan-Ole Hübner 2023-09-05 22:55:43 +02:00 committed by GitHub
commit 2a1839fe04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,7 @@ logger.addHandler(ch)
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
__version__ = "v0.0.4" __version__ = "v0.0.5"
logger.info(__version__) logger.info(__version__)
client = InfluxDBClient(url=URL, token=TOKEN, org=ORG) client = InfluxDBClient(url=URL, token=TOKEN, org=ORG)
@ -60,22 +60,15 @@ async def run():
tibber_connection = tibber.Tibber(TIBBERTOKEN, websession=session, user_agent="python") tibber_connection = tibber.Tibber(TIBBERTOKEN, websession=session, user_agent="python")
await tibber_connection.update_info() await tibber_connection.update_info()
home = tibber_connection.get_homes()[0] home = tibber_connection.get_homes()[0]
try:
await home.rt_subscribe(_incoming) await home.rt_subscribe(_incoming)
except RuntimeError as e:
logger.error(f"Caught a RuntimeError: {e}")
exit(1)
except Exception as e:
exit(1)
while 1:
while time.time() - start_time < duration_seconds:
await asyncio.sleep(5) await asyncio.sleep(5)
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.run_until_complete(run())
exit(0)
try:
loop.run_until_complete(run())
except:
exit(1)