Variablen machen komische Sachen
Verfasst: Sonntag 21. Juli 2019, 15:42
Ich versuche den Leistungsbedarf und die Temperatur zu erfassen
Das mit der Temperatur und der Leistung funktioniert, aber beim Zusammenklöppeln stimmt irgendwas nicht:
Ich hätte erwartet, dass N:26.437:42.57 ausgegeben wird und nicht ...:0 . Also wo zum Geier kommt die 0 her?
Ich versteh es nicht
Jemand eine Idee?
PS:
shelly.sh gibt nur die Leistung zurück
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re, os, rrdtool, time
# ds20b18
def read_sensor(path):
value = "U"
try:
f = open(path, "r")
line = f.readline()
if re.match(r"([0-9a-f]{2} ){9}: crc=[0-9a-f]{2} YES", line):
line = f.readline()
m = re.match(r"([0-9a-f]{2} ){9}t=([+-]?[0-9]+)", line)
if m:
value = str(float(m.group(2)) / 1000.0)
f.close()
except (IOError), e:
print time.strftime("%x %X"), "Error reading", path, ": ", e
return value
data = 'N'
data += ':'
data += read_sensor("/sys/bus/w1/devices/28-00044a52d2ff/w1_slave")
data += ':'
data += str(os.system("shelly.sh"))
# insert data into round-robin-database
# rrdtool.update("/home/pi/bosch.rrd",data)
print "bosch.rrd: ", data
Code: Alles auswählen
pi@Raspi-B:~ $ ./getbosch.py
42.57
bosch.rrd: N:26.437:0
pi@Raspi-B:~ $
Ich versteh es nicht

PS:
shelly.sh gibt nur die Leistung zurück
Code: Alles auswählen
pi@Raspi-B:~ $ shelly.sh
42.51
pi@Raspi-B:~ $