Skip to content
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

Update lp.applyAction() handling #1942

Merged
merged 17 commits into from
Dec 1, 2021
Merged

Conversation

rivengh
Copy link
Contributor

@rivengh rivengh commented Nov 26, 2021

  • allow GetTargetSoC() and GetMinSoC() to be used even when no vehicle is connected
  • use SetMinSoC() and SetTargetSoC() functions in applyAction()
  • allow to set minSoC to 0 with applyAction()
  • apply OnIdentify actions only when OnIdentify node is present in vehicle configuration (optional parameter)

@andig andig added the enhancement New feature or request label Nov 26, 2021
@rivengh
Copy link
Contributor Author

rivengh commented Nov 26, 2021

Vehicle connected and identified:

[lp-1  ] INFO 2021/11/26 12:51:20 car connected
[lp-1  ] INFO 2021/11/26 12:54:31 vehicle updated: unknown -> VW e-up!
[lp-1  ] INFO 2021/11/26 12:54:31 set charge mode: pv
[lp-1  ] INFO 2021/11/26 12:54:31 set min current: 6
[lp-1  ] INFO 2021/11/26 12:54:31 set max current: 16
[lp-1  ] INFO 2021/11/26 12:54:31 set min soc: 20
[lp-1  ] INFO 2021/11/26 12:54:31 set target soc: 60

Reset to loadpoint defaults on vehicle disconnect:

[lp-1  ] INFO 2021/11/26 12:56:40 car disconnected
[lp-1  ] INFO 2021/11/26 12:56:40 vehicle updated: VW e-up! -> unknown
[lp-1  ] INFO 2021/11/26 12:56:40 set charge mode: off
[lp-1  ] INFO 2021/11/26 12:56:40 set min current: 6
[lp-1  ] INFO 2021/11/26 12:56:40 set max current: 16
[lp-1  ] INFO 2021/11/26 12:56:40 set min soc: 0
[lp-1  ] INFO 2021/11/26 12:56:40 set target soc: 80

@rivengh rivengh marked this pull request as draft November 29, 2021 15:10
@rivengh
Copy link
Contributor Author

rivengh commented Nov 29, 2021

evcc vehicles dump without Identifiers and with OnIdentified options:

e-up
----
SoC:            71%
...
Capacity:       32kWh
OnIdentified:   &{pv 6 16 20 60}

Dump without OnIdentified and with Identifiers options:

dummy
-----
SoC:           100%
Charge status: B
Capacity:      50kWh
Identifiers:   [DUMMY:IDENT]

@rivengh rivengh marked this pull request as ready for review November 29, 2021 15:15
@andig
Copy link
Member

andig commented Nov 29, 2021

apply OnIdentify actions only when OnIdentify node is present in vehicle configuration (optional parameter)

Was willst Du hier erreichen?

@rivengh
Copy link
Contributor Author

rivengh commented Nov 29, 2021

apply OnIdentify actions only when OnIdentify node is present in vehicle configuration (optional parameter)

Was willst Du hier erreichen?

Das ist relevant im Zusammenhang mit:

  • allow to set minSoC to 0 with applyAction()

Dadurch wurde minSoC bei Erkennung immer auf 0 gesetzt, auch wenn OnIdentified am Fahrzeug überhaupt nicht konfiguriert war.

@andig
Copy link
Member

andig commented Nov 30, 2021

apply OnIdentify actions only when OnIdentify node is present in vehicle configuration (optional parameter)

Was willst Du hier erreichen?

Das ist relevant im Zusammenhang mit:

  • allow to set minSoC to 0 with applyAction()

Dadurch wurde minSoC bei Erkennung immer auf 0 gesetzt, auch wenn OnIdentified am Fahrzeug überhaupt nicht konfiguriert war.

Das Problem ist doch aber, dass OnIdentified in dem Fall überhaupt ausgeführt wird, nicht dass irgendwas mit minSoC passiert, oder?

Copy link
Member

@andig andig left a comment

Choose a reason for hiding this comment

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

Danke für den PR- bitte schau mal die Kommentare an. Wenn ich alles richtig verstanden habe, scheint das eine gute Präzisierung des Verhaltens zu sein- vielen Dank!

core/loadpoint.go Outdated Show resolved Hide resolved
core/loadpoint_api.go Show resolved Hide resolved
core/loadpoint_api.go Show resolved Hide resolved
cmd/dumper.go Outdated Show resolved Hide resolved
@rivengh
Copy link
Contributor Author

rivengh commented Nov 30, 2021

Dadurch wurde minSoC bei Erkennung immer auf 0 gesetzt, auch wenn OnIdentified am Fahrzeug überhaupt nicht konfiguriert war.

Das Problem ist doch aber, dass OnIdentified in dem Fall überhaupt ausgeführt wird, nicht dass irgendwas mit minSoC passiert, oder?

Da hast du Recht. Der Effekt war in diesem Fall eben nur am minSoC zu sehen.

@andig
Copy link
Member

andig commented Nov 30, 2021

allow to set minSoC to 0 with applyAction()

Ich glaube das funktioniert nicht. 0 ist der Defaultwert. ApplyAction kann nicht wissen ob der gesetzt ist oder nicht. Eine Alternative wäre, alle Einzelwerte zu Pointern zu machen und alle Vergleiche gegen nil zu machen.

@rivengh
Copy link
Contributor Author

rivengh commented Nov 30, 2021

allow to set minSoC to 0 with applyAction()

Ich glaube das funktioniert nicht. 0 ist der Defaultwert. ApplyAction kann nicht wissen ob der gesetzt ist oder nicht. Eine Alternative wäre, alle Einzelwerte zu Pointern zu machen und alle Vergleiche gegen nil zu machen.

Das wäre in der Tat noch eine Erweiterung auf die einzelnen Elemente des ActionConfig structs.
Ich wollte es erst mal nicht noch komplexer machen und habe angenommen, wenn man OnIdentified schon konfiguriert, dass man auch alle Werte davon entsprechend setzt.
Kann das aber gerne auch noch erweitern, wenn du möchtest?

Ansonsten funktioniert das Setzen auf 0 schon, da die if-Condition beim minSoC auf >= 0 abfragt.

@andig
Copy link
Member

andig commented Nov 30, 2021

Ansonsten funktioniert das Setzen auf 0 schon, da die if-Condition beim minSoC auf >= 0 abfragt.

Genau das funktioniert eben nicht (immer). Wenn ich das Feld gar nicht im YAML hab ists blöderweise auch 0.

Ich würde Vorschlagen, die Einzelwerte (alle) auf Pointer umzubauen und die Settings selbst ohne Pointer zu übergeben.

@rivengh
Copy link
Contributor Author

rivengh commented Nov 30, 2021

Ich würde Vorschlagen, die Einzelwerte (alle) auf Pointer umzubauen und die Settings selbst ohne Pointer zu übergeben.

Alles klar, das ist sicher am konsequentesten. Ich baue das dann noch um.

Danke für dein Review.

@rivengh
Copy link
Contributor Author

rivengh commented Nov 30, 2021

So, habe es jetzt nochmal umgebaut: Alle Elemente von ActionConfig sind nun Pointer und die Vergleiche in applyAction werden gegen nil gemacht. Die Settings selbst habe ich auch als Pointer drin gelassen. Fand ich jetzt ganz praktisch, wenn ich auch direkt darauf auf nil abfragen kann. Was meinst du?

cmd/dumper.go Outdated Show resolved Hide resolved
core/loadpoint.go Show resolved Hide resolved
lp.publish("targetSoC", action.TargetSoC)
lp.Unlock()
func (lp *LoadPoint) applyAction(action *api.ActionConfig) {
if action != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Ich find den doppelten Pointer merkwürdig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doppelter Pointer ist nun entfernt.

@andig
Copy link
Member

andig commented Nov 30, 2021

Das ist alles sehr unglücklich. Vmtl müssten wir die Standardkonfig auch als tristate (also mit Pointern) machen. Die würde ich aber ungern überall im Code haben. Mir fehlt grad eine gute Idee. So schein das Problem aus der letzten Überarbeiten jedenfalls immer noch vorhanden, nru diesmal von der Vehicle auf die Standardconfig verlagert.

@andig
Copy link
Member

andig commented Nov 30, 2021

…oder wir argumentieren dass das „as designed“ ist. Bin grad unsicher. Dann könnte man nur am Fahrzeug entscheiden, ob Standardwerte überschrieben werden, der Standard selbst wird aber immer wieder hergestellt.

@andig
Copy link
Member

andig commented Nov 30, 2021

Die Idee gefällt mir eigentlich gut. Bliebe also nur, das doppelte nil wieder zu beseitigen wenn Du so nett sein willst.

@rivengh
Copy link
Contributor Author

rivengh commented Nov 30, 2021

Danke Dir. Ich mache mich morgen nochmal ran.

@andig andig merged commit a45e240 into evcc-io:master Dec 1, 2021
@rivengh rivengh deleted the update-apply-action branch December 1, 2021 13:28
dontbyte pushed a commit to dontbyte/evcc that referenced this pull request Aug 2, 2022
…ngs (evcc-io#1942)

allow GetTargetSoC() and GetMinSoC() to be used even when no vehicle is connected
use SetMinSoC() and SetTargetSoC() functions in applyAction()
allow to set minSoC to 0 with applyAction()
apply OnIdentify actions only when OnIdentify node is present in vehicle configuration (optional parameter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants