Evcc Binding - electric vehicle charging control BETA [3.3.0;4.0.0)

Unsure about your understanding here.
“decimal type commands which use a dimension” are not decimal type commands, it’s a command fired at a QT item and includes value plus unit.

If you meant to say a “decimal type commands which DO NOT use a dimension” and send to a QT item that does not have a unit set so far, this patch (only if installed of course, it’s brand new) will set that item’s unit. If it already has a unit, that’ll remain and the value is updated.

That’s what I meant, thanks for the explanation.
Anyway, I’ll provide a fix that extends the accepted command types.

Well, of course it’ll replace value and unit with what’s sent.

1 Like

Hi Florian,

I did the addon update and tried your fix. Hope all I did was correct because I never worked with pre-released addons.

Just to make sure the installation worked I did:

openhab> bundle:list | grep evcc
288 │ Active │  80 │ 3.4.0.202211281648     │ openHAB Add-ons :: Bundles :: evcc Binding

Looks good to me. After that, I looked for the item config:

Number:ElectricCurrent   EVCC_Loadpoint0_MaxCurrent                 "Loadpoint0 max current"                  {channel="evcc:device:4d99bcba7d:loadpoint0#maxCurrent"}

Then I tried to change the item:

EVCC_Loadpoint0_MaxCurrent.sendCommand(9)

Log says:

2022-11-28 19:59:10.950 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Handling command 9 A (class org.openhab.core.library.types.QuantityType) for channel evcc:device:4d99bcba7d:loadpoint0#maxCurrent
2022-11-28 19:59:10.962 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - POST http://192.168.XXX.XXXX:7070//api/loadpoints/0/maxcurrent/9 - 
2022-11-28 19:59:10.964 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Running refresh job ...
2022-11-28 19:59:10.978 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - GET http://192.168.XXX.XXX:7070//api/state - {"result":{"auth":{"vehicles":null},"batteryConfigured":false,"bufferSoC":0,"currency":"EUR","gridConfigured":false,"homePower":0,"loadpoints":[{"chargeCurrent":0,"chargeCurrents":[0,0,0],"chargeDuration":0,"chargePower":0,"chargeTotalImport":1129.8545230555542,"chargedEnergy":29927.087783813477,"charging":false,"connected":false,"connectedDuration":9223372036854775807,"enabled":false,"maxCurrent":16,"minCurrent":6,"minSoC":0,"mode":"pv","phaseAction":"inactive","phaseRemaining":0,"phasesActive":3,"phasesConfigured":3,"phasesEnabled":0,"pvAction":"inactive","pvRemaining":0,"targetSoC":100,"targetTime":null,"targetTimeProjectedStart":null,"title":"Wallbox","vehicleDetectionActive":false}],"prioritySoC":0,"pvConfigured":true,"pvPower":0,"residualPower":0,"savingsAmount":10.443100604140174,"savingsEffectivePrice":0.19741133258100965,"savingsGridCharged":54.327210927865856,"savingsSelfConsumptionCharged":47.4686391097281,"savingsSelfConsumptionPercent":46.631212463177604,"savingsSince":1667468807,"savingsTotalCharged":101.79585003759396,"siteTitle":"Home","sponsor":"XXX","tariffFeedIn":0.08,"tariffGrid":0.3,"vehicles":["unavailable"],"version":"0.108.2"}}
2022-11-28 19:59:10.980 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Found 1 loadpoints on site Home.
==> /var/log/openhab/events.log <==
2022-11-28 19:59:10.928 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'EVCC_Loadpoint0_MaxCurrent' received command 9
2022-11-28 19:59:10.934 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'EVCC_Loadpoint0_MaxCurrent' predicted to become 9
2022-11-28 19:59:10.949 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EVCC_Loadpoint0_MaxCurrent' changed from 16 to 9
2022-11-28 19:59:11.017 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EVCC_Loadpoint0_MaxCurrent' changed from 9 to 16

After that I tried it with no unit:

Number   EVCC_Loadpoint0_MaxCurrent                 "Loadpoint0 max current"                  {channel="evcc:device:4d99bcba7d:loadpoint0#maxCurrent"}

Command:

EVCC_Loadpoint0_MaxCurrent.sendCommand(9)

