Anti-conflict guard: hysteresis + per-cycle decision log#131
Merged
Conversation
Customer reported visible flipper behaviour during long discharge windows: discharge → idle → discharge every ~16 seconds. Logs showed the anti-conflict guard tripping on momentary grid imports as small as 281W (just over the 200W threshold). Each flip is two Modbus writes and a physical inverter mode switch — rough on hardware and customers notice the on/off cycling. The 200W threshold is easily crossed by everyday loads: kettle, oven preheat, EV charging start, even a fridge compressor kick. When the battery is exporting to the grid and load briefly spikes above the inverter discharge power, the meter reads a few hundred W of import for one polling cycle. Hysteresis added: - Small/moderate import (200-2000W) must persist for ≥ 2 consecutive cycles (~32s) before suppression triggers. - Large import (> 2000W) suppresses immediately (genuine sustained draw like EV charging or oven preheat). - After suppression ends, a 60s cooldown blocks re-suppression so the inverter stabilises before the next decision. Diagnostic logging: - Each tick now logs the full state decision at DEBUG level: desired/current state, SOC, price, threshold, grid_power. Makes flipper investigations straightforward — the customer log pattern would have stood out in seconds with this in place. - Anti-conflict ramp-up (tick N of M) logs at DEBUG; suppression trigger stays at INFO with the sustained/large reason.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Customer reported visible flipper behaviour during long discharge windows: discharge → idle → discharge every ~16 seconds. Logs showed the anti-conflict guard tripping on momentary grid imports as small as 281W (just over the 200W threshold). Each flip is two Modbus writes and a physical inverter mode switch — rough on hardware and customers notice the on/off cycling.
The 200W threshold is easily crossed by everyday loads: kettle, oven preheat, EV charging start, even a fridge compressor kick. When the battery is exporting to the grid and load briefly spikes above the inverter discharge power, the meter reads a few hundred W of import for one polling cycle.
Hysteresis added:
Diagnostic logging: