based on this topic I got the balancing working.
Got 2 questions:
3 phase loading at 6A is 4100 W, but if I single phase load i’m not pushing back solar on 2 phases and using the net on 1 phase.
I’d like to put load balancing per phase, having different Ampere per phase.
I see modbus adresses per phase, but I’m not sure if this is possible / good for the car or not:
example:
Phase 1: 6A
Phase 2: 9A
Phase 3: 5A (not used as below 6A)
I have an alfen station with removable cable, but i mostly leave it plug in. To start a new sessions, the alfen pole required the cable to be removed from the pole, as it’s in status “B1”. Through backoffice you can do a soft status reset, does anyone know if/how we can do a CS reboot (or status reset) through either Modbus or Homeassistant?
Do you have any info on how the P1 load balancing works?
In general, it will of course charge the car with the “excess/injection”, but how does it react in the following situations?
Not enough injection continuously
The minimum required charge for my car is 1300 W. In winter, when I do not have a continuous minimum of 1300 W injection, it would nearly never start charging my car or continuously start/stop. Therefore, I created a script that always charges at min. 1300 W and it increases when (occasionally) I have some more injection. But, it will never stop charging, only when the target SOC is reached.
I call this the “start now mode” (min. 1300 W + solar excess)
Enough injection
When I have enough injection (1300 W) during 5 minutes, I start charging the car. The 5 minutes is to avoid that it starts charging just the first moment that it reaches this 1300 W (maybe followed by a drop). Then, every minute, I check if there is still enough injection. If not enough injection, it will stop charging the car. If there is more injection than before, it even increases the power of the car charger.
To avoid that it stops when it does not have 1300 W, I added a “buffer” of 300 W, meaning that it will not stop charging if there is only 1000 W injection; it can consume max. 300 W from the grid. The reasoning is that it is economically more interesting to put your own solar energy in your car (1000 W) than to sell this 1000 W to the grid for only a few €. The cost of (temporarily) using 300 W from the grid is just a small cost that allows you to continue to charge the car with solar. In addition, this makes that the car does not stop charging that often. It only stop charging when there is less than 1000 W injection. Of course, you can change the buffer to your preferences.
I call this the “solar charging mode” (sun + max. 300 W grid consumption)
As you see, when you manage the power of your car charger by yourself instead of the P1, you can manage all the situations to your own preference.
I really wonder how the Alphen reacts to the P1 active load balancing.
This is part of the solution. I won’t post the complete configuration in this thread, because this topic is about the Alfen charger and TCP modbus. There are other threads on charging on solar excess power.
These are 2 automations. The first to start the “sun only charging”.
The second to adjust every minute when the sun only charging is busy.
The scripts define the wattage for the car charger and then send it via scripts to the charger.
I also send a notification to my phone when it starts and stops charging. It helps me to debug also.
I can probably simplify the automations (eg. leave some conditions out).
I also use quite a lot of helpers:
input_number.car_charge_sun_start_wattage: the -1300 W required to start charging the car
input_boolean.car_charge_mode_sun: toggle to choose the sun only mode
input_boolean.car_charge_sun_busy: toggle to keep track if the sun charging mode is on or not
and some sensors:
sensor.net_power: gives the grid consumption or injection in Watt
sensor.charger_real_power: the current wattage of the car charger
- alias: "🚗 car 1 // 🔋 charge // mode sun // start - als er voldoende injectie is"
id: 'fff013ea-12e1-427f-8283-617a0f2e94ad'
description: ''
# start when the wattmater is below the number defined in input_number.car_charge_sun_start_wattage
trigger:
- platform: time_pattern
minutes: /1
- platform: numeric_state
entity_id: sensor.net_power
below: input_number.car_charge_sun_start_wattage
for: "00:05:00"
condition:
- condition: numeric_state
entity_id: sensor.net_power
below: input_number.car_charge_sun_start_wattage
- condition: or
conditions:
- condition: state
entity_id: sensor.charger_status
state: 'connected'
- condition: state
entity_id: sensor.charger_status
state: 'charging'
- condition: state
entity_id: input_boolean.car_charge_mode_sun
state: 'on'
- condition: state
entity_id: input_boolean.car_charge_sun_busy
state: 'off'
action:
# toggle the switches to keep track of the status
- service: input_boolean.turn_on
data: {}
target:
entity_id:
- input_boolean.car_charge_sun_busy
- input_boolean.car_charge_busy
# define charger Watt based on injection
- service: input_number.set_value
target:
entity_id: input_number.car_charger_watt
data:
value: >-
{% set charger = states('sensor.charger_real_power') | float(default=0) / 1000 %}
{% set maxpower = states('input_number.car_charge_minimum_wattage') | float(default=0) %}
{% set net = states('sensor.net_power') | float(default=0) %}
{% if net + charger < maxpower %}
{{ [(-net + charger) / 1000, maxpower] | max }}
{% elif net + charger > maxpower %}
{{ maxpower }}
{% endif %}
- wait_template: ''
timeout: '00:00:05'
- service: script.charger_define_phase_1_or_3_based_on_watt
- service: script.charger_define_ampere_based_on_watt
- service: script.charger_define_and_write_register_based_on_ampere
- service: notify.bart_phone
data:
title: Auto is gestart met laden op zonne-energie
message: >
Zon nu {{ states('sensor.solar_power')}} W | Net: {{ states('sensor.net_power')}} W | Auto laadt nu aan {{states('input_number.car_charger_watt') | round(1)}} kW<br>
Auto: {{states('sensor.car_1_soc') | round()}}%. Doel: {{ states('input_number.car_charge_target_percentage') | round(0)}}%
data:
tag: car_charging_sun
color: green
notification_icon: "mdi:car-electric"
actions:
- action: URI
title: meer info
uri: /dashboard-car/car-charging
mode: single
- alias: "🚗 car 1 // 🔋 charge // mode sun // bezig - check elke minuut tijdens zonneladen"
id: '258101bc-919c-4944-96e4-bb290cbe8922'
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: state
entity_id: input_boolean.car_charge_mode_sun
state: 'on'
# only if charger cable is connected to home charger or already charging
- condition: or
conditions:
- condition: state
entity_id: sensor.charger_status
state: 'connected'
- condition: state
entity_id: sensor.charger_status
state: 'charging'
# only when sun is up
- condition: state
entity_id: sun.sun
state: above_horizon
# only if charging is busy in sun mode
- condition: state
entity_id: input_boolean.car_charge_sun_busy
state: 'on'
action:
- if:
- condition: template
value_template: "{{ wattage > 1300 }}"
then:
- service: input_number.set_value
target:
entity_id: input_number.car_charger_watt
data:
value: >-
{% set charger = states('sensor.charger_real_power') | float(default=0) / 1000 %}
{% set net = states('sensor.net_power') | float(default=0) %}
{{ wattage / 1000 }}
- wait_template: ''
timeout: '00:00:05'
- service: script.charger_define_phase_1_or_3_based_on_watt
- service: script.charger_define_ampere_based_on_watt
- service: script.charger_define_and_write_register_based_on_ampere
else:
- service: script.stop_charger
data: {}
# wait 5 minutes to avoid too frequent start/stop = result in charging faillure
- service: notify.bart_phone
data:
title: Zonneladen gestopt
message: >
Zon: {{ states('sensor.solar_power')}} W | Net: {{ states('sensor.net_power')}} W | Auto: {{states('input_number.car_charger_watt') | round(1)}} kW<br>
Nu: {{states('sensor.car_1_soc') | round()}}%.
- wait_template: ''
timeout: '00:05:00'
variables:
wattage: >
{% set charger = states('sensor.charger_real_power') | float(default=0) %}
{% set maxpower = states('input_number.car_charge_sun_max_netwattage') | float(default=0) %}
{% set net = states('sensor.net_power') | float(default=0) %}
{{ - (net - maxpower - charger) }}
mode: single
Hi Tnx for the modbus read codes…
I would like to read the total charged by charger into HA
I believe it would be this code added to the configuration.yaml
But I get a NaN on the sensor… al the rest is working fine.
Anyone know’s what the problem is
(I would also like to convert it to kWh so a “scale: 0.001” would also be added, but I would like to have it working)
Is the alfen HA integration still maintained. The code does not allow to add a charger anymore. Always reults in an error (see earlier post). The github repo does not allow to post issues.
When I add this to my configuration.yaml I get the error that this entity had no unique ID. I have solved this by setting unique_id manually but still I’m not seeing any data on the energy dashboard. Even when I switch from day to week or month. When I add laadpaal_energy_delivered_sum_1 to an entity card on my dashboard it show a good value. Any ideas?
hmm not really to be honest. I have pasted my complete configuration for the chargepoint in the first post of this thread. Maybe there is something missing in your configuration, can you compare yours to what I posted?
Hi stefaan…
I installed it last week, but I went back to modbus read and I disabled the integration.
I have troubles with my EMS and the modbusread so I went back to this integration.
I could not add a new charger, but then I realised that the previous integration was disabled.
So I enabled it and the integration works fine.
Hi,
Last couple of days, I’ve been trying to get this to work for my own Alfen Single Eve Pro charger.
I imported the flow made by Luuk and adjusted it for my just 1 phase installation.
At the end of the flow, there the Node to set the values to write to the Modbus:
msg.payload = {
value: msg.payload,
‘fc’: 16,
‘unitid’: 1,
‘address’: 1210,
‘quantity’: 2
}
return msg
When I try this in a simple flow to test the Modbus to the Alfen, I keep getting the following error:
“Error: Quantity should be less or equal to register payload array length: 32 Addr: 1210 Q: 2”
Thanks for the reply.
Seemed that I copied too little of Luuk’s code.
I now don’t have an error anymore, but the payload still is not complete, since I don’t see any current values changing on the Alfen charger.
Could not find the answer to my question in this thread:
I have set my Alfen to Energy Management System as datasource, I can succesfully read values from the charger in HA with modbus.
I want the charger to do the Active Loadbalancing. For this the charger needs P1 data. Since you cannot have EMS and P1 active, the charger needs to get this information from the EMS (HA > Modbus).
Question: what DSMR parameters does the charger need and how do I send them over Modbus ?