mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-22 06:58:17 +01:00
InfluxDB: support non-ASCII symbols in sensor names
This commit is contained in:
parent
7aecdac6a7
commit
03d1521c5e
1 changed files with 1 additions and 4 deletions
|
@ -57,12 +57,9 @@ class LogController:
|
||||||
|
|
||||||
id = name
|
id = name
|
||||||
try:
|
try:
|
||||||
chars = {'ö':'oe','ä':'ae','ü':'ue','Ö':'Oe','Ä':'Ae','Ü':'Ue'}
|
|
||||||
sensor=self.cbpi.sensor.find_by_id(name)
|
sensor=self.cbpi.sensor.find_by_id(name)
|
||||||
if sensor is not None:
|
if sensor is not None:
|
||||||
itemname=sensor.name.replace(" ", "_")
|
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)
|
out=str(self.influxdbmeasurement)+",source=" + itemname + ",itemID=" + str(id) + " value="+str(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("InfluxDB ID Error: {}".format(e))
|
logging.error("InfluxDB ID Error: {}".format(e))
|
||||||
|
@ -82,7 +79,7 @@ class LogController:
|
||||||
try:
|
try:
|
||||||
header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')}
|
header = {'User-Agent': name, 'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % self.base64string.decode('utf-8')}
|
||||||
http = urllib3.PoolManager()
|
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:
|
except Exception as e:
|
||||||
logging.error("InfluxDB write Error: {}".format(e))
|
logging.error("InfluxDB write Error: {}".format(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue