Skip to content

Commit

Permalink
Fix decimal places for PVOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-s committed Jan 17, 2022
1 parent 1d02bac commit fcc7f4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
6 changes: 3 additions & 3 deletions SunGather/config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions SunGather/exports/pvoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def publish(self, inverter):
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"))

Expand All @@ -111,31 +114,22 @@ def publish(self, inverter):
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:
self.payload_data = ""
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

Expand Down
2 changes: 0 additions & 2 deletions SunGather/registers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ registers:
address: 5008
datatype: "S16"
multiple: 0.1
zero_on_standby: True
- name: "total_apparent_power"
level: 1
address: 5009
Expand Down Expand Up @@ -258,7 +257,6 @@ registers:
address: 5019
datatype: "U16"
multiple: 0.1
zero_on_standby: True
- name: "phase_b_voltage"
level: 2
address: 5020
Expand Down
3 changes: 0 additions & 3 deletions SunGather/sungather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fcc7f4f

Please sign in to comment.