Skip to content

HEMS: add FNN 3-relay (experimental)#25851

Merged
andig merged 6 commits intomasterfrom
feat/vnn-3-relay
Dec 29, 2025
Merged

HEMS: add FNN 3-relay (experimental)#25851
andig merged 6 commits intomasterfrom
feat/vnn-3-relay

Conversation

@andig
Copy link
Copy Markdown
Member

@andig andig commented Dec 6, 2025

Depends on #25887

@andig andig added the devices Specific device support label Dec 6, 2025
@premultiply

This comment was marked as outdated.

@andig andig changed the title Add VNN 3-relay Add FNN 3-relay Dec 7, 2025
@andig andig changed the title Add FNN 3-relay HEMS: add FNN 3-relay Dec 7, 2025
@github-actions github-actions Bot added the stale Outdated and ready to close label Dec 14, 2025
@premultiply premultiply removed the stale Outdated and ready to close label Dec 15, 2025
@github-actions github-actions Bot added the stale Outdated and ready to close label Dec 22, 2025
@andig andig added backlog Things to do later and removed stale Outdated and ready to close labels Dec 23, 2025
@andig andig changed the title HEMS: add FNN 3-relay HEMS: add FNN 3-relay (experimental) Dec 29, 2025
@andig andig marked this pull request as ready for review December 29, 2025 16:33
@andig andig added the experimental Experimental feature label Dec 29, 2025
@andig andig enabled auto-merge (squash) December 29, 2025 16:33
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The maxPower field is effectively unused (only referenced in commented code in curtail); either wire it up via SetMaxPower or remove the parameter/field to avoid confusion.
  • Run uses time.Tick without any way to stop the goroutine, which can leak a ticker and run forever; consider using time.NewTicker with a stop mechanism (e.g., context cancellation) to allow clean shutdown.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `maxPower` field is effectively unused (only referenced in commented code in `curtail`); either wire it up via `SetMaxPower` or remove the parameter/field to avoid confusion.
- `Run` uses `time.Tick` without any way to stop the goroutine, which can leak a ticker and run forever; consider using `time.NewTicker` with a stop mechanism (e.g., context cancellation) to allow clean shutdown.

## Individual Comments

### Comment 1
<location> `hems/fnn/fnn-3.go:46-53` </location>
<code_context>
+		return nil, errors.New("hems requires load management- please configure root circuit")
+	}
+
+	// register LPP circuit if not already registered
+	lpp, err := shared.GetOrCreateCircuit("lpp", "fnn-3")
+	if err != nil {
+		return nil, err
+	}
+
+	// wrap old root with new pc parent
+	if err := root.Wrap(lpp); err != nil {
+		return nil, err
+	}
</code_context>

<issue_to_address>
**issue (bug_risk):** Avoid performing irreversible side effects (wrapping root circuit) before all dependent getters are successfully created

If `cc.S1.BoolGetter`, `cc.S2.BoolGetter`, or `cc.W3.BoolGetter` fails, this function returns an error after `root.Wrap(lpp)` and `site.SetCircuit(lpp)` have already changed global state, leaving a partially configured system despite `NewFromConfig` failing. Please reorder so all getters are constructed and configuration validated before wrapping the root and calling `site.SetCircuit`, or add compensating logic to roll back those side effects on error.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread hems/fnn/fnn-3.go
Comment on lines +46 to +53
// register LPP circuit if not already registered
lpp, err := shared.GetOrCreateCircuit("lpp", "fnn-3")
if err != nil {
return nil, err
}

// wrap old root with new pc parent
if err := root.Wrap(lpp); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Avoid performing irreversible side effects (wrapping root circuit) before all dependent getters are successfully created

If cc.S1.BoolGetter, cc.S2.BoolGetter, or cc.W3.BoolGetter fails, this function returns an error after root.Wrap(lpp) and site.SetCircuit(lpp) have already changed global state, leaving a partially configured system despite NewFromConfig failing. Please reorder so all getters are constructed and configuration validated before wrapping the root and calling site.SetCircuit, or add compensating logic to roll back those side effects on error.

@andig andig merged commit 1d6ab6b into master Dec 29, 2025
9 checks passed
@andig andig deleted the feat/vnn-3-relay branch December 29, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backlog Things to do later devices Specific device support experimental Experimental feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants