examples now work on installed library

This commit is contained in:
Paul Warren 2024-10-11 15:00:51 +11:00
parent 4bbb92ba29
commit 6f70903993
4 changed files with 38 additions and 66 deletions

View file

@ -1,37 +1,41 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from froniusreg import froniusreg from pyfroniusreg import gen24_registers as froniusreg
from pymodbus.client.tcp import ModbusTcpClient from pymodbus.client.tcp import ModbusTcpClient
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10) fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
fronius1.connect() fronius1.connect()
soc = FroniusReg.scaledStateOfCharge.getValue(fronius1) soc = froniusreg.scaledStateOfCharge.getValue(fronius1)
print(" SOC: %s%%" % soc) print(" SOC: %s%%" % soc)
discharge = FroniusReg.scaledOutWRte.getValue(fronius1) discharge = froniusreg.scaledOutWRte.getValue(fronius1)
print("Pre DRate: %d%%" % discharge) print("Pre DRate: %d%%" % discharge)
charge = FroniusReg.scaledInWRte.getValue(fronius1) charge = froniusreg.scaledInWRte.getValue(fronius1)
print("Pre CRate: %d%%" % charge) print("Pre CRate: %d%%" % charge)
mode = FroniusReg.StorCtl_Mode.getValue(fronius1) mode = froniusreg.StorCtl_Mode.getValue(fronius1)
print("Pre Mode: %d" % mode) print("Pre Mode: %d" % mode)
# This should be 'limit discharge' mode # This should be 'limit discharge' mode
err = FroniusReg.StorCtl_Mode.setValue(fronius1, 2) print("Setting control mode to limit discharge")
err = froniusreg.StorCtl_Mode.setValue(fronius1, 2)
# Charge battery at a rate from -2% discharge to 100% charge # Charge battery at a rate from -2% discharge to 100% charge
# as a percentage of the MaxChaRte, which in our case is 25600W # as a percentage of the MaxChaRte, which in our case is 25600W
err = FroniusReg.scaledOutWRte.setValue(fronius1, -10) print("Setting discharge rate to -10%")
err = FroniusReg.scaledInWRte.setValue(fronius1, 100) err = froniusreg.scaledOutWRte.setValue(fronius1, int(-10))
print("Setting charge rate to 100%")
err = froniusreg.scaledInWRte.setValue(fronius1, int(100))
discharge = FroniusReg.scaledOutWRte.getValue(fronius1) discharge = froniusreg.scaledOutWRte.getValue(fronius1)
print("Post DRate: %d%%" % discharge) print("Post DRate: %d%%" % discharge)
charge = FroniusReg.scaledInWRte.getValue(fronius1) charge = froniusreg.scaledInWRte.getValue(fronius1)
print("Post CRate: %d%%" % charge) print("Post CRate: %d%%" % charge)
mode = FroniusReg.StorCtl_Mode.getValue(fronius1) mode = froniusreg.StorCtl_Mode.getValue(fronius1)
print("Post Mode: %d" % mode) print("Post Mode: %d" % mode)

View file

@ -1,32 +1,32 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from froniusreg import froniusreg from pyfroniusreg import gen24_registers as froniusreg
from pymodbus.client.tcp import ModbusTcpClient from pymodbus.client.tcp import ModbusTcpClient
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10) fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
fronius1.connect() fronius1.connect()
soc = FroniusReg.scaledStateOfCharge.getValue(fronius1) soc = froniusreg.scaledStateOfCharge.getValue(fronius1)
print(" SOC: %s%%" % soc) print(" SOC: %s%%" % soc)
discharge = FroniusReg.scaledOutWRte.getValue(fronius1) discharge = froniusreg.scaledOutWRte.getValue(fronius1)
print("Pre DRate: %d%%" % discharge) print("Pre DRate: %d%%" % discharge)
charge = FroniusReg.scaledInWRte.getValue(fronius1) charge = froniusreg.scaledInWRte.getValue(fronius1)
print("Pre CRate: %d%%" % charge) print("Pre CRate: %d%%" % charge)
mode = FroniusReg.StorCtl_Mode.getValue(fronius1) mode = froniusreg.StorCtl_Mode.getValue(fronius1)
print("Pre Mode: %d" % mode) print("Pre Mode: %d" % mode)
reserve = FroniusReg.scaledReserve.getValue(fronius1) reserve = froniusreg.scaledReserve.getValue(fronius1)
print("Pre Res: %d" % reserve) print("Pre Res: %d" % reserve)
rate = FroniusReg.scaledMaxChaRte.getValue(fronius1) rate = froniusreg.scaledMaxChaRte.getValue(fronius1)
print("Pre rate: %d" % rate) print("Pre rate: %d" % rate)
rate = FroniusReg.scaledMaxWChaGra.getValue(fronius1) rate = froniusreg.scaledMaxWChaGra.getValue(fronius1)
print("Pre WGra rate: %d" % rate) print("Pre WGra rate: %d" % rate)
revert = FroniusReg.InOutWRte_RvrtTms.getValue(fronius1) revert = froniusreg.InOutWRte_RvrtTms.getValue(fronius1)
print("Timer: %d" % revert) print("Timer: %d" % revert)

View file

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

View file

@ -1,32 +0,0 @@
#!/usr/bin/env python3
from pyfroniusreg import gen24_registers as froniusreg
from pymodbus.client.tcp import ModbusTcpClient
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
fronius1.connect()
soc = froniusreg.scaledStateOfCharge.getValue(fronius1)
print(" SOC: %s%%" % soc)
discharge = froniusreg.scaledOutWRte.getValue(fronius1)
print("Pre DRate: %d%%" % discharge)
charge = froniusreg.scaledInWRte.getValue(fronius1)
print("Pre CRate: %d%%" % charge)
mode = froniusreg.StorCtl_Mode.getValue(fronius1)
print("Pre Mode: %d" % mode)
reserve = froniusreg.scaledReserve.getValue(fronius1)
print("Pre Res: %d" % reserve)
rate = froniusreg.scaledMaxChaRte.getValue(fronius1)
print("Pre rate: %d" % rate)
rate = froniusreg.scaledMaxWChaGra.getValue(fronius1)
print("Pre WGra rate: %d" % rate)
revert = froniusreg.InOutWRte_RvrtTms.getValue(fronius1)
print("Timer: %d" % revert)