powervaultpy 0.0.7__tar.gz → 0.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: powervaultpy
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: An integration to control the Powervault battery
5
5
  Author-email: Adam McDonagh <adam@elitemonkey.net>
6
6
  License: GPLv3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "powervaultpy"
7
- version = "0.0.7"
7
+ version = "0.0.8"
8
8
  authors = [
9
9
  { name="Adam McDonagh", email="adam@elitemonkey.net" },
10
10
  ]
@@ -144,6 +144,30 @@ class PowerVault:
144
144
 
145
145
  _LOGGER.error("Failed to retrieve data")
146
146
 
147
+ def get_kwh(self, data: dict) -> dict:
148
+ # List of attributes to retrieve from data dict
149
+ attributes = [
150
+ "batteryInputFromGrid",
151
+ "batteryInputFromSolar",
152
+ "batteryOutputConsumedByHome",
153
+ "batteryOutputExported",
154
+ "homeConsumed",
155
+ "gridConsumedByHome",
156
+ "solarConsumedByHome",
157
+ "solarExported",
158
+ "solarGenerated",
159
+ ]
160
+ # For each attribute, loop through the data dict and conver the W reading to kWh over the 5 minute period
161
+ totals = {}
162
+ for row in data:
163
+ for attribute in attributes:
164
+ if attribute in row:
165
+ if attribute not in totals:
166
+ totals[attribute] = 0
167
+ totals[attribute] += round(row[attribute] / 1000 * (5/60), 2)
168
+
169
+ return totals
170
+
147
171
  def set_battery_state(self, unit_id: str, battery_state) -> bool:
148
172
  """Override the current battery status with the provided one."""
149
173
  url = f"{self._base_url}/unit/{unit_id}/stateOverride"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: powervaultpy
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: An integration to control the Powervault battery
5
5
  Author-email: Adam McDonagh <adam@elitemonkey.net>
6
6
  License: GPLv3
File without changes