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