diff --git a/Dockerfile b/Dockerfile index 4d5791a..08503c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,8 @@ FROM python:3.10-slim LABEL MAINTAINER="Jan-Ole Hübner " -ADD requirenments.txt / -RUN pip3 install -r /requirenments.txt +ADD requirements.txt / +RUN pip3 install -r /requirements.txt # Environment ENV PYTHONIOENCODING=utf-8 ADD . / diff --git a/pulse.py b/pulse.py index 15ea7bc..42da4d4 100644 --- a/pulse.py +++ b/pulse.py @@ -31,7 +31,7 @@ logger.addHandler(ch) logger.setLevel(logging.INFO) -__version__ = "v0.1.2" +__version__ = "v0.1.3" logger.info(__version__) client = InfluxDBClient(url=URL, token=TOKEN, org=ORG) @@ -51,11 +51,19 @@ def _incoming(pkg): exit(1) async def run(): - async with aiohttp.ClientSession() as session: + conn = aiohttp.TCPConnector(limit_per_host=3) + async with aiohttp.ClientSession(trust_env=True, connector=conn) as session: + logger.info("connecting to tibber...") if session.closed: logger.error("session closed") exit(1) - tibber_connection = tibber.Tibber(TIBBERTOKEN, websession=session, user_agent="python") + try: + tibber_connection = tibber.Tibber(TIBBERTOKEN, user_agent="python") + except Exception as e: + logger.info("error connecting to tibber...") + + logger.info(e) + raise e await tibber_connection.update_info() home = tibber_connection.get_homes()[0] await home.rt_subscribe(_incoming) diff --git a/requirenments.txt b/requirements.txt similarity index 79% rename from requirenments.txt rename to requirements.txt index 91f7ee7..25605e1 100644 --- a/requirenments.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ influxdb-client[ciso] requests pyTibber tzdata -pytz \ No newline at end of file +pytz +certifi \ No newline at end of file