Skip to content

Commit

Permalink
Fix percentage_charged
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Dec 22, 2023
1 parent 86a3efd commit 974f793
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pypowerwall/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,13 @@ def poll(self, api):
# TODO: Assemble vitals data payload
data = None

elif api in ['/api/system_status/soe','/soe']:
# TODO check to see if SOE is true value or 5% reserved
power = self.get_site_power()
elif api in ['/api/system_status/soe']:
battery = self.get_battery()
percentage_charged = lookup(battery, ("response", "percentage_charged")) or 0
# percentage_charged is scaled to keep 5% buffer at bottom
soe = (percentage_charged + (5 / 0.95)) * 0.95
data = {
"percentage": lookup(power, ("response", "percentage_charged")) or 0,
"percentage": soe,
}

elif api == '/api/meters/aggregates':
Expand Down Expand Up @@ -488,9 +490,7 @@ def poll(self, api):

data = {
"real_mode": default_real_mode,
"backup_reserve_percent": backup_reserve_percent,
"freq_shift_load_shed_soe": 0,
"freq_shift_load_shed_delta_f": 0
"backup_reserve_percent": backup_reserve_percent
}
elif api == '/api/system_status':
power = self.get_site_power()
Expand Down

0 comments on commit 974f793

Please sign in to comment.