error handling tests
This commit is contained in:
parent
fbd90b8206
commit
e6e0d7ac2e
1 changed files with 13 additions and 4 deletions
13
pulse.py
13
pulse.py
|
@ -10,12 +10,15 @@ from influxdb_client import InfluxDBClient
|
|||
from influxdb_client.client.write_api import SYNCHRONOUS
|
||||
from DataPoints import Pulse
|
||||
import logging
|
||||
import time
|
||||
|
||||
TOKEN=os.getenv('TOKEN', '')
|
||||
TIBBERTOKEN=os.getenv('TIBBERTOKEN', '')
|
||||
URL = os.getenv('URL',"" )
|
||||
BUCKET = os.getenv('BUCKET',"tibber" )
|
||||
ORG = os.getenv('ORG',"Default" )
|
||||
duration_seconds = 3600
|
||||
start_time = time.time()
|
||||
|
||||
#logging
|
||||
logger = logging.getLogger("TibberInflux")
|
||||
|
@ -59,8 +62,10 @@ async def run():
|
|||
home = tibber_connection.get_homes()[0]
|
||||
try:
|
||||
await home.rt_subscribe(_incoming)
|
||||
|
||||
except:
|
||||
except RuntimeError as e:
|
||||
logger.error(f"Caught a RuntimeError: {e}")
|
||||
exit(1)
|
||||
except Exception as e:
|
||||
exit(1)
|
||||
|
||||
while 1:
|
||||
|
@ -69,4 +74,8 @@ async def run():
|
|||
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
try:
|
||||
loop.run_until_complete(run())
|
||||
except:
|
||||
exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue