nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
209 stars 34 forks source link

Change MaxCircuit #120

Open MvQuast opened 3 years ago

MvQuast commented 3 years ago

Hi, first of all - thank you for creating this awesome HA integration. One thing I observed: Is it possible to programmatically change MaxCircuit?

Background: when charging from PV, I'd like to periodically adjust charged Amps according to current power overhead.

Thanks, Marcel

olalid commented 3 years ago

Hi and thank you. It is best to use dynamic circuit limit for this purpose.

Changing the max circuit limit will write to flash in the device each time, so it is not recommended to do that often because there is a risk the flash will wear out. But there are in any case services that you can use to set the current limits. easee.set_circuit_dynamic_limit or easee.set_charger_circuit_dynamic_limit (both do the exact same thing, it just the handle that is different).

MvQuast commented 3 years ago

Reason for this idea was that changing this from Easee app directly changed the max circuit limit down. Use case: when I know that my PV currently has 2 kW left, I would limit this to 10A, to avoid draining my battery.

olalid commented 3 years ago

Dynamic circuit works the same way. The lowest value of all the limits "wins". So if your max circuit limit is set to 14A and the dynamic circuit limit is set to 10A, the current will be limited to 10A.

olalid commented 3 years ago

Please close the issue if this solved your problem.

MvQuast commented 3 years ago

Hi, I modified the value within Easee App - dynamic circuit limit always stays at 40 A, no matter if I choose 15A or only 10A - so the value that can be dynamically adjusted is max_circuit_limit. (which is not the overall setup of your installation location like fuse parameters). Another challenge: no matter if we talk about Dynamic Circuit limit or Max circuit limit - it's a sensor within HASS, so it's just readable but not modifyable.

olalid commented 3 years ago

As I said above, there are services within the Easee integration in HA which you can use to set the dynamic circuit limit. (And yes, the app supports only setting the max circuit limit, but that is kind of irrelevant). Which means that to change the dynamic circuit limit you must call one of these services.

Typically you would make an automation that changes the limit when a new limit has been calculated. Something along these lines:

- id: charging_current
  alias: Set dynamic charging current
  trigger:
  - platform: state
    entity_id: sensor.allowed_current
  action:
  - service: easee.set_circuit_dynamic_limit
    data_template:
      circuit_id: 12345
      currentP1: "{{ states.sensor.allowed_current.state }}"
      currentP2: "{{ states.sensor.allowed_current.state }}"
      currentP3: "{{ states.sensor.allowed_current.state }}"
hollowboarder commented 2 years ago

As I said above, there are services within the Easee integration in HA which you can use to set the dynamic circuit limit. (And yes, the app supports only setting the max circuit limit, but that is kind of irrelevant). Which means that to change the dynamic circuit limit you must call one of these services.

Typically you would make an automation that changes the limit when a new limit has been calculated. Something along these lines:

- id: charging_current
  alias: Set dynamic charging current
  trigger:
  - platform: state
    entity_id: sensor.allowed_current
  action:
  - service: easee.set_circuit_dynamic_limit
    data_template:
      circuit_id: 12345
      currentP1: "{{ states.sensor.allowed_current.state }}"
      currentP2: "{{ states.sensor.allowed_current.state }}"
      currentP3: "{{ states.sensor.allowed_current.state }}"

Hi! Im trying to use that Code but it doesnt work with my Charger. The maximum circuit Limit doesnt change at all it always stays at 40A

Maybe the circuit id is wrong? Which id i have to use? for testing reason i try this currentP1: "{{ 10 }}" To Set it to 10A on each Phase. The Event is fired but the Charger stays always on 40A

Maybe anyone can help? Thanks

AMajland commented 2 years ago

I've done some testing today - before finding this thread, So see this a thumbs up and a confirmation that it is working ....

It seems that the Easee App uses "Max circuit limit" - (That can't be set from HA as described above)

"Dyn charger limit" works to reduce current. But only if it is set after charging has started. Otherwise the charger just said "In que - Load balancing"

The right one to use is "Dyn circuit limit". That can be set before charging has even started and will not prohibit the charger to start when a car is connected or a schedule turns it on

hollowboarder commented 2 years ago

I've done some testing today - before finding this thread, So see this a thumbs up and a confirmation that it is working ....

It seems that the Easee App uses "Max circuit limit" - (That can't be set from HA as described above)

"Dyn charger limit" works to reduce current. But only if it is set after charging has started. Otherwise the charger just said "In que - Load balancing"

The right one to use is "Dyn circuit limit". That can be set before charging has even started and will not prohibit the charger to start when a car is connected or a schedule turns it on

Hi there. Could you please share your Code of the automation? Couldnt get my Code to work.. Thanks

AMajland commented 2 years ago

So far i'm just using the charger card and their advanced example for an ease home. See https://github.com/tmjo/charger-card/issues/24

image

Been charging slowly all day to just most of my solar power instead of giving it away (the nordpool DK1 has been almost 0 all day

olalid commented 2 years ago

Ok, we should I guess provide some examples, but until then I can share how my setup looks. First I have some template sensors, one set for solar charging and one for regular (typically nightly charging). So elbil_sol_begransning_1 calculates the new limit when solar charging, and elbil_begransning_2 is just limiting the output to a value between 5 and 14A. Likewise is elbil_natt_begransning_1 and elbil_natt_begransning_2 for regular charging. Solar charging is single phase with target power 0W and regular charging is 3-phase charging with target power 9700W. "Target" means that the total house consumption should not be above that.

      elbil_sol_begransning_1:
        friendly_name: "Elbil solladdning begränsning steg 1"
        value_template: "{{ (state_attr('sensor.j21_dynamic_circuit_limit', 'state_dynamicCircuitCurrentP3') - (states('sensor.elmatare_effekt') | float/230)) | int }}"
        unit_of_measurement: "A"
        device_class: current
      elbil_sol_begransning_2:
        friendly_name: "Elbil solladdning begränsning steg 2"
        value_template: "{% if (states('sensor.elbil_sol_begransning_1') | float) < 5 %}5{% elif (states('sensor.elbil_sol_begransning_1') | float) > 14%}14{% else %}{{ states('sensor.elbil_sol_begransning_1') }}{% end\
if %}"
        unit_of_measurement: "A"
        device_class: current
      elbil_natt_begransning_1:
        friendly_name: "Elbil nattladdning begränsning steg 1"
        value_template: "{{ (state_attr('sensor.j21_dynamic_circuit_limit', 'state_dynamicCircuitCurrentP3') - (((states('sensor.elmatare_effekt') | float)-9700)/(230*3))) | int }}"
        unit_of_measurement: "A"
        device_class: current
      elbil_natt_begransning_2:
        friendly_name: "Elbil nattladdning begränsning steg 2"
        value_template: "{% if (states('sensor.elbil_natt_begransning_1') | float) < 5 %}5{% elif (states('sensor.elbil_natt_begransning_1') | float) > 14%}14{% else %}{{ states('sensor.elbil_natt_begransning_1') }}{% \
endif %}"
        unit_of_measurement: "A"
        device_class: current

Then I have a couple of automations that triggers the transfer of these values to the charger settings every 20 second. Which one of them runs depends on the state of input_boolean.billaddare_prioritet, which can manually changed between solar charging and regular charging, or it can be changed by some automation. It is a bit crude but it works reasonable well.

- id: elbil_solel_pa
  alias: Elbil solladdning på
  trigger:
  - platform: time_pattern
    seconds: "/20"
  condition:
    condition:
    - condition: state
      entity_id: input_boolean.billaddare_prioritet
      state: "off"
  action:
  - service: easee.set_charger_circuit_dynamic_limit
    data:
      charger_id: xxxxx
      currentP1: 0
      currentP2: 0
      currentP3: "{{ states('sensor.elbil_sol_begransning_2') }}"

- id: elbil_natt_pa
  alias: Elbil nattladdning på
  trigger:
  - platform: time_pattern
    seconds: "/20"
  condition:
    - condition: state
      entity_id: input_boolean.billaddare_prioritet
      state: "on"
  action:
  - service: easee.set_charger_circuit_dynamic_limit
    data:
      charger_id: xxxxx
      currentP1: "{{ states('sensor.elbil_natt_begransning_2') }}"
      currentP2: "{{ states('sensor.elbil_natt_begransning_2') }}"
      currentP3: "{{ states('sensor.elbil_natt_begransning_2') }}"
AMajland commented 1 year ago

I've been using this pretty crude and simple automation that i can easily enable with the boolean. The tlx_grida1/2/3 is simply the currents from my inverter.

But i would like to be able to pass the float instead of it being truncated to an integer

I don't have an interface to my electric meter yet, but when i do i'll like to match it as good as possible instead of using the values from the solar inverter. The Easee API takes it as floating point numbers but i'm not sure if the charger is able to adjust so accurately [https://developer.easee.cloud/reference/post_api-sites-siteid-circuits-circuitid-dynamiccurrent] It is a pulse-width signal to the car so no reason for it match integers

alias: EaseeDynamic
description: EaseeDynamic
trigger:
  - platform: time_pattern
    minutes: /1
condition:
  - condition: state
    entity_id: input_boolean.dynamic_charging
    state: "on"
action:
  - service: easee.set_charger_circuit_dynamic_limit
    data:
      charger_id: EHEEXPYG
      currentP1: "{{ ((states('sensor.tlx_grida1') | float) ) }} "
      currentP2: "{{ ((states('sensor.tlx_grida2') | float) ) }} "
      currentP3: "{{ ((states('sensor.tlx_grida3') | float) ) }} "
mode: single

`

olalid commented 1 year ago

If I remember correct the standard for car charging says you should only output PWM signals that indicate an integer amount of current and the car should also interpret it as such. So if you provide a non integer value to the API it will just be rounded to the nearest integer internally in the charger.

AMajland commented 1 year ago

You might be right but https://en.wikipedia.org/wiki/SAE_J1772 list an example of PWM of 16% beeing 9.6A

The easee api also seems to accept a double as parameter, but i do not know if it make a pwm in larger steps or how my car will respond.

AMajland commented 1 year ago

I've now gotten my second charger online - but when i set the circuit_dynamix based on charger ID it is just set for that charger and not the other on the same circuit.

Using circuit_id: instead of charger_id i got that "expected int for dictionary value @ data['circuit_id']" but as i have only one circuit i then entered 1 instead of the name. But both with 1 (and 0) i get the error "Could not find circuit 0"

olalid commented 1 year ago

The circuit id can be found under the attributes in the status sensor for each charger. You need to use that specific number, it is for sure not going to be 0 or 1 or some other low number, my chargers have circuit ids in the 18000-20000 range. Also, make sure that it is the same number on both chargers. If the numbers are different they are not correctly configured (if they are indeed connected to the same circuit). Slave chargers does not provide a circuit_current sensor, there might be other limitations that we are unaware of at the moment. I do not have that type of installation myself. I.e. it is possible that the set limit is only displayed on the master charger and not on the slaves.

In the end, it does not matter if you use the circuit id, charger id or device id to identify the limit you want to set, the same API is called in the end. The API needs the circuit id to work, we translate to circuit id if you provide something else. We just allow all 3 for convenience.

AMajland commented 1 year ago

Thankyou - was looking in the easee.cloud instead of the status entity ...

Luckily the both show the same site_id and circuit_id :-)

Tha automation for ev charging with surpluss sun still works with circuite_id instead of charger id, but the second one is not updating. image

So maybe it is just the not updating without a car connected (i still have only one ev - but gotta be prepared for the next one).

I'll have to finish up other changes to the automation to charge from the other one to test and the sun has lost its power for today. Excess will soon be less than 6A

AMajland commented 1 year ago

Moved the car arround.

It seems that the state_dynamicCircuitCurrentPx is not updated for the slave but only for the master.

The car charges fine at the calculated reduced power on the slave even trough the dynamic limit is still shown at 40A.

image

The allowed current of 6A on P1 is set by my automation. So it works but just got confused byt the limit shown as 40

AMajland commented 1 year ago

And now it says it is to low even trough is still show it at 40

image