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

Cant get dynamic limit to work #216

Open
Sleepy81 opened this issue Oct 3, 2022 · 6 comments
Open

Cant get dynamic limit to work #216

Sleepy81 opened this issue Oct 3, 2022 · 6 comments
Labels
support Support and questions

Comments

@Sleepy81
Copy link

Sleepy81 commented Oct 3, 2022

Question

Ok, so I'm trying to dynamically adjust 2 charging robots, so that the hourly consumption stays below a certain kWh during the last hour. I have figured out the trigger/condition part I think, but struggle with actually limit the chargers current draw. To do a quick test I wanted to see if I could limit the charging current of my two chargers to 6A (Which I understand is the minimum required to start the charger).

This is the code I use:

action:
  - service: easee.set_circuit_dynamic_limit
    data:
      charger_id: EHXXXXXX
      currentP1: 6
      currentP2: 6
      currentP3: 6
  - service: easee.set_circuit_dynamic_limit
    data:
      charger_id: EHXXXXXX
      currentP1: 6
      currentP2: 6
      currentP3: 6

This does not change the amount of amperes the chargers draw, and they draw whatever the cars are set to as max (24A and 12A). In the Easee app I see no change in the "Dynamic limit for Chargingrobot" which I presume should be showing 6A.

If I try the following:

action:
  - service: easee.set_charger_circuit_dynamic_limit
    data:
      charger_id: EHXXXXXX
      currentP1: 6
      currentP2: 6
      currentP3: 6
  - service: easee.set_charger_circuit_dynamic_limit
    data:
      charger_id: EHXXXXXX
      currentP1: 6
      currentP2: 6
      currentP3: 6

I do see that the "Dynamic limit for Chargingrobot" changes in the Easee app, but only if the charger is not currently charging. If it starts to charge it seems to overwrite this value, and goes to the car limit again. Also, If I run the automation while the car is charging, the charging stops, and just says "In que - Load balancing", never to start charging again.

Any Ideas as to what I'm doing wrong here?

What version of the integration are you using?

0.9.45

Anything in the logs that might be useful for us?

No response

Additional information

No response

@Sleepy81 Sleepy81 added the support Support and questions label Oct 3, 2022
@olalid
Copy link
Collaborator

olalid commented Oct 3, 2022

First, easee.set_circuit_dynamic_limit and easee.set_charger_circuit_dynamic_limit are the exact same thing in the sense that they end up calling the same API in the end.
The only difference is that with easee.set_circuit_dynamic_limit you are supposed to provide the circuit id instead of the charger id. So this is most likely why your call to easee.set_circuit_dynamic_limit does not work, your input is simply wrong. Remove charger_id and add circuit_id instead if you want to use that version of the service.
(Circuit ID can be found by looking at the attributes for the xxxx_status sensor).

Second, and here I am guessing a bit since I do not know how your system is set up, but if I assume that you have 2 chargers, both connected to the same circuit and one is set up as master and one as slave.
And, disclaimer, I do not have such a system myself so I have no actual experience about how it works.
If your system is set up differently you can stop reading here and instead tell me how it is set up so we can have a better discussion :)
In any case, What I think happens is:
The circuit limit is for the circuit (aka fuse group), so it is shared between the 2 chargers.
(Which means you do not have to set it separately for each charger, it applies to all chargers on the same circuit. The actual API call uses the circuit ID, we just translate internally from charger ID to circuit ID for user convenience).
Setting it to 6A, means you allow totally 6A for both chargers combined. I.e. that would only be enough for 1 charger to be active at 6A and the other one would need to pause since there is in fact 0A left to use. 12A would in theory allow both chargers to charge at 6A, but we have no control or knowledge about how the priority between the 2 chargers will play out, it could be that it still pauses one and allows charging on the other at 12A until that car does not need to charge anymore.
Also worth noting that there apparently are a few cars out there that require more than 6A to start charging, Renault Zoe requires 7A I believe, so it is not universally true that charing starts at 6A, but it is always true that it stops when set to 5A or lower.

Regarding that problem with limits changing when you plug in/start charging, it kind of sound like you have used the easee.set_charger_dynamic_limit service instead of easee.set_charger_circuit_dynamic_limit like you are stating above?
easee.set_charger_dynamic_limit operates on charger level instead of circuit level, and it will in fact reset when you plug in a car. The circuit limit is supposed to stay valid unless you reboot the charger basically.
So please check what it is that you have used when testing.

This is a good place to read a bit about all the different limits and which ones you are supposed to use for what: https://developer.easee.cloud/docs/current-limits-and-control

@olalid
Copy link
Collaborator

olalid commented Oct 3, 2022

Forgot to say, since you say that the limit that changes is the app is "Dynamic limit for Chargingrobot", that too points to that you have accidentally actually used the easee.set_charger_dynamic_limit service, since that would change that limit.
The limit changed by easee.set_circuit_dynamic_limit or easee.set_charger_circuit_dynamic_limit is the circuit limit. Not sure what the english translation is, but something like "Dynamic limit for circuit" and it would be shown as "6/6/6" or similar in the app, not as a single value, e.g. "6".

@Sleepy81
Copy link
Author

Sleepy81 commented Oct 5, 2022

Thanks!
Completely missed that it should be circuit_id, and not charger_id when using easee.set_circuit_dynamic_limit. Changed to circuit_id now, and now the app shows "Dynamic limit for circuit" set to 6A for both chargers. They are as you said connected to the same circuit with one master and one slave unit. Will report back when I find out how the inbuilt load balancing works with a circuit limit set below 12A, i.e. if set to for example 11A, if it uses 11A on the first car, and waits for it to be finished before charging the next car, since it cant charge both at 6A, or if it somehow accepts below 6A for one charger when the other one is in use. (So one charges at 6A and the other at 5A). I'm guessing the first logic is used, but will report back.

And for anybody else that has never set this up before, when displaying the circuit_ID in the "CHARGERNAME_sensor status" attributes, it shows with a decimal character (example 123,456). You have to remove the decimal when using it in the circuit_ID YAML script, so it will be 123456. :)

@Sleepy81
Copy link
Author

Sleepy81 commented Oct 5, 2022

Did a short test, and it seems that no matter what the dynamic limit is set to, it first charges one car, and then the other. But come to think about it, I think that was the default behavior before as well for my case, as one car charges using 3-phase, while the other charges using single phase. Think ther was an issue with Easee mixing phases simultaneously, so they instead charge in sequence. Doesn't matter much to me, as the total time to get both cars charge will be about the same anyways.

But, I thought I had a cunning plan to optimize the charging current, but alas, I have failed :)
So, this is what I'm trying to achieve:

  • I have a live feed of the total kW drawn at the main breaker (Tibber Pulse). Also, the Tibber API provides a "Estimated Consumption current hour" sensor. That sensor tries to estimate, based on the current usage, and I guess some moving averaging what the total consumption will be at the end of the hour. So, for example it says 5.3kWh, which tells Home Assistant that it guesses that at the end of the hour (for example at 21:00) the total consumption in the period from 20:00 to 21:00 will be 5,3kWh. This is important, as the tarrifs here are calculated partly by the amount of energy used per hour, an if you exceed for instance 10kWh during a single hour, you will be charged for the next tier compared to if you used 9,9 kWh in the same hour.

  • Naturally I want to charge the cars as fast as possible, but still stay within the max 10kWh per hour limit I'm aiming for. To do this I want to dynamically change the current of the car chargers based on what the rest of the house is using. So if my house is using 8kWh during a single hour, I have 2 kWh "to spare" that I want to use for charging the car.

I wrote down the following formulas:

  • 10 kWh consumption limit * 230 /1000 = should give the amount of Amperage I could draw continuously during the hour to reach a consumption og 10kWh. This equates to approx 43A.
  • I would then figure out how many Amps I have "to spare" based on the estimated consumption per hour from Tibber. So I wrote the following: "Estimated consumption current hour(kWh) / 230 *1000. This should give the average amperage pulled during the hour to reach the estimated consumption usage. So if Tibber estimates 6kWh usage, that should equate to 26A
  • Subtract 26 from 43, and that should give me 17A "to spare". This is the dynamic current limit I set in the charger circuit.

Based on this I wrote the following code, which I run once a minute:

elbil_lader_begresning:
        friendly_name: "Ladebegrensning Elbil"
        value_template: "{{ (43 - (states('sensor.estimated_consumption_current_hour") | float/230*1000)) | int }}"
        unit_of_measurement: "A"
        device_class: current

This code works, and in the example above I can see that the dynamic circuit limit is set correctly at the charger, and updates while the car charges. I would then expect to se that the "Estimated consumption current hour" would climb and approach, but never reach 10kWh. (Red line, please excuse my poor drawing skills)

However, what I see is the "Estimated consumption current hour" climb, but level of at about 7kWh. (Blue line, ignore the downward spike at approx. 1610.)

image

I am assuming my logic is faulty, but cant pinpoint what is wrong...

@olalid
Copy link
Collaborator

olalid commented Oct 6, 2022

I think what you are calculating is not the actual limit to set, but the error, i.e. how much you need to change your setting.
So if you already have set 10A charging limit and you get 17A out from your formula you should set 10+17=27A limit.
If you get a negative number it would be lowered (i.e. 10+(-5)=5A).
Then, next time you run the algorithm you should ideally get 0A out of it and no change would be needed.

I do not know how often the tibber sensor for estimated energy in current hour you are using updates, but it would not make sense to run this algoritm more often than when it updates.
It might have very long delays, I do not know.

Another way to do this is to look at power instead and keep the total power of the "house" slightly below 10kW at all times.
But that of course depends on what loads you have in your house, some other things that you can not control may consume more than 10kW and then it does not help to keep only the car charging below 10kW...

@quatrox
Copy link

quatrox commented Feb 6, 2023

@Sleepy81

10 kWh consumption limit * 230 /1000 = should give the amount of Amperage
I could draw continuously during the hour to reach a consumption og 10kWh.

That formula does not make any sense.
10000 * 230 / 1000 = 2300, not 43.
Try to add the units into your formula to see what you get.
The power, measured in Watts, is the current, measured in Ampére,
multiplied by the voltage, measured in Volts.

The power consumption is voltage multiplied by ampére, P = I * V.

Your limit is 10kWh, which means you draw 10000 W in 1 hour
(3600 seconds) on average.

Also, remember to calculate for each phase and add the numbers together.
E.g. for 3-phase:
P = I_L1 * V_L1 + I_L2 * V_L2 + I_L3 * V_L3 = I_per_phase * (V_L1 + V_L2 + V_L3)

If you have a Norwegian IT system (no dedicated neutral line), you have 115V from phase to ground.
If you, however, have a Norwegian TN system (with dedicated neutral line), you have 230V from phase to ground.

So, if you assume you have 115V on each phase (with respect to ground), you get:
P = I_per_phase * (3 * 115)

P_limit = I_per_phase * (V_per_phase / number_of_phases)
I_per_phase = P_limit / ((V_L1 + V_L2 + V_L3) / 3)
E.g:
I_per_phase = (10000 Wh / (115V + 121V + 109V)) / 3 = 9.66 A

If your limit is P_limit and you have t_seconds_remaining left of the hour, and already used P_used, then it would be:
(P_limit - P_used) * (3600 / t_seconds_remaining) = I_per_phase * (V_per_phase / number_of_phases)
I_per_phase = (P_limit - P_used) * (3600 / t_seconds_remaining) / ((V_L1 + V_L2 + V_L3) / 3)
I_per_phase [A] = 10000 [W] - P_used [W] * (3600 [s] / t_seconds_remaining [s]) / 115 [V]

As the voltage per phase tends to vary over time, you might want to add some margin.
Also note that the voltage drop in your charging cable (all the way from the breaker box), depends on how
much current you draw, so make sure to use the Voltage reported from your Tibber device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support and questions
Projects
None yet
Development

No branches or pull requests

3 participants