From 03d1521c5e5ac6085ee6494f9bf0052234f9ab8b Mon Sep 17 00:00:00 2001 From: Maxim Strinzha Date: Sat, 18 Mar 2023 16:39:35 +0300 Subject: [PATCH] InfluxDB: support non-ASCII symbols in sensor names --- cbpi/controller/log_file_controller.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cbpi/controller/log_file_controller.py b/cbpi/controller/log_file_controller.py index 4a50604..6c69c9d 100644 --- a/cbpi/controller/log_file_controller.py +++ b/cbpi/controller/log_file_controller.py @@ -57,12 +57,9 @@ class LogController: id = name try: - chars = {'ö':'oe','ä':'ae','ü':'ue','Ö':'Oe','Ä':'Ae','Ü':'Ue'} sensor=self.cbpi.sensor.find_by_id(name) if sensor is not None: itemname=sensor.name.replace(" ", "_") - for char in chars: - itemname = itemname.replace(char,chars[char]) out=str(self.influxdbmeasurement)+",source=" + itemname + ",itemID=" + str(id) + " value="+str(value) except Exception as e: logging.error("InfluxDB ID Error: {}".format(e)) @@ -82,7 +79,7 @@ class LogController: try: header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')} http = urllib3.PoolManager() - req = http.request('POST',self.influxdburl, body=out, headers = header) + req = http.request('POST',self.influxdburl, body=out.encode(), headers = header) except Exception as e: logging.error("InfluxDB write Error: {}".format(e))