Skip to content

Commit 944f4d7

Browse files
authored
Merge pull request #4 from RepositPower/feature/add-remaining-charge
Add remaining charge method
2 parents 3bde9bb + 28bda11 commit 944f4d7

File tree

6 files changed

+35
-15
lines changed

6 files changed

+35
-15
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ print(controller.battery_capacity)
4343
| `battery_min_state_of_charge` | - | Get the minimum state of charge of the battery | Percentage (%)
4444
| `has_battery` | - | Bool of whether the user has a battery or not| True/False |
4545
| `has_inverter` | - | Bool of whether the user has an inverter or not| True/False |
46-
| `get_solar_generation_data` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of solar generation data based on start or end| kW |
47-
|`latest_solar_generation_data`|-|Get a list of the latest generation data. Goes back the last 24 hours.| kW |
48-
| `get_house_data` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of house data based on start or end| kW|
49-
|`latest_house_data`|-|Get a list of the latest house data. Goes back the last 24 hours.| kW|
46+
| `get_solar_generation` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of solar generation data based on start or end| kW |
47+
|`latest_solar_generation`|-|Get a list of the latest generation data. Goes back the last 24 hours.| kW |
48+
| `get_house_consumption` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of house consumption values based on start or end| kW|
49+
|`latest_house_consumption`|-|Get a list of the latest house consumption. Goes back the last 24 hours.| kW|
5050
| `get_battery_data` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of battery data based on start or end| kWh |
51-
|`latest_battery_data`|-|Get a list of the latest battery data. Goes back the last 24 hours.| kWh |pip
52-
| `get_meter_data` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of meter data based on start or end. There should be at least a 5 minute gap between start and end timestamps (i.e. 300 seconds) | kWh
53-
|`latest_meter_data`|-|Get a list of the latest meter data. Goes back the last 24 hours.| kWh |
51+
|`latest_battery_data`|-|Get a list of the latest battery data. Goes back the last 24 hours.| kWh |
52+
| `get_remaining_charge` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of the battery's remaining charge values based on start or end. There should be at least a 5 minute gap between start and end timestamps (i.e. 300 seconds)<br/><br/> Note: This can be used to calculate the state of charge with the formula: (remaining_charge / battery_capacity) * 100` | kWh
53+
| `get_meter_data` | <ul><li>start (timestamp)</li><li>end(timestamp)(optional, default=now)</li></ul> | Get a list of meter data based on start or end. There should be at least a 5 minute gap between start and end timestamps (i.e. 300 seconds) | kW
54+
|`latest_meter_data`|-|Get a list of the latest meter data. Goes back the last 24 hours.| kW |
5455
|`feed_in_tariff`|-|Get the feed-in-tariff| Dollars ($) |
5556

5657
## Links

reposit/auth/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ class NoAuthenticationError(Exception):
88
If a method is called that requires an access token and none is yet
99
set then raise this error
1010
"""
11+
# pylint: disable=unnecessary-pass
1112
pass

reposit/data/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def query(self, start, end=None):
108108
raise ex
109109

110110
data = self._simple_format_for_fields(resp)
111-
return {'data': data[0]} # because this is a list of lists
111+
return {'data': data}
112112

113113
def _simple_format_for_fields(self, api_response):
114114
"""

reposit/data/controller.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def has_inverter(self):
8080
)
8181
return request.get()
8282

83-
def get_solar_generation_data(self, start, end):
83+
def get_solar_generation(self, start, end=None):
8484
"""
8585
Given a start and end timestamp return the generation
8686
data.
@@ -98,7 +98,7 @@ def get_solar_generation_data(self, start, end):
9898
return request.query(start, end)
9999

100100
@property
101-
def latest_solar_generation_data(self):
101+
def latest_solar_generation(self):
102102
"""
103103
Return a list of data points as lists. Time are in GMT
104104
:return:
@@ -112,7 +112,7 @@ def latest_solar_generation_data(self):
112112
)
113113
return request.get()
114114

115-
def get_house_data(self, start, end):
115+
def get_house_consumption(self, start, end=None):
116116
"""
117117
Given a start and end timestamp return the house
118118
data.
@@ -130,7 +130,7 @@ def get_house_data(self, start, end):
130130
return request.query(start, end)
131131

132132
@property
133-
def latest_house_data(self):
133+
def latest_house_consumption(self):
134134
"""
135135
Return a list of data points as lists. Time are in GMT
136136
:return:
@@ -146,7 +146,7 @@ def latest_house_data(self):
146146
)
147147
return request.get()
148148

149-
def get_battery_data(self, start, end):
149+
def get_battery_data(self, start, end=None):
150150
"""
151151
Given a start and end timestamp return the inverter
152152
data.
@@ -178,7 +178,24 @@ def latest_battery_data(self):
178178
)
179179
return request.get()
180180

181-
def get_meter_data(self, start, end):
181+
def get_remaining_charge(self, start, end=None):
182+
"""
183+
Given a start and end timestamp return the remaining battery charge
184+
data.
185+
:param start: unix timestamp
186+
:param end: unix timestamp
187+
:return: list of lists of data
188+
"""
189+
request = ApiRequest(
190+
path='v2/deployments/{}/battery/historical/soc'.format(self.user_key),
191+
controller=self,
192+
schema={
193+
'batterySOC': {}
194+
}
195+
)
196+
return request.query(start, end)
197+
198+
def get_meter_data(self, start, end=None):
182199
"""
183200
Given a start and end timestamp return the meter
184201
data.

reposit/data/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ class InvalidControllerException(Exception):
77
"""
88
A connection is attempted without auth headers
99
"""
10+
# pylint: disable=unnecessary-pass
1011
pass

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="reposit",
8-
version="0.3.1",
8+
version="0.4.0",
99
author="Thomas Basche",
1010
author_email="[email protected]",
1111
description="A library to communicate with a Reposit Controller",

0 commit comments

Comments
 (0)