Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support US3000 batteries as master #5

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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