pyFroniusReg/examples/reset_charge.py

45 lines
1.3 KiB
Python
Raw Normal View History

2024-10-08 16:32:55 +11:00
#!/usr/bin/env python3
2024-10-11 15:00:51 +11:00
from pyfroniusreg import gen24_registers as froniusreg
2024-10-08 16:32:55 +11:00
from pymodbus.client.tcp import ModbusTcpClient
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
fronius1.connect()
2024-10-11 15:00:51 +11:00
soc = froniusreg.scaledStateOfCharge.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print(" SOC: %s%%" % soc)
2024-10-11 15:00:51 +11:00
discharge = froniusreg.scaledOutWRte.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre DRate: %d%%" % discharge)
2024-10-11 15:00:51 +11:00
charge = froniusreg.scaledInWRte.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre CRate: %d%%" % charge)
2024-10-11 15:00:51 +11:00
mode = froniusreg.StorCtl_Mode.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre Mode: %d" % mode)
2024-10-11 15:00:51 +11:00
reserve = froniusreg.scaledReserve.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre Res: %d" % reserve)
# This should be 'no limits' mode
2024-10-11 15:00:51 +11:00
err = froniusreg.StorCtl_Mode.setValue(fronius1, 0)
2024-10-08 16:32:55 +11:00
# discharge at 100% allowed charge rate
2024-10-11 15:00:51 +11:00
err = froniusreg.scaledOutWRte.setValue(fronius1, 100)
err = froniusreg.scaledInWRte.setValue(fronius1, 100)
2024-10-08 16:32:55 +11:00
# charge to 7%
2024-10-11 15:00:51 +11:00
err = froniusreg.scaledReserve.setValue(fronius1, 7)
2024-10-08 16:32:55 +11:00
2024-10-11 15:00:51 +11:00
discharge = froniusreg.scaledOutWRte.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Post DRate: %d%%" % discharge)
2024-10-11 15:00:51 +11:00
charge = froniusreg.scaledInWRte.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Post CRate: %d%%" % charge)
2024-10-11 15:00:51 +11:00
mode = froniusreg.StorCtl_Mode.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Post Mode: %d" % mode)
2024-10-11 15:00:51 +11:00
reserve = froniusreg.scaledReserve.getValue(fronius1)
2024-10-08 16:32:55 +11:00
print("Post Res: %d" % reserve)