Skip to content

feat(energy-control): add solar-based automatic mode switching#5

Open
deKibi wants to merge 1 commit into
mainfrom
feature/autonomous-energy-mode-switching
Open

feat(energy-control): add solar-based automatic mode switching#5
deKibi wants to merge 1 commit into
mainfrom
feature/autonomous-energy-mode-switching

Conversation

@deKibi

@deKibi deKibi commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Adds autonomous inverter mode switching based on time window, grid availability, and recent battery, PV, and load conditions.

@deKibi deKibi self-assigned this Jul 11, 2026
@deKibi

deKibi commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex please review this PR only for critical or harmful issues.

Focus on whether:

  • mode switching can trigger under unsafe or clearly incorrect conditions;
  • rules can conflict or send the wrong target mode;
  • repeated commands can be spammed;
  • grid-outage priority can be bypassed;
  • invalid or insufficient telemetry can still cause a switch;
  • the current mode check can fail and trigger unnecessary switching.

This is an MVP running in real conditions. Please report only issues that could cause incorrect, unsafe, or damaging behavior. Ignore nice-to-have improvements, broad refactoring, style suggestions, and speculative edge cases.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1214b2782

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +147
if (
last_command_timestamp is not None
and current_timestamp - last_command_timestamp
< ENERGY_MODE_COMMAND_COOLDOWN_SECONDS
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not let cooldowns block outage switches

When grid state toggles and GRID_OUTAGE_TARGET_MODE differs from the solar/time target, a lower-priority rule can send the opposite mode while the grid is briefly available, then this same-target cooldown blocks the next outage command for up to 5 minutes. With the example defaults of solar SBU and outage SUB, an outage at t0 sends SUB, recovery at t1 can send solar SBU, and a second outage at t2 returns here without sending the configured outage SUB even though the current mode is now SBU, bypassing the declared highest-priority safety rule.

Useful? React with 👍 / 👎.

Comment on lines +69 to +73
averages = {
field: sum(sample[field] for sample in valid_samples)
/ len(valid_samples)
for field in REQUIRED_TELEMETRY_FIELDS
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require current samples to satisfy hard solar limits

The solar switch decision averages the whole lookback, so a dangerous latest reading can be hidden by earlier good samples. For example, seven low-load samples plus one current load spike can keep average PLoad under the threshold and still switch from SUB to solar/battery priority exactly when the current load exceeds the configured maximum; the same applies to a current battery-voltage or PV drop. For real operation, the latest sample or per-sample hard limits need to pass before allowing the switch.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant