Skip to content

Commit

Permalink
Changed all energy units to kWh
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed Sep 7, 2021
1 parent 53554ae commit 14e47ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions pymyenergi/base_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ async def fetch_history_data(self, date_from, how_long, resolution):
watt_hours = row.get(key, 0) / 3600
energy_wh[key] = energy_wh[key] + watt_hours
return_data = {
"generated": round(energy_wh["gep"]),
"grid_import": round(energy_wh["imp"]),
"grid_export": round(energy_wh["exp"]),
"generated": round(energy_wh["gep"] / 1000, 2),
"grid_import": round(energy_wh["imp"] / 1000, 2),
"grid_export": round(energy_wh["exp"] / 1000, 2),
"device_total": round(
energy_wh["h1b"] + energy_wh["h2b"] + energy_wh["h3b"]
(energy_wh["h1b"] + energy_wh["h2b"] + energy_wh["h3b"]) / 1000, 2
),
"device_diverted": round(
energy_wh["h1d"] + energy_wh["h2d"] + energy_wh["h3d"]
(energy_wh["h1d"] + energy_wh["h2d"] + energy_wh["h3d"]) / 1000, 2
),
}
for i in range(6):
Expand All @@ -159,7 +159,7 @@ async def fetch_history_data(self, date_from, how_long, resolution):
ct_key = getattr(self, key).name_as_key
if ct_key != "ct_none":
return_data[ct_key] = round(
return_data.get(ct_key, 0) + energy_wh[f"ct{i+1}"]
(return_data.get(ct_key, 0) + (energy_wh[f"ct{i+1}"] / 1000)), 2
)
return return_data

Expand Down
13 changes: 7 additions & 6 deletions pymyenergi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ async def main(args):
out = out + f"Power generation : {client.power_generation}W\n"
out = out + f"Power EV charge : {client.power_charging}W\n"
out = out + f"Power battery : {client.power_battery}W\n"
out = out + f"Energy imported : {client.energy_imported/1000:.2f}kWh\n"
out = out + f"Energy exported : {client.energy_exported/1000:.2f}kWh\n"
out = out + f"Energy generated : {client.energy_generated/1000:.2f}kWh\n"
out = out + f"Energy diverted : {client.energy_diverted/1000:.2f}kWh\n"
out = out + f"Energy imported : {client.energy_imported}kWh\n"
out = out + f"Energy exported : {client.energy_exported}kWh\n"
out = out + f"Energy generated : {client.energy_generated}kWh\n"
out = out + f"Energy diverted : {client.energy_diverted}kWh\n"
out = out + "Devices:\n"
for device in devices:
out = out + f"\t{device.kind.capitalize()}: {device.name}"
if device.kind != HARVI:
out = out + f"\t{device.energy_total}Wh today\n"
out = out + f"\t{device.energy_total}kWh today\n"
for key in device.ct_keys:
out = (
out + f"\t{key} {device.history_data.get(key, 0)}Wh today\n"
out
+ f"\t{key} {device.history_data.get(key, 0)}kWh today\n"
)
out = out + "\n"
else:
Expand Down

0 comments on commit 14e47ca

Please sign in to comment.