diff --git a/cbpi/__init__.py b/cbpi/__init__.py index e16d0c4..eeae0a9 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.1.7.a4" +__version__ = "4.1.7.a5" __codename__ = "Groundhog Day" diff --git a/cbpi/controller/log_file_controller.py b/cbpi/controller/log_file_controller.py index 59da525..c752216 100644 --- a/cbpi/controller/log_file_controller.py +++ b/cbpi/controller/log_file_controller.py @@ -7,7 +7,7 @@ from time import strftime, localtime import pandas as pd import zipfile import base64 -import urllib3 +from urllib3 import Timeout, PoolManager from pathlib import Path from cbpi.api import * from cbpi.api.config import ConfigType @@ -46,16 +46,20 @@ class LogController: formatted_time = strftime("%Y-%m-%d %H:%M:%S", localtime()) self.datalogger[name].info("%s,%s" % (formatted_time, str(value))) + if self.influxdb == "Yes": + ## Write to influxdb in an asyncio task + self._task = asyncio.create_task(self.log_influx(name,value)) + + async def log_influx(self, name:str, value:str): self.influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", "No") self.influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None) - #self.influxdbport = self.cbpi.config.get("INFLUXDBPORT", None) self.influxdbname = self.cbpi.config.get("INFLUXDBNAME", None) self.influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None) self.influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None) self.influxdbmeasurement = self.cbpi.config.get("INFLUXDBMEASUREMENT", "measurement") - id = name + timeout = Timeout(connect=5.0, read=None) try: sensor=self.cbpi.sensor.find_by_id(name) if sensor is not None: @@ -68,7 +72,7 @@ class LogController: self.influxdburl=self.influxdbaddr + "/api/v2/write?org=" + self.influxdbuser + "&bucket=" + self.influxdbname + "&precision=s" try: header = {'User-Agent': name, 'Authorization': "Token {}".format(self.influxdbpwd)} - http = urllib3.PoolManager() + http = PoolManager(timeout=timeout) req = http.request('POST',self.influxdburl, body=out.encode(), headers = header) except Exception as e: logging.error("InfluxDB cloud write Error: {}".format(e)) @@ -78,7 +82,7 @@ class LogController: self.influxdburl= self.influxdbaddr + '/write?db=' + self.influxdbname try: header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')} - http = urllib3.PoolManager() + http = PoolManager(timeout=timeout) req = http.request('POST',self.influxdburl, body=out.encode(), headers = header) except Exception as e: logging.error("InfluxDB write Error: {}".format(e)) diff --git a/cbpi4.egg-info/PKG-INFO b/cbpi4.egg-info/PKG-INFO index acea7b7..e37f3a2 100644 --- a/cbpi4.egg-info/PKG-INFO +++ b/cbpi4.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: cbpi4 -Version: 4.1.2 +Version: 4.1.7a4 Summary: CraftBeerPi4 Brewing Software Home-page: http://web.craftbeerpi.com Author: Manuel Fritsch / Alexander Vollkopf @@ -14,14 +14,14 @@ License-File: LICENSE # CraftBeerPi 4 -[![Build](https://github.com/avollkopf/craftbeerpi4/actions/workflows/build.yml/badge.svg)](https://github.com/avollkopf/craftbeerpi4/actions/workflows/build.yml) -[![GitHub license](https://img.shields.io/github/license/avollkopf/craftbeerpi4)](https://github.com/avollkopf/craftbeerpi4/blob/master/LICENSE) -![GitHub issues](https://img.shields.io/github/issues-raw/avollkopf/craftbeerpi4) +[![Build](https://github.com/PiBrewing/craftbeerpi4/actions/workflows/build.yml/badge.svg)](https://github.com/PiBrewing/craftbeerpi4/actions/workflows/build.yml) +[![GitHub license](https://img.shields.io/github/license/PiBrewing/craftbeerpi4)](https://github.com/PiBrewing/craftbeerpi4/blob/master/LICENSE) +![GitHub issues](https://img.shields.io/github/issues-raw/PiBrewing/craftbeerpi4) ![PyPI](https://img.shields.io/pypi/v/cbpi4) ![Happy Brewing](https://img.shields.io/badge/CraftBeerPi%204-Happy%20Brewing-%23FBB117)

- CraftBeerPi Logo + CraftBeerPi Logo

CraftBeerPi 4 is an open source software solution to control the brewing and @@ -50,6 +50,6 @@ For a more detailed description of a development setup without the _development ### Contributors Thanks to all the people who have contributed -[![contributors](https://contributors-img.web.app/image?repo=avollkopf/craftbeerpi4)](https://github.com/avollkopf/craftbeerpi4/graphs/contributors) +[![contributors](https://contributors-img.web.app/image?repo=PiBrewing/craftbeerpi4)](https://github.com/PiBrewing/craftbeerpi4/graphs/contributors) diff --git a/cbpi4.egg-info/SOURCES.txt b/cbpi4.egg-info/SOURCES.txt index 001e06e..93caa9c 100644 --- a/cbpi4.egg-info/SOURCES.txt +++ b/cbpi4.egg-info/SOURCES.txt @@ -158,6 +158,10 @@ cbpi/extension/onewire/__pycache__/__init__.cpython-310.pyc cbpi/extension/onewire/__pycache__/__init__.cpython-311.pyc cbpi/extension/onewire/__pycache__/__init__.cpython-37.pyc cbpi/extension/onewire/__pycache__/__init__.cpython-39.pyc +cbpi/extension/timer/__init__.py +cbpi/extension/timer/config.yaml +cbpi/extension/timer/__pycache__/__init__.cpython-311.pyc +cbpi/extension/timer/__pycache__/__init__.cpython-39.pyc cbpi/http_endpoints/__init__.py cbpi/http_endpoints/http_actor.py cbpi/http_endpoints/http_config.py diff --git a/cbpi4.egg-info/requires.txt b/cbpi4.egg-info/requires.txt index 347a698..337e19f 100644 --- a/cbpi4.egg-info/requires.txt +++ b/cbpi4.egg-info/requires.txt @@ -7,7 +7,7 @@ aiohttp-session==2.12.0 aiohttp-swagger==1.0.16 aiojobs==1.1.0 aiosqlite==0.17.0 -cryptography==36.0.1 +cryptography==40.0.0 requests==2.28.1 voluptuous==0.13.1 pyfiglet==0.8.post1