Logging:

2022-11-28 20:01:30.929 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Handling command 9 A (class org.openhab.core.library.types.QuantityType) for channel evcc:device:4d99bcba7d:loadpoint0#maxCurrent
2022-11-28 20:01:30.942 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - POST http://192.168.XXX.XXX:7070//api/loadpoints/0/maxcurrent/9 - 
2022-11-28 20:01:30.945 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Running refresh job ...
2022-11-28 20:01:30.959 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - GET http://192.168.XXX.XXX:7070//api/state - {"result":{"auth":{"vehicles":null},"batteryConfigured":false,"bufferSoC":0,"currency":"EUR","gridConfigured":false,"homePower":0,"loadpoints":[{"chargeCurrent":0,"chargeCurrents":[0,0,0],"chargeDuration":0,"chargePower":0,"chargeTotalImport":1129.8545230555542,"chargedEnergy":29927.087783813477,"charging":false,"connected":false,"connectedDuration":9223372036854775807,"enabled":false,"maxCurrent":16,"minCurrent":6,"minSoC":0,"mode":"pv","phaseAction":"inactive","phaseRemaining":0,"phasesActive":3,"phasesConfigured":3,"phasesEnabled":0,"pvAction":"inactive","pvRemaining":0,"targetSoC":100,"targetTime":null,"targetTimeProjectedStart":null,"title":"Wallbox","vehicleDetectionActive":false}],"prioritySoC":0,"pvConfigured":true,"pvPower":0,"residualPower":0,"savingsAmount":10.443100604140174,"savingsEffectivePrice":0.19741133258100965,"savingsGridCharged":54.327210927865856,"savingsSelfConsumptionCharged":47.4686391097281,"savingsSelfConsumptionPercent":46.631212463177604,"savingsSince":1667468807,"savingsTotalCharged":101.79585003759396,"siteTitle":"Home","sponsor":"XXX","tariffFeedIn":0.08,"tariffGrid":0.3,"vehicles":["unavailable"],"version":"0.108.2"}}
2022-11-28 20:01:30.962 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Found 1 loadpoints on site Home.
==> /var/log/openhab/events.log <==
2022-11-28 20:01:30.910 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'EVCC_Loadpoint0_MaxCurrent' received command 9
2022-11-28 20:01:30.916 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'EVCC_Loadpoint0_MaxCurrent' predicted to become 9
2022-11-28 20:01:30.936 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EVCC_Loadpoint0_MaxCurrent' changed from 16 to 9
2022-11-28 20:01:31.027 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EVCC_Loadpoint0_MaxCurrent' changed from 9 to 16

Hope this helps you. Thank you!
Jens

You installed the addon correctly, but I have just noticed that your host configuration is wrong,

Seems like your host configuration ends with a slash /, but it isn’t supposed to. This is the reason why the command API requests to evcc are failing. Can you please remove the slash from the end of your host configuration?

I will improve the binding to also accept a slash, but for testing it would be nice if you could just remove it.

Oh wow, that’s it. I just removed the slash and tried again:

