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-14 20:26:50 +11:00
from pyfroniusreg import gen24_registers
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-16 21:33:28 +11:00
soc = gen24_registers.scaledChaState.get(fronius1)
2024-10-08 16:32:55 +11:00
print(" SOC: %s%%" % soc)
2024-10-14 20:26:50 +11:00
discharge = gen24_registers.scaledOutWRte.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre DRate: %d%%" % discharge)
2024-10-14 20:26:50 +11:00
charge = gen24_registers.scaledInWRte.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre CRate: %d%%" % charge)
2024-10-16 21:33:28 +11:00
mode = gen24_registers.StorCtl_Mod.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre Mode: %d" % mode)
2024-10-16 21:33:28 +11:00
reserve = gen24_registers.scaledMinRsvPct.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Pre Res: %d" % reserve)
# This should be 'no limits' mode
2024-10-16 21:33:28 +11:00
err = gen24_registers.StorCtl_Mod.set(fronius1, 0)
2024-10-08 16:32:55 +11:00
# discharge at 100% allowed charge rate
2024-10-14 20:26:50 +11:00
err = gen24_registers.scaledOutWRte.set(fronius1, 100)
err = gen24_registers.scaledInWRte.set(fronius1, 100)
2024-10-08 16:32:55 +11:00
# charge to 7%
2024-10-16 21:33:28 +11:00
err = gen24_registers.scaledMinRsvPct.set(fronius1, 7)
2024-10-08 16:32:55 +11:00
2024-10-14 20:26:50 +11:00
discharge = gen24_registers.scaledOutWRte.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Post DRate: %d%%" % discharge)
2024-10-14 20:26:50 +11:00
charge = gen24_registers.scaledInWRte.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Post CRate: %d%%" % charge)
2024-10-16 21:33:28 +11:00
mode = gen24_registers.StorCtl_Mod.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Post Mode: %d" % mode)
2024-10-16 21:33:28 +11:00
reserve = gen24_registers.scaledMinRsvPct.get(fronius1)
2024-10-08 16:32:55 +11:00
print("Post Res: %d" % reserve)