jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
139 stars 19 forks source link

Sensor to detect excess PV power #212

Open JakobEgPedersen opened 9 months ago

JakobEgPedersen commented 9 months ago

It would be nice if the system had a input sensor to tell about excess power production from PV panels (export to grid) And then start charging when exporting power. This should just trigger a charge start, no matter og other settings.

RienduPre commented 9 months ago

I would like this too🤗

jonasbkarlsson commented 9 months ago

Thanks for the suggestion. There are a few complications that need to be considered.

1) The minimum current that a car can expect is 6 A. For 1-phase charging this means at least 1.4 kW, and for 3-phase charging this means at least 4.2 kW.

So I would assume that there will be a need to configure the integration with a minimum excess power production that would trigger charging. The easiest would be to be able to choose between 1,4 kW and 4.2 kW. Alternatively, to support any positive value, but to recommend 1.4 kW or 4.2 kW.

2) On days with clouds, this minimum excess power threshold might be triggered on and off very frequently. That doesn't feel like a good behaviour. And I know that there have been cars that interpret frequency starts and stops of charging as malfunction of the charger, and due to that stop further charging.

Here there are several possibilities.

Any thoughts about this?

RienduPre commented 9 months ago

In my opinion is the second option the best one, with the addition to use a entity with the average excess power over the last 10 minutes to discard high and low peaks.

janneho commented 9 months ago

In finland we have something called "tuntitase", do not know what it is in english - maybe something like hourly balance. It means, that your export and import is balanced in one hour periods (so if you export constant 1kW for hour, you can use it as you will in that 1 hour period. So it is possible that you export 1kWh, and use 10kW for 6 minutes and you do not get charged for it). That is going to change to "varttitase" - to 15minute period sometime soon.

So i think that if you have energy metering for import and export (electricity meters have had that for long time - google "han port"), you can count import and export and charge accordingly in last minutes in that hour.

jonasbkarlsson commented 9 months ago

@janneho, what you descirbe sounds very similar to the situation in Sweden. Here, export and import is measured per hour, and it's only the total of export and import that counts. That is, from a measurement point of view, you can not have both export and import during an hour. If you export 1 kWh and import 2 kWh, that will be reported as 1 kWh import (and no export). Is that what you also have in Finland?

Also, in Sweden, the cost for import and income for export is very similar, so your suggestion to "charge accordingly in last minutes in that hour" will not provide any benefits in Sweden. But maybe that is not the case in Finland?

janneho commented 9 months ago

Yes, same here. Hourly export is subtracted from hourly import and that is what you see in bill. Maybe it is nordic thing, so maybe in norway (denmark?) too.

It will change to 15 min period sometime, but i think it is when nordpool goes to 15 minutes.

EDIT. It aslo goes with phases. It does not matter if export and import is in different phases, only total counts. Earlier it was so that you could be importing on one phase and exporting on other.

EDIT 2. I meant to say, that if you can measure import/export you know how much that hour is positive or negative. If it is negative (export), then you can charge car in last minutes in that hour to get balance to zero. For example if you measure consumption for 1kWh and solar production 2kWh, you have -1kWh balance. So it is possible to start charging for last 6 minutes for that hour (at 10kW) and that balances that hour to 2kWh consumption/2kWh solar -> no import/export.

janneho commented 9 months ago

I am bad at explaining things, but this is quite good explanation LINK.

jonasbkarlsson commented 9 months ago

I understand want you mean. But it's a very specific way of controlling charging, not sure how widely it will be useful. For example, if there are places where you handle export and import totally separately.

janneho commented 9 months ago

I understand want you mean. But it's a very specific way of controlling charging, not sure how widely it will be useful. For example, if there are places where you handle export and import totally separately.

True, and it is something that does not need to be done with this integration. It can be easily do with scripts in home assistant.

But in finland, and i guess in sweden also you can use allmost all solar energy this way withput any import/export (when car is home), and charging is done at max once in every hour.

I think that to use excess solar energy one should have import and export energy sensor (sensors). I have shelly 3 em but han port in electricity meter works also. Then you have to do as i described, or if that is not ok you just can adjust caharging current so that solar excess power is zero (or.near zero}. This i think can done just as easily without this addon.

AMajland commented 7 months ago

Yes, same here. Hourly export is subtracted from hourly import and that is what you see in bill. Maybe it is nordic thing, so maybe in norway (denmark?) too.

In Denmark it largely depends on when you got your solar panels. There is only a few (compared to the total number of private solar systems) that are in group 2 where you for each hour have either an import or export. For all others you can have have both import and export in the same hours. And depending on you meter you might even have simultaneously import on one phase while exporting on another (With solar system you now have the right to get a meter that either counts import or export at any given moment - but you have to pay for the exchange yourself.......)

I have an easee home (actually two) and during the summer i have mostly charged with excess power directly from solar with a rather simple automation https://gist.github.com/AMajland/6ffc6814df2a92e99cff2c901447efee