2022-11-28 22:02:41.910 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Handling command 9 A (class org.openhab.core.library.types.QuantityType) for channel evcc:device:4d99bcba7d:loadpoint0#maxCurrent
2022-11-28 22:02:41.924 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - POST http://192.168.XXX.XXX:7070/api/loadpoints/0/maxcurrent/9 - {"result":9}
2022-11-28 22:02:41.926 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Running refresh job ...
2022-11-28 22:02:41.933 [TRACE] [ab.binding.evcc.internal.api.EvccAPI] - GET http://192.168.XXX.XXX:7070/api/state - {"result":{"auth":{"vehicles":null},"batteryConfigured":false,"bufferSoC":0,"currency":"EUR","gridConfigured":false,"homePower":0,"loadpoints":[{"chargeCurrent":0,"chargeCurrents":[0,0,0],"chargeDuration":0,"chargePower":0,"chargeTotalImport":1129.8545230555542,"chargedEnergy":29927.087783813477,"charging":false,"connected":false,"connectedDuration":9223372036854775807,"enabled":false,"maxCurrent":9,"minCurrent":6,"minSoC":0,"mode":"pv","phaseAction":"inactive","phaseRemaining":0,"phasesActive":3,"phasesConfigured":3,"phasesEnabled":0,"pvAction":"inactive","pvRemaining":0,"targetSoC":100,"targetTime":null,"targetTimeProjectedStart":null,"title":"Wallbox","vehicleDetectionActive":false}],"prioritySoC":0,"pvConfigured":true,"pvPower":0,"residualPower":0,"savingsAmount":10.443100604140174,"savingsEffectivePrice":0.19741133258100965,"savingsGridCharged":54.327210927865856,"savingsSelfConsumptionCharged":47.4686391097281,"savingsSelfConsumptionPercent":46.631212463177604,"savingsSince":1667468807,"savingsTotalCharged":101.79585003759396,"siteTitle":"Home","sponsor":"XXX","tariffFeedIn":0.08,"tariffGrid":0.3,"vehicles":["unavailable"],"version":"0.108.2"}}
2022-11-28 22:02:41.935 [DEBUG] [ab.binding.evcc.internal.EvccHandler] - Found 1 loadpoints on site Home.
==> /var/log/openhab/events.log <==
2022-11-28 22:02:41.895 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'EVCC_Loadpoint0_MaxCurrent' received command 9
2022-11-28 22:02:41.898 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'EVCC_Loadpoint0_MaxCurrent' predicted to become 9
2022-11-28 22:02:41.922 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EVCC_Loadpoint0_MaxCurrent' changed from 16 A to 9 A

Everything works fine. I also tried to change the mode and it works.

Thanks alot!

1 Like

TBH I’ve also missed that in all your previous logs.
FYI I will also add support for URLs ending with a slash / to evcc, it is just a oneliner.

Is there a reason to maintain this binding published in the marketplace while it is now part of the official distribution? I see potential confusion for users.

Yes and no. Normally, there is no reason that it is published here, but in the case that I a bug is found that breaks the binding, I can publish a fix here much faster than the next openHAB release comes.
Note that I did not set the binding to published.

Perfectl Sorry I thought it was still published and available.

In an GitHub issue I was informed that the binding is not able to control evcc 0.111.1, I have just pusblished a fixed release here on the marketplace.

To install it on your openHAB instances, you have to go to Settings → Community Marketplace → Show unpublished entries and enable it.

Fwiw maybe worth mentioning in the binding docs that openHABian has an option to install EVCC before anyone interested embarks on getting hardware for it.

Please have a look at my PR, I‘ve added a note but feedback or alternative texts are very welcome.

Thanks Florian.
Tried to install marketplace binding but Im getting :
image
Anything that I maybe missed? Logs dont tell me what went wrong.

Oh which openHAB version are you?

It’s 3.4.1
Seems marketplace binding URL is broken.
Did manual install and got it to work on my system.
Also implemented API fixes looks promising. Thanks for the effort Florian

1 Like

3.4.1.
I got binding from git and put it to addons folder, which worked for me. Finally
Seems link to jar is broken in marketplace

The broken marketplace link was my fault, sorry - I corrected it.

New finding(s):

  1. prioritysoc
    Seems prioritysoc is not functioning as expected - or I do not fully understand its purpose resp. behavior in this binding.
    This channel value follows home battery Soc in any case. Changing value thru setpoint is not respected.
    Manually setting works:

curl -X POST http://localhost:7071/api/prioritysoc/50

API response is successful
{"result":50}

Possibly this one?: openhab-addons/EvccHandler.java at f808edf725bf52942245ba2033b529a5e0b1ba3b · florian-h05/openhab-addons · GitHub

  1. Vehicle Battery Capacity
    Vehicle Battery comes as kWh. This binding interprets it as Wh.
    /api/state returns “vehicleCapacity”:64

  2. Active Phases
    Channel (:loadpoint0#activePhases (Number)) always is 0
    /api/state returns “phasesActive”:3

@florian-h05
is it possible to add the “buffersoc” and “bufferstartsoc” endpoint in the next release? i can`t find it in the current binding. Here is the doc from evcc:

POST /api/buffersoc/<soc>`: battery buffer SoC in %
POST /api/bufferstartsoc/<soc>: battery buffer start SoC in %