Hi, since I’m new in this community I’m not sure if this is the right place to ask for support.
However:
We have a Fronius Primo Gen24 Plus 10kw inverter and a BYD battery. We live in New Zealand and our electricity provider has peak tariffs (07:00 to 9:00 and 17:00 to 21:00) for both use and buyback and an hour of free power per day outside of peak times – our free hour is set to 6:00 to 7:00.
We have very successfully implemented redpomodoro fronius_modbus (int +sf) and solcast and the system has been running for 12 months now. I force charge during the free hour and then may or may not force discharge during peak export tariffs dependent on solcast forecast , battery soc and load expectations.
I would like to implement deadman functionality so that if power or network fails while I’m up a mountain and the inverter is in a force charge or force discharge state, I want the inverter to revert to auto mode.
I tested the code below which I got from google expecting the timer to count down, but it immediately reverted.
I’d love to hear from anyone who has found a way to implement deadman restoration to auto battery storage mode using modbus on the gen24 plus inverter?
Thanks you for reading this.
Cheers Noel
import time
from pymodbus.client import ModbusTcpClient
--- LOCAL ROUTING CONFIGURATION ---
INVERTER_IP = "192.168.1.1"
PORT = 502
SLAVE_ID = 1
client = ModbusTcpClient(INVERTER_IP, port=PORT)
if client.connect():
print("=" * 70)
print(" AUTONOMOUS MOUNTAIN WATCHDOG: Activating 30s Hardware Lease Timer")
print("=" * 70)
# Write a 30-second countdown window to register 40348 instead of a static mode flag
print("Sending 30-second hardware safety window to register 40348...")
client.write_register(40348, 30, slave=SLAVE_ID)
time.sleep(0.1)
print("Hardware safety window sent. Monitoring the countdown loop live below...\n")
print("Simulate a failure now: Disconnect your Pi or stop your scripts.\n")
try:
for i in range(35):
# Poll register 40348 to watch the hardware clock tick down to zero
res_m = client.read_holding_registers(40348, 1, slave=SLAVE_ID)
m_val = res_m.registers[0] if not res_m.isError() else "ERR"
print(f"[{time.strftime('%H:%M:%S')}] Inverter Safety Clock (40348): {m_val}s remaining")
# If it snaps back to 100 or 0, the timeout has triggered successfully
if m_val == 100 or m_val == 0:
print("\n🎉 SUCCESS: The hardware timer hit zero!")
print("The inverter automatically wiped the overrides and snapped back to AUTO natively!")
break
time.sleep(1)
except KeyboardInterrupt:
pass
finally:
client.close()
else:
print("Connection failed.")