Skip to content

Commit

Permalink
Added ct energy
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed Sep 7, 2021
1 parent 15a579b commit 2eb8d44
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pymyenergi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ async def main(args):
out = out + f"Energy diverted : {client.energy_diverted/1000:.2f}kWh\n"
out = out + "Devices:\n"
for device in devices:
out = out + f" {device.kind.capitalize()}: {device.name}"
out = out + f"\t{device.kind.capitalize()}: {device.name}"
if device.kind != HARVI:
out = out + f"\t{device.energy_total}Wh today"
out = out + "\n"
out = out + f"\t{device.energy_total}Wh today\n"
for key in device.ct_keys:
out = (
out + f"\t{key} {device.history_data.get(key, 0)}Wh today\n"
)
out = out + "\n"
else:
out = out + "\n"
print(out)
elif args.command in ["zappi", "eddi", "harvi"]:
device = device_factory(conn, args.command, args.serial)
Expand Down
13 changes: 13 additions & 0 deletions pymyenergi/eddi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def kind(self):
def prefix(self):
return "E"

@property
def ct_keys(self):
"""Return CT key names that are not none"""
keys = {}
for i in range(2):
ct = getattr(self, f"ct{i+1}")
if ct.name_as_key == "ct_none":
continue
keys[ct.name_as_key] = keys.get(ct.name_as_key, 0) + 1
return keys

@property
def l1_phase(self):
"""What phase L1 is connected to"""
Expand Down Expand Up @@ -72,4 +83,6 @@ def show(self):
ret = ret + f"S/N {self.serial_number} version {self.firmware_version}\n\n"
ret = ret + f"CT 1 {self.ct1.name} {self.ct1.power}W\n"
ret = ret + f"CT 2 {self.ct2.name} {self.ct2.power}W\n"
for key in self.ct_keys:
ret = ret + f"Energy {key} {self.history_data.get(key, 0)}Wh\n"
return ret
11 changes: 11 additions & 0 deletions pymyenergi/harvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ def __init__(self, connection: Connection, serialno, data={}) -> None:
def kind(self):
return HARVI

@property
def ct_keys(self):
"""Return CT key names that are not none"""
keys = {}
for i in range(3):
ct = getattr(self, f"ct{i+1}")
if ct.name_as_key == "ct_none":
continue
keys[ct.name_as_key] = keys.get(ct.name_as_key, 0) + 1
return keys

@property
def ct3(self):
"""Current transformer 3"""
Expand Down
14 changes: 14 additions & 0 deletions pymyenergi/zappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def kind(self):
def prefix(self):
return "Z"

@property
def ct_keys(self):
"""Return CT key names that are not none"""
keys = {}
for i in range(6):
ct = getattr(self, f"ct{i+1}")
if ct.name_as_key == "ct_none":
continue
keys[ct.name_as_key] = keys.get(ct.name_as_key, 0) + 1
return keys

@property
def charge_mode(self):
"""Charge mode, one of Fast, Eco, Eco+ and Stopped"""
Expand Down Expand Up @@ -212,6 +223,9 @@ def show(self):
ret = ret + f" Grid : {self.power_grid}W\n"
ret = ret + f" Generated : {self.power_generated}W\n"
ret = ret + "\n"
for key in self.ct_keys:
ret = ret + f"Energy {key} {self.history_data.get(key, 0)}Wh\n"
ret = ret + "\n"
ret = ret + f"Boost with {self.boost_amount}kWh\n"
ret = ret + "Smart Boost start at"
ret = ret + f" {self.smart_boost_start_hour}:{self.smart_boost_start_minute}"
Expand Down

0 comments on commit 2eb8d44

Please sign in to comment.