This commit is contained in:
Jan-Ole Hübner 2024-05-07 19:08:52 +02:00
parent 1456c12608
commit 7546d1fdc7
3 changed files with 15 additions and 6 deletions

View file

@ -4,8 +4,8 @@ FROM python:3.10-slim
LABEL MAINTAINER="Jan-Ole Hübner <huebner@jan-ole.de>" LABEL MAINTAINER="Jan-Ole Hübner <huebner@jan-ole.de>"
ADD requirenments.txt / ADD requirements.txt /
RUN pip3 install -r /requirenments.txt RUN pip3 install -r /requirements.txt
# Environment # Environment
ENV PYTHONIOENCODING=utf-8 ENV PYTHONIOENCODING=utf-8
ADD . / ADD . /

View file

@ -31,7 +31,7 @@ logger.addHandler(ch)
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
__version__ = "v0.1.2" __version__ = "v0.1.3"
logger.info(__version__) logger.info(__version__)
client = InfluxDBClient(url=URL, token=TOKEN, org=ORG) client = InfluxDBClient(url=URL, token=TOKEN, org=ORG)
@ -51,11 +51,19 @@ def _incoming(pkg):
exit(1) exit(1)
async def run(): 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: if session.closed:
logger.error("session closed") logger.error("session closed")
exit(1) 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() await tibber_connection.update_info()
home = tibber_connection.get_homes()[0] home = tibber_connection.get_homes()[0]
await home.rt_subscribe(_incoming) await home.rt_subscribe(_incoming)

View file

@ -3,3 +3,4 @@ requests
pyTibber pyTibber
tzdata tzdata
pytz pytz
certifi