mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-15 15:41:20 +10:00
Fix decimal places for PVOutput
This commit is contained in:
@@ -132,12 +132,12 @@ exports:
|
||||
# register:
|
||||
- name: v4 # Power Consumption
|
||||
register: load_power # Current Home usage (Power)
|
||||
- name: v5 # Temperature
|
||||
register: internal_temperature # Inverter internal temperature
|
||||
# - name: v5 # Ambient temperature see: https://forum.pvoutput.org/t/what-temperature-is-used-to-calculate-insolation/2106
|
||||
# register: internal_temperature #
|
||||
- name: v6 # Voltage
|
||||
register: phase_a_voltage # Read voltage from first Phase
|
||||
- name: c1 # Cumulative Flag,
|
||||
value: 2 # If using v2/v4 set to 1
|
||||
value: 2 # If using v2 & v4 set to 1, of using only v1 set to 2 (if daily totals)
|
||||
# - name: "n" # Net Flag
|
||||
# value: 1
|
||||
# - name: "v7" # Extended Value v7 - Donation Only
|
||||
|
||||
@@ -101,7 +101,10 @@ class export_pvoutput(object):
|
||||
if int(now.strftime("%M")) % self.status_interval == 0 and not now.strftime("%H:%M") == self.latest_run.strftime("%H:%M"):
|
||||
for v in self.collected_data:
|
||||
if v[0] == 'v' and not self.collected_data[v] == 0:
|
||||
self.collected_data[v] = round(self.collected_data[v] / self.collected_data['count'], 2)
|
||||
if v[1] == '6' or v[1] == '7': # Round to 1 decimal place
|
||||
self.collected_data[v] = round(self.collected_data[v] / self.collected_data['count'], 1)
|
||||
else: # Getting errors when uploading decimals for power/energy so return INT
|
||||
self.collected_data[v] = int(self.collected_data[v] / self.collected_data['count'])
|
||||
|
||||
data_point = str(now.strftime("%Y%m%d")) + "," + str(now.strftime("%H:%M"))
|
||||
|
||||
@@ -111,16 +114,9 @@ class export_pvoutput(object):
|
||||
data_point = data_point + "," + str(self.collected_data[v])
|
||||
else:
|
||||
data_point = data_point + ","
|
||||
|
||||
if self.collected_data.get('v2', False) and self.collected_data.get('v4', False):
|
||||
net_data = 1
|
||||
else:
|
||||
net_data = 0
|
||||
|
||||
self.collected_data = {}
|
||||
|
||||
print(data_point)
|
||||
|
||||
if self.payload_data:
|
||||
self.payload_data = self.payload_data + ";"
|
||||
else:
|
||||
@@ -128,14 +124,12 @@ class export_pvoutput(object):
|
||||
self.payload_data = self.payload_data + data_point
|
||||
|
||||
self.batch_count +=1
|
||||
|
||||
|
||||
if self.batch_count == self.batch_points:
|
||||
|
||||
payload = {}
|
||||
payload['data'] = self.payload_data
|
||||
|
||||
if net_data > 0:
|
||||
payload['n'] = net_data
|
||||
if 'cumulative_energy' in locals():
|
||||
payload['c1'] = cumulative_energy
|
||||
|
||||
|
||||
@@ -209,7 +209,6 @@ registers:
|
||||
address: 5008
|
||||
datatype: "S16"
|
||||
multiple: 0.1
|
||||
zero_on_standby: True
|
||||
- name: "total_apparent_power"
|
||||
level: 1
|
||||
address: 5009
|
||||
@@ -258,7 +257,6 @@ registers:
|
||||
address: 5019
|
||||
datatype: "U16"
|
||||
multiple: 0.1
|
||||
zero_on_standby: True
|
||||
- name: "phase_b_voltage"
|
||||
level: 2
|
||||
address: 5020
|
||||
|
||||
@@ -204,9 +204,6 @@ def load_registers(register_type, start, count=100):
|
||||
if register.get('multiple'):
|
||||
register_value = round(register_value * register.get('multiple'),2)
|
||||
|
||||
if register.get('zero_on_standby') and inverter["run_state"] == "OFF":
|
||||
register_value = 0
|
||||
|
||||
# Set the final register value with adjustments above included
|
||||
inverter[register_name] = register_value
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user