Basically it changes between 1 and 3 phase charging depending on the 10min average surplus in one automation and then tries to match the charing current 3 x minute. It works pretty well.

But for darker month without much sun it looks like it will be rather straight forward to integrate EV Smart Charing so i don't have to reinvent the wheel.

I'll just add 4th option for smart charge to my current "EV Charge Mode" which will just start stop on - sensor.ev_smart_charging_charging from: "on" to: "off" or the opposite.

The last step will be to change automatically from Solar charging to EV smart charging based on sunset.

Cars get home late afternoon and is plugged in. If there is excess power from solar that will be used for charging. After sunset EV Smart Charge will ensure that the car is charged suffienctly for the next morning drive. (But i antisipate issues with my cars SOC missing for longer periods due to Skoda/VAG server issues .... )

AMajland commented 7 months ago

In the above i've just added an option. It does not matter that it is called 3 times a minute even trough it is overkill for this. Could jyst be triggeren on 'sensor.ev_smart_charging_charging' changing instead

' - conditions:

As suggested also added an automation to update ev_connected.

'alias: PV to EV - EV Connected description: "" trigger:

At the moment i have only one my easee home charges online and we only have one electric car. I'll deal with the complexity of more when the need arises... Unfortunately it is not possible to which car is connected to a charge and skoda_connect updates pretty slowly (if at all). That is the reason to use the sensor.CHARGER_ID_status above and not [binary_sensor.enyaq_charging_cable_locked] or [binary_sensor.enyaq_charging_cable_connected]

tubalainen commented 7 months ago

I would recommend that we keep this component "clean" and to the point.

This feature can easily be done with an automation. Here is my example, this automation is manual, hence there is ALWAYS an incentive to sell excess solar here in Sweden (because of the state providing extra pay per kW exported). If you still want to "force solar charge" i flip this input boolean.

- id: wallbox_auto_amps_solar_only
  alias: Wallbox ström laddarautomation endast solladdning
  mode: single
  max: 3
  trigger:
    - platform: numeric_state
      entity_id: sensor.p1_momentary_active
      above: 13000
    - platform: state
      entity_id: sensor.elmatare_bilen_active_power
  condition:
    - alias: "Car is charging"
      condition: state
      entity_id: switch.wallboxpulsar_charge_control
      state: "on"
    - alias: "Charge car with sun only"
      condition: state
      entity_id: input_boolean.charge_car_using_solar_only
      state: "on"
    - condition: template
      value_template: "{{ int(states('sensor.elmatare_bilen_active_power'),0) > 120 }}"
  action:
    ## My car can only do three phase 6 amps as a minimum. If I go below that the charger in the car will turn off
    - service: number.set_value
      target:
        entity_id: number.wallbox_portal_max_charging_current
      data:
        value: >
          {% set solar = int(states('sensor.ferroamp_solar_power'), 3000) | round(0) %}
          {% set lim = 11500 %}
          {% set limit = solar + lim | round(0) %}
          {% set sparsnas_car = int(states('sensor.elmatare_bilen_active_power'), 3000) | round(0) %}
          {% set ferroamp_tot = int(states('sensor.ferroamp_consumption_power'), 6000) | round(0) %}
          {% set house = ferroamp_tot - sparsnas_car | int(5000) %}
          {% set avail_pwr = solar - house | int(5000) %}
          {% if avail_pwr <=6299 %}
            6
          {% elif avail_pwr > 6300 and avail_pwr < 6899 %}
            8
          {% elif avail_pwr > 6900 and avail_pwr < 7599 %}
            10
          {% elif avail_pwr > 7600 and avail_pwr < 8299 %}
            11
          {% elif avail_pwr > 8300 and avail_pwr < 8999 %}
            12
          {% elif avail_pwr > 9000 and avail_pwr < 9699 %}
            13
          {% elif avail_pwr > 9700 and avail_pwr < 10500 %}
            14
          {% elif avail_pwr > 10501 and avail_pwr < 11000 %}
            15
          {% elif avail_pwr > 11001 %}
            16
          {% else %}
            6
          {%- endif %}

- id: reset_charge_car_on_solar
  alias: Resetta ladda bilen på solel
  mode: single
  max: 3
  trigger:
    - platform: numeric_state
      entity_id: sensor.ferroamp_solar_power
      below: 6000
      for: 00:10:00
  condition: []
  action:
    - service: input_boolean.turn_off
      target:
        entity_id: input_boolean.charge_car_using_solar_only

## Amps  Watt
## 2    1400
## 3    2100
## 4    2800
## 5    3500
## 6    4200
## 7    4800
## 8    5500
## 9    6300
## 10     6900
## 11     7600
## 12     8300
## 13     9000
## 14     9700
## 15     11000
## 
jonasgustavsson commented 7 months ago

Regarding the net hourly metering, it comes from a EU-directive, so should sooner or later apply to all EU contries if my understanding is correct. See my post here for some more details: https://community.home-assistant.io/t/energy-management-calculation-every-15-minutes/335359/5