diff --git a/heatingMeter.py b/heatingMeter.py index 2779065..301a6a4 100644 --- a/heatingMeter.py +++ b/heatingMeter.py @@ -32,36 +32,36 @@ while True: # return all values but slower parsed_msgs = sml_frame.parse_frame() for msg in parsed_msgs: - # prints a nice overview over the received values - print(msg.format_msg()) + print(msg.format_msg()) # prints a nice overview over the received values - # In the parsed message the obis values are typically found like this - obis_values = parsed_msgs[1].message_body.val_list + obis_values = parsed_msgs[1].message_body.val_list # In the parsed message the obis values are typically found like this - # The obis attribute of the SmlListEntry carries different obis representations as attributes - list_entry = obis_values[3] + list_entry = obis_values[3] # The obis attribute of the SmlListEntry carries different obis representations as attributes + # Get values from obis list heatPowerIn = int(obis_values[5].value*0.01) heatEnergyIn = int(obis_values[2].value*0.0001) heatEnergyInHT = int(obis_values[3].value*0.0001) heatEnergyInNT = int(obis_values[4].value*0.0001) + # Print values to console print("Heizung Wirkleistung aktuell: " + str(heatPowerIn) + "W") print("Heizung Energie bezug gesamt: " + str(heatEnergyIn) + "kWh") print("Heizung Energie bezug HT: " + str(heatEnergyInHT) + "kWh") print("Heizung Energie bezug NT: " + str(heatEnergyInNT) + "kWh") pointList.append( Point('power').field('heatPowerIn', heatPowerIn).time(pushTime, WritePrecision.S) ) - if energyCounter % 12 == 0: # Only add energy to db every 6th while loop (every minute) + # Only add energy to pointlist every 6th while loop (every minute) + if energyCounter % 6 == 0: pointList.append( Point('energy').field('heatEnergyIn', heatEnergyIn).time(pushTime, WritePrecision.S) ) pointList.append( Point('energy').field('heatEnergyInHT', heatEnergyInHT).time(pushTime, WritePrecision.S) ) pointList.append( Point('energy').field('heatEnergyInNT', heatEnergyInNT).time(pushTime, WritePrecision.S) ) print("Energy in DB") energyCounter = 0 - for point in pointList: + for point in pointList: # Print all points in pointlist print(point) - writeToDB(pointList) + writeToDB(pointList) # Write pointlist to db - time.sleep(5) \ No newline at end of file + time.sleep(10) # Sleep 10 seconds before reading the next value \ No newline at end of file diff --git a/officeMeter.py b/officeMeter.py index 3249161..f29e0d1 100644 --- a/officeMeter.py +++ b/officeMeter.py @@ -32,30 +32,32 @@ while True: # return all values but slower parsed_msgs = sml_frame.parse_frame() for msg in parsed_msgs: - # prints a nice overview over the received values - print(msg.format_msg()) + print(msg.format_msg()) # prints a nice overview over the received values - # In the parsed message the obis values are typically found like this - obis_values = parsed_msgs[1].message_body.val_list + obis_values = parsed_msgs[1].message_body.val_list # In the parsed message the obis values are typically found like this - # The obis attribute of the SmlListEntry carries different obis representations as attributes - list_entry = obis_values[3] + list_entry = obis_values[3] # The obis attribute of the SmlListEntry carries different obis representations as attributes + # Get values from obis list officePowerIn = int(obis_values[3].value*0.01) officeEnergyIn = int(obis_values[2].value*0.0001) + # Print values to console print("Büro Wirkleistung aktuell: " + str(officePowerIn) + "W") print("Büro Energie bezug gesamt: " + str(officeEnergyIn) + "kWh") + + # Add Power value to pointlist pointList.append( Point('power').field('officePowerIn', officePowerIn).time(pushTime, WritePrecision.S) ) - if energyCounter % 12 == 0: # Only add energy to db every 6th while loop (every minute) + # Only add energy to pointlist every 6th while loop (every minute) + if energyCounter % 6 == 0: pointList.append( Point('energy').field('officeEnergyIn', officeEnergyIn).time(pushTime, WritePrecision.S) ) print("Energy in DB") energyCounter = 0 - - for point in pointList: + + for point in pointList: # Print all points in pointlist print(point) - writeToDB(pointList) + writeToDB(pointList) # Write pointlist to db - time.sleep(5) \ No newline at end of file + time.sleep(10) # Sleep 10 seconds before reading the next value \ No newline at end of file