-
Notifications
You must be signed in to change notification settings - Fork 32
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
US3000 parsing failure #4
Comments
Which version of python are you running ?
…On October 17, 2021 8:14:37 AM GMT+02:00, Vards0 ***@***.***> wrote:
Hi.
I'm getting the following eror when I import the library:-
`>>> import pylontech
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pylontech.py", line 6
def _decode(self, obj, context, path) -> bytes:
`
Any ideas?
Thanks
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#4
|
You need to install the two libs (with pip, pipenv, or whatever) specified here: https://github.com/Frankkkkk/python-pylontech#dependencies
Cheers
…On October 17, 2021 10:04:31 AM GMT+02:00, Vards0 ***@***.***> wrote:
I was running version 2.7.
I have upgraded to version 3.5. Now I am getting this error:-
`Python 3.5.3 (default, Apr 5 2021, 09:00:41)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylontech
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pylontech/pylontech.py", line 2, in <module>
import construct
ImportError: No module named 'construct'
`
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#4 (comment)
|
Thanks very much I was running ver 2.7. I'm now running ver 3.5. I've installed both dependencies but now I am getting this error:- `Python 3.5.3 (default, Apr 5 2021, 09:00:41)
|
I should add more debug verbosity, but in the meantime you could follow #2 (comment) which was the same problem What is your battery topology ? |
My battery topology is 4x US3000 |
Okay, so maybe you've got the same problem as @stuartornum . Can you give me a raw frame example by editing def _decode_hw_frame(self, raw_frame: bytes) -> bytes:
print(raw_frame) and launching That way we can try and support the US3000 batteries alone. |
I managed to get my setup working by having the US2000 as the primary and the US3000 secondary. Although, I still have some weirdness when the SOC of the US3000 is above ~89% it reports as some very lower number (when I know for a fact it’s not!) and when it dips below 89% it reports fine again….? Very stalrange. Here’s my grafana graph https://ibb.co/yV2N2B9 |
Hi Frankkkkk... Sorry for the delay in getting back to you. I edited the code to be as follows:-
I'm not 100% sure if this is what I needed to do. Please correct me if I am wrong. Now when I run the get_values, I am getting the below:- [GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylontech
>>> p = pylontech.Pylontech()
>>> print(p.get_values())
b'~2002460061DC11040F0CFD0CFC0CFC0CFB0CFC0CFB0CFD0CFC0CFC0CFB0CFA0CFD0CFB0CFE0CFA050BE10BCD0BCD0BCD0BCD0000C2C1FFFF04FFFF002F00EFEC0121100F0CEB0CEB0CEB0CEA0CEA0CEC0CEB0CEB0CE90CE80CE60CE90CE90CEA0CE8050BE10BCD0BCD0BCD0BCDFFBCC1B2FFFF04FFFF002800F2D00121100F0CE80CE90CEA0CEA0CEA0CE90CEA0CEA0CEB0CEC0CEB0CEB0CEB0CEA0CEA050BE10BC30BC30BC30BC3FFB7C1B8FFFF04FFFF007100E7400121100F0CE90CEC0CEB0CEA0CEA0CEB0CE90CE80CEA0CEA0CEA0CEB0CEC0CEA0CEA050BD70BC30BC30BC30BB9FFBBC1B9FFFF04FFFF006B00ED080121108D63\r' @stuartornum, are you using mqtt to bring your values into grafana? |
Hi @Vards0 ! I'm using @Frankkkkk code (thank you again!) on a RPi3 polling every minute via cron, this then dumps the output into an nginx html directory... which Prometheus then comes along and pulls the data out for Grafana. I'm using Prometheus for other stuff like Shelly.cloud devices. |
Hi Frank I realised that I needed to change to '/dev/ttyUSB1' I think I'm now getting more meainingful output:-
|
Hi, thanks for the debug output ! I'll take a look tonight hopefully and try to adapt the data structure :-) Cheers |
You were right @Vards0 Indeed I completely missed this part. Here's the output with the correct parsing with the PDU you gave me above:
Could you try the code on the PS: SOC Is wrong because using the US2000 values Cheers |
Frank you're a genius!! I ran the updated code at it looks to be working a treat:- Is there any way of separating the battery identities and their respective values so that I can pipe these into mqtt? [GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylontech
>>> print(p.get_values())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'p' is not defined
>>> p = pylontech.Pylontech()
>>> print(p.get_values())
Container:
NumberOfModules = 4
Module = ListContainer:
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.531
3.53
3.531
3.528
3.531
3.531
3.532
3.515
3.533
3.533
3.53
3.533
3.533
3.533
3.533
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
29.91
29.91
30.01
29.91
Current = 0.0
Voltage = 52.957
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 48
US3000 = Container:
Remaining = 74.0
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.523
3.528
3.534
3.53
3.531
3.531
3.532
3.517
3.535
3.535
3.533
3.534
3.534
3.536
3.532
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
30.01
30.01
30.01
29.91
Current = 0.0
Voltage = 52.965
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 41
US3000 = Container:
Remaining = 74.0
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.529
3.528
3.519
3.533
3.529
3.532
3.53
3.532
3.536
3.536
3.537
3.536
3.537
3.533
3.535
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
29.91
29.91
29.91
29.91
Current = 0.0
Voltage = 52.982
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 114
US3000 = Container:
Remaining = 74.74
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.533
3.525
3.532
3.53
3.532
3.522
3.521
3.524
3.539
3.539
3.522
3.537
3.538
3.54
3.539
NumberOfTemperatures = 5
AverageBMSTemperature = 30.01
GroupedCellsTemperatures = ListContainer:
29.81
29.81
29.91
29.81
Current = 0.0
Voltage = 52.973
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 108
US3000 = Container:
Remaining = 74.0
Total = 74.0
TotalPower = 0.0
StateOfCharge = 1.0
>>> |
This is great !
The values can be iterated like so:
```
vals = p.get_values()
for module in vals.Module:
print (module.Power)
```
PS: I still haven't merged the branch: I'm just waiting on how to do it "cleanly"
…On October 20, 2021 7:37:34 AM GMT+02:00, Vards0 ***@***.***> wrote:
Frank you're a genius!!
I ran the updated code at it looks to be working a treat:-
```Python 3.5.3 (default, Apr 5 2021, 09:00:41)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylontech
>>> print(p.get_values())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'p' is not defined
>>> p = pylontech.Pylontech()
>>> print(p.get_values())
Container:
NumberOfModules = 4
Module = ListContainer:
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.531
3.53
3.531
3.528
3.531
3.531
3.532
3.515
3.533
3.533
3.53
3.533
3.533
3.533
3.533
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
29.91
29.91
30.01
29.91
Current = 0.0
Voltage = 52.957
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 48
US3000 = Container:
Remaining = 74.0
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.523
3.528
3.534
3.53
3.531
3.531
3.532
3.517
3.535
3.535
3.533
3.534
3.534
3.536
3.532
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
30.01
30.01
30.01
29.91
Current = 0.0
Voltage = 52.965
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 41
US3000 = Container:
Remaining = 74.0
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.529
3.528
3.519
3.533
3.529
3.532
3.53
3.532
3.536
3.536
3.537
3.536
3.537
3.533
3.535
NumberOfTemperatures = 5
AverageBMSTemperature = 30.11
GroupedCellsTemperatures = ListContainer:
29.91
29.91
29.91
29.91
Current = 0.0
Voltage = 52.982
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 114
US3000 = Container:
Remaining = 74.74
Total = 74.0
Container:
NumberOfCells = 15
CellVoltages = ListContainer:
3.533
3.525
3.532
3.53
3.532
3.522
3.521
3.524
3.539
3.539
3.522
3.537
3.538
3.54
3.539
NumberOfTemperatures = 5
AverageBMSTemperature = 30.01
GroupedCellsTemperatures = ListContainer:
29.81
29.81
29.91
29.81
Current = 0.0
Voltage = 52.973
Power = 0.0
RemainingCapacity = 65.535
UserDefinedItems = 4
TotalCapacity = 65.535
CycleNumber = 108
US3000 = Container:
Remaining = 74.0
Total = 74.0
TotalPower = 0.0
StateOfCharge = 1.0
>>>
```
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#4 (comment)
|
Thanks once again Frank. Unfortunately I may not be able to use the script after all of this. For some reason it causes my master battery to go into protection mode (Solid red light) as soon as I run it. I can't figure out what is causing this as I have another python script (which again only works with US2000 batteries) which runs without any issues. It pulls the values and the master battery continues running as normal...... Do you have any ideas as to what may be causing this? Cheers |
Hi @Vards0 could you please send me which script you use please ? I have the same issue too for some time now. Don't know why because it worked fine before. Maybe I introduced a regression ? Cheers ! |
Hi Frank. This is the script that I am using that causes the master battery to go into protection mode when I run it.... Pylontech.py
|
And these are the scripts that runs without issue but imports the wrong values because it is written for US2000 and not for US3000 batteries:- Both scripts needed for the communication to work. Pyloncom.py
pylonpacket.py
|
Hi Frank. I'm just following up to see if you have had a chance to review the code for this. I still haven't found any working code that can monitor the Pylontech US3000 devices. Thanks |
I've also got a US3000 and would like to support this project. I'm looking to fix the Capacity fields and therefore have a sensible SoC output. I'm remote from the battery so would hook up a RPi or something and remote into it when I visit next. I'm very keen to get this fixed and see @Frankkkkk has a branch he's waiting to merge... |
@Vards0 I have a US3000 single module. I'm working on modifying @Frankkkkk 's script to work with larger >65Ah (3.5kWh) batteries. I noted Frank's comment about keeping the API clean so I'm working toward that goal but I think maybe an abstractin layer is required rather than making them in the binary conversion code... Your screenshot from the Pylontech RS485 manual is super useful as it means the overflow of the existing fields is not limited to US3000 batteries, but just any which go over 65Ah capacity. Do you have the Pylontech RS485 manual? |
Hi Henry. You should be able to download it from here. https://powerforum.co.za/applications/core/interface/file/attachment.php?id=12308 I look forward to seeing how you get on with this. Please let me know if you need anything else. |
The link doesn't work because: "This attachment is not available. It may have been removed or the person who shared it may not have permission to share it to this location. " I've made changes to a version of Frank's pylontech.py which give me this output: You can try it at https://github.com/hrford/solar-battery/blob/main/pylontech.py It renames the original fields of lower capacity devices to "RemainingCapacityLowC" and "TotalCapacityLowC" and computes two new fields using the existing names "RemainingCapacity" and "TotalCapacity". If you have a high-capacity device, it uses those raw fields instead. (If you have any issues, please send raw_frame outputs and I can put them through my fake serial driver.) |
Thanks Henry. If You copy the link and paste it into a new tab it should work. Github seems to alter the link somehow. https://powerforum.co.za/applications/core/interface/file/attachment.php?id=12308 |
Hi Henry. I ran your modified code. (I'm not sure if you want me to raise a new issue under your github branch).... It gives all the correct values for all 4 of my batteries but unfortunately I am getting the same issue as with Frank's code; for some reason it causes my master battery to go into protection mode (Solid red light) as soon as I run it. I didn't have this issue with the original code that Frank posted. It only started happening after the code was adjusted to accommodate >65AH capacities. |
I spotted that github altered the link and did what you suggested to start with, but same issue. I'll do a comparison between my code and Frank's master branch and see where commands might be different and get back to you. However, any issues should be raised with Frank on his github using a new issue. |
@Vards0 the script that works for you is an older version and nothing like the newer reformatted one I'm working on. I might have a go at running the old script through my serial debugger and see what is different, maybe I can help @Frankkkkk find that regression. In the mean time, can you send me a copy of the RS485 manual please? |
Hi Henry. I cannot find your email address to send you the manual .... Can you perhaps give me upload access to your repository?? Cheers |
Hi @hrford and @Vards0 ! Indeed, I think that I introduced a regression somethere in the code that makes the battery fault themselves.. I'll try to run a git .bissect and hopefully pinpoint the problem. In the meantime, don't hesitate to make a merge request ! I'd be happy to merge them ! Cheers to both |
@Frankkkkk
This is what my test outputs based on your US3000 scanner:
However, my serial driver fakes only one battery, so it's not possible to tell what the issue is with @Vards0's battery is crashing. Varda's script first output: Frank's script first output: @Vards0 Could you let us know where your battery is resetting? |
Hi Henry. Apologies, I was away for a few days. Please clarify what you mean? I am not sure exactly when the script is causing the battery to reset. It seems to be as soon as I run it.... |
Hi
Container: |
Hi.
I'm getting the following eror when I import the library:-
>>> import pylontech Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pylontech.py", line 6 def _decode(self, obj, context, path) -> bytes:
Any ideas?
Thanks
The text was updated successfully, but these errors were encountered: