nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
216 stars 37 forks source link

Leveraging solar panel surplus #416

Closed Bello2023 closed 3 weeks ago

Bello2023 commented 6 months ago

Question

I have an Easee Home Charging Station with Equalizer. These are connected to HA. My desire is to utilize the surplus solar energy for charging the car, but not exceeding what is generated. So, the amount typically fed back into the grid should now be directed towards charging the vehicle. For example, if I'm feeding back 6 kW, then the charging station should provide 6 kW to the car. Is there a setting in HA that allows me to control the charging station's capacity?

What version of the integration are you using?

Easee Home

Anything in the logs that might be useful for us?

No response

Additional information

No response

olalid commented 6 months ago

First option is to use the surplus energy setting in the easee app (this setting can not be controlled from the HA integration unfortunately since there is no publicly known api for it). The other option is to use the easee.set_circuit_dynamic_limit service in some automation and set it such that the export/import of power is close to zero. There are some other discussions about this if you look through the issues the support issues.

celodnb commented 6 months ago

I have been doing this very thing at home for just over a year now (an Easee home chargebox with Huawei solar panel and 5kWh battery). I'll post the way I have done it, and how it works for me, but I have likely done it in a very complicated way, so I'd love to hear if anyone else has an alternative way of doing it.

When I first started, I made a basic template to calculate the surplus number of amps I had available to charge with, which could be fed into the car. I also wanted to ensure that HA would automatically change the Easee charger from single to three phase, and of course, I only ever want to use surplus solar, and minimize charging from the electricity grid, unless I specifically chose to (usually at night during the winter months, or if there is not enough sun, then find the cheapest time during the day).

Basic surplus amps calc is as follows:

#Charging current
  - platform: template
    sensors:
      charging_current:
        friendly_name: Charging current
        value_template: "{{ (((states('sensor.power_meter_active_power') | float(0) ) + (states('sensor.car_charger_power') | float(0) ) + (states('sensor.battery_charge_discharge_power') | float(0) )) / (0.23) + (0.5) | float(0) ) | round(0) }}"
        icon_template: mdi:current-ac
        unit_of_measurement: A

This sensor can then be used in automations, to control the easee.set_circuit_dynamic_limit service. However, I found that if I use this value directly, it can cause some minor issues with the charger. On sunny days, there is no problem, however, if you have a day where you have some cloud cover, and the charging current value keeps changing between values that are over 6A, and below 6A, this of course stops and starts the charger all the time, and after a few times, I find the charger just decides to stop charging anymore. So what I did, was I used the HACS average sensor integration to create an average value for the charging current. This effectively removes the sudden changes in the charging current value, helping to prevent the sudden changes from over 6A and below 6A, keeping the charger charging. It can be found here:

https://github.com/Limych/ha-average/tree/2.3.4

And here's my average sensor:

#Average charging current
  - platform: average
    name: 'Charging current average 5 mins'
    duration:
      minutes: 5
    entities:
      - sensor.charging_current

This is the value I then used in my automations to control the easee.set_circuit_dynamic_limit service.

stefan240987 commented 6 months ago

I have been doing this very thing at home for just over a year now (an Easee home chargebox with Huawei solar panel and 5kWh battery). I'll post the way I have done it, and how it works for me, but I have likely done it in a very complicated way, so I'd love to hear if anyone else has an alternative way of doing it.

When I first started, I made a basic template to calculate the surplus number of amps I had available to charge with, which could be fed into the car. I also wanted to ensure that HA would automatically change the Easee charger from single to three phase, and of course, I only ever want to use surplus solar, and minimize charging from the electricity grid, unless I specifically chose to (usually at night during the winter months, or if there is not enough sun, then find the cheapest time during the day).

Basic surplus amps calc is as follows:

#Charging current
  - platform: template
    sensors:
      charging_current:
        friendly_name: Charging current
        value_template: "{{ (((states('sensor.power_meter_active_power') | float(0) ) + (states('sensor.car_charger_power') | float(0) ) + (states('sensor.battery_charge_discharge_power') | float(0) )) / (0.23) + (0.5) | float(0) ) | round(0) }}"
        icon_template: mdi:current-ac
        unit_of_measurement: A

This sensor can then be used in automations, to control the easee.set_circuit_dynamic_limit service. However, I found that if I use this value directly, it can cause some minor issues with the charger. On sunny days, there is no problem, however, if you have a day where you have some cloud cover, and the charging current value keeps changing between values that are over 6A, and below 6A, this of course stops and starts the charger all the time, and after a few times, I find the charger just decides to stop charging anymore. So what I did, was I used the HACS average sensor integration to create an average value for the charging current. This effectively removes the sudden changes in the charging current value, helping to prevent the sudden changes from over 6A and below 6A, keeping the charger charging. It can be found here:

https://github.com/Limych/ha-average/tree/2.3.4

And here's my average sensor:

#Average charging current
  - platform: average
    name: 'Charging current average 5 mins'
    duration:
      minutes: 5
    entities:
      - sensor.charging_current

This is the value I then used in my automations to control the easee.set_circuit_dynamic_limit service.

Why do you divide with 0.23 + 0.5 for the surplus amps?

celodnb commented 6 months ago

I have been doing this very thing at home for just over a year now (an Easee home chargebox with Huawei solar panel and 5kWh battery). I'll post the way I have done it, and how it works for me, but I have likely done it in a very complicated way, so I'd love to hear if anyone else has an alternative way of doing it. When I first started, I made a basic template to calculate the surplus number of amps I had available to charge with, which could be fed into the car. I also wanted to ensure that HA would automatically change the Easee charger from single to three phase, and of course, I only ever want to use surplus solar, and minimize charging from the electricity grid, unless I specifically chose to (usually at night during the winter months, or if there is not enough sun, then find the cheapest time during the day). Basic surplus amps calc is as follows:

#Charging current
  - platform: template
    sensors:
      charging_current:
        friendly_name: Charging current
        value_template: "{{ (((states('sensor.power_meter_active_power') | float(0) ) + (states('sensor.car_charger_power') | float(0) ) + (states('sensor.battery_charge_discharge_power') | float(0) )) / (0.23) + (0.5) | float(0) ) | round(0) }}"
        icon_template: mdi:current-ac
        unit_of_measurement: A

This sensor can then be used in automations, to control the easee.set_circuit_dynamic_limit service. However, I found that if I use this value directly, it can cause some minor issues with the charger. On sunny days, there is no problem, however, if you have a day where you have some cloud cover, and the charging current value keeps changing between values that are over 6A, and below 6A, this of course stops and starts the charger all the time, and after a few times, I find the charger just decides to stop charging anymore. So what I did, was I used the HACS average sensor integration to create an average value for the charging current. This effectively removes the sudden changes in the charging current value, helping to prevent the sudden changes from over 6A and below 6A, keeping the charger charging. It can be found here: https://github.com/Limych/ha-average/tree/2.3.4 And here's my average sensor:

#Average charging current
  - platform: average
    name: 'Charging current average 5 mins'
    duration:
      minutes: 5
    entities:
      - sensor.charging_current

This is the value I then used in my automations to control the easee.set_circuit_dynamic_limit service.

Why do you divide with 0.23 + 0.5 for the surplus amps?

Hi Stefan, the various sensors in the calculations give me the amount of surplus watts there are available for charging. This is then multiplied by 0.23 to give the number of amps (amps is A = W x V, where the 0.23 is 230 volts).

The extra 0.5 was just a bias to boost the about up to the nearest amp. Is not necessary though :-)

wilderbridge commented 5 months ago

For anyone interested I've reverse engineered the surplus API:

The URL is https://api.easee.com/cloud-loadbalancing/equalizer/<equalizer ID>/config/surplus-energy

where response is {"mode":"chargingWithImport","chargingWithImport":{"eligible":true,"maximumImportAddedCurrent":3}}

POSTing '{"mode":"chargingWithImport","chargingWithImport":{"eligible":true,"maximumImportAddedCurrent":6}}' to the same URL will result a response 202 and surplus parameters are updated.

Setting maximumImportAddedCurrent to 0 will result charging only from surplus. The mode would still be chargingWithImport.

Disabling the surplus charging: {"mode":"none","chargingWithImport":{"eligible":true,"maximumImportAddedCurrent":0}}

I've no idea about the rate limits but would assume some exists.

wilderbridge commented 5 months ago

Hacked pyeasee and easee_hass to add a service command to this and it works perfectly.

Is this project up for non-public APIs? If so, I can submit PRs probably next week.

olalid commented 5 months ago

Good question, this would be the first occasion where we needed to resort to using undocumented features to implement something, although there is always a certain amount of trial and error with the Easee API. I have asked Easee if they can provide info on an API for it, but have not gotten any response. So in absence of a reply I guess we could do it.

If you want to provide PRs please do and we will take it from there.

Peethiplatsch commented 3 months ago

Hi, so far the integration works fine and I like that you can use the API calls to automate the wallbox. I might consider not using EVCC in the end :D My question here would be, why is the API call for the 3/1 phase switch not implemented? Is there a reason for? Because this would help to charge the car with less energy then 3 phase 6A, since you can go down to 1 phase 6A. The API call would be: limitToSinglePhaseCharging (boolean | null) https://developer.easee.com/reference/post_api-chargers-chargerid-settings

olalid commented 3 months ago

There is no need to use that configuration, you can just set the limits for two of the phases to 0 and one to 6 or more and the charger will switch to single phase charging. Then you can also control which phase it uses.

Peethiplatsch commented 3 months ago

Haha that was too easy 😅 thanks a lot, sounds smart. I need to play around with it the next days.

HolgerMiara commented 3 months ago

Hi both, Just reading your latest exchange, I would actually find it interesting to let the charger / the equalizer choose the phase with the lowest load for single phase charging. I remember having read somewhere that the Equalizer (?) would provide such a functionality in case of single phase charging, but I forgot where.

Peethiplatsch commented 3 months ago

Hi Holger, the charger itself can't do this as far as I am aware since it can't measure the load per phase within the house. The Equalizer uses a meter to measure the actual load per phase.

But I have another stupid question. When I send a command to the car, I can choose different A per phase and also chose to use 1, 2 or all three phases.

  1. Is it possible to use P1 = 10A, P2 = 6A and P3=16A - Not really a usecase, but out of curiosity. Or needs the car inverter the A at a similar level?
  2. Since I could turn off P2 or P3, is it possible to only turn off one phase and send load on 2 phases to the car?
  3. Both questions would allow a very granular load management to shave the PV surplus very close :)
olalid commented 3 months ago

@HolgerMiara fair point, there could be a use-case for this, we should look in to adding that feature. I believe your are right that it will check for lowest A as reported by the equalizer when it starts. It will not switch over to another phase once it has started though.

olalid commented 3 months ago

@Peethiplatsch

Not sure what you mean by sending different current limits to the car, are you using an API for your car to do that? Or how do you see that happening?

  1. When it comes to Easee and all other "chargers" that follows the standards for AC charging, there is a single PWM signal that goes from the "charger" to the car that signals the current limit. So that limit is applied to all of the phases. When it comes to limits and Easee the rule is that lowest wins. If you tell it that it can use 10, 6 and 16A as in your example it will signal 6A. Anything lower that 6A means charging is not allowed.
  2. Not really, there is only 3 and 1 phase modes. But in IT-nets (i.e. electrical grids with 3 phases without neutral) a 3-phase car can if supports it charge on 2 phases, but then it uses one of the phases as if it was a neutral. If you do not live in Norway or Belgium you will not come across this :)
  3. Yes, I do this in my home, I charge in 1-phase mode at day when the solar panels produce electricity and charge in 3-phase mode at night when the price is low. If you have a large solar panel installation it could make sense to switch to 3-phase when the production is big enough, but it takes a little time to switch between them, so it is not always worthwhile.
Peethiplatsch commented 3 months ago

Just as an update, if interesting :). I tried setting two phases to 0 and that worked if I pause and restart the charging session. So that is cool. Thanks a lot. Also thanks a lot for your long answer.

  1. I also read that the smallest phase sets the current limit for all phases today on the Easee website. I didn't know that before, and the question came to me when I saw that you can set different current limits within the "set circuit dynamic limit" action.
  2. Funny that it is possible in Norway and Belgium, so doesn't apply to me here in Denmark ^^
  3. That will also be my plan. On sunny days, I could easily take the three phase mode with the PV system. But I think, as you wrote need to consider the slow switching between modes and also that the car doesn't like quick start and stop actions.
olalid commented 2 months ago

Work in progress for pyeasee: https://github.com/nordicopen/pyeasee/pull/102

olalid commented 2 months ago

@Peethiplatsch Regarding Norway and Belgium, it is not that "it is possible" there, they just have a different electric grid in some places (usally older parts of the grid), where the voltage is 230V between phases and no neutral. While almost everywhere else in europe you have 400V between phases and 230V between phase and neutral. When a car that supports 3-phase charging is connected to such an electrical grid it can usually only charge from 2 phases since the first phase is connected to the neutral of the type 2 connector. The charger itself is not doing anything to make this happen it is just how those cars work under those circumstances.

olalid commented 1 month ago

Surplus energy settings included in this PR, but it is still work in progress: https://github.com/nordicopen/easee_hass/pull/483

olalid commented 1 month ago

Version with support for setting the surplus charging settings through a service is now released.