-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Sonnenbatterie 5/6: add battery control #21152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sonnenbatterie 5/6: add battery control #21152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ngehrsitz - I've reviewed your changes - here's some feedback:
- The watchdog timeout in "charge" mode (
30s) appears to conflict with its comment (3 minutes); please clarify. - Consider if the hardcoded 1-second sleep in the "charge" sequence should be configurable.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
e0b29b0 to
14c32de
Compare
14c32de to
1c98b45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ngehrsitz - I've reviewed your changes - here's some feedback:
- In plugin/watchdog.go you can simplify
make([]T, 0, 0)to the literal[]T{}and consider making BoolSetter support multiple reset values like the Int/Float setters for consistency. - In plugin/sleep.go use
time.Sleep(o.duration)instead of<-time.After(o.duration)to avoid unnecessary timer allocations for a simple delay. - Double-check the indentation of the
maxchargepowertemplating in the YAML to ensure it renders correctly under both branches.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Mein workaround funktioniert, langfristig sollte man sich überlegen, ob der ursprüngliche Fall mit einem Watchdog hinter einem switch statement nicht auch den watchdog abbrechen sollte. |
|
Workaround wofür? Der WDT bricht bei |
Co-authored-by: andig <cpuidle@gmail.com>
| body: '55' # slave mode | ||
| - source: watchdog | ||
| timeout: 30s # 3 minutes without setting a value will stop all charging | ||
| reset: 1,2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hast Du das getestet? Reset kann laut Code nur einen Wert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deshalb habe ich das in c34d8df eingebaut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice. Einfacher: mach config.Reset []string, dann sparst Du das Splitting. Leere Slices einfach als
var reset []int64
Du meinst wahrscheinlich batterymode:
# use a sequence to propagate resets to the watchdog
source: watchdog
timeout: 30s # 3 minutes without setting a value will stop all charging
reset: 1,2
set:
source: switch
switch:
- case: 1 # normal
set:
source: http
method: PUT
uri: http://{{ .host }}:{{ .port }}/rest/devices/battery/C06
body: '10' # Automatic
- case: 2 # hold
set:
source: http
method: PUT
uri: http://{{ .host }}:{{ .port }}/rest/devices/battery/C06
body: '20' # Standby
- case: 3 # charge
set:
source: sequence
set:
- source: http
method: PUT
uri: http://{{ .host }}:{{ .port }}/rest/devices/battery/C06
body: '55' # slave mode
- source: sleep
duration: 1s
- source: http
method: PUT
uri: http://{{ .host }}:{{ .port }}/rest/devices/battery/C24
body: {{ if .maxchargepower }}{{ .maxchargepower }}{{ else }}99000{{ end }}Wenn ich das so definiere wird aber auch der Modus immer wieder geändert: Genau das will ich aber vermeiden, weil die API leider total instabil ist und bei zu vielen requests aussteigt. |
|
Oh, ok- dann mach bitte noch einen Kommentar damit man das versteht. |
|
Du hast keins konfiguriert ;) |
Meinst du damit 6bb8612? |
Genau. Damit sollte intern gecached werden- das siehst Du aber nur mit Wireshark. |
Der Screenshot ist von _, dateErr:= Date(resp.Header)
if errors.Is(dateErr,ErrNoDateHeader) {
resp.Header.Set("Date", time.Now().Format(time.RFC1123))
}Der Grund dafür dürfte sein, das parallele Requests nicht kombiniert werden und der Cache erst dann eingreift, wenn er einen request gespeichert hat. |
plugin/watchdog.go
Outdated
| } | ||
|
|
||
| var reset *int64 | ||
| reset := make([]int64, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| reset := make([]int64, 0, 0) | |
| var reset []int64 |
dito unten
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.


Looks like #20451 is done apart from some test. Continuing from #20742