Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pylontech/pylontech.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ class Pylontech:
"Voltage" / ToVolt(construct.Int16ub),
"Power" / construct.Computed(construct.this.Current * construct.this.Voltage),
"RemainingCapacity" / DivideBy1000(construct.Int16ub),
"_undef1" / construct.Int8ub,
"UserDefinedItems" / construct.Int8ub,
"TotalCapacity" / DivideBy1000(construct.Int16ub),
"CycleNumber" / construct.Int16ub,
"US3000" / construct.If(construct.this.UserDefinedItems > 2,
"Capacity" / construct.Struct(
"Remaining" / DivideBy1000(construct.Int24ub),
"Total" / DivideBy1000(construct.Int24ub),
)
),
)),
"TotalPower" / construct.Computed(lambda this: sum([x.Power for x in this.Module])),
"StateOfCharge" / construct.Computed(lambda this: sum([x.RemainingCapacity for x in this.Module]) / sum([x.TotalCapacity for x in this.Module])),

)

def __init__(self, serial_port='/dev/ttyUSB0', baudrate=115200):
Expand Down