Alfen Eve Pro EV chargepoint interface via TCP modbus

New Alfen firmware released:
Firmware Release 6.0 for our NG9xx charging platform

Nice new feature:
The charging station can now read DSMR P1 smart meter data from a P1-to-network converter
using the telnet protocol. Configuration items are added to select the P1 interface (serial or telnet)
and set the telnet server properties (IP address and port)

2 Likes

Thanks McDobber! That solved my problem.

Beste Heren,

Na het lezen van jullie mooie oplossing, ben ik aan de slag gegaan met een oude gebruikte ICU EVE met smartcard en zonder display. Ik heb hem aangesloten, maar ik kom er niet in met de software van Alfen. Ik krijg ook geen ARP van de kast via een standaard UTP kabel en Wireshark. Wat doe ik eventueel fout of is het een instelling van de kast?

Alvast bedankt,

Edouard

Lieven,

With high interest I read what you did and I would like to implement the same for me too, but I don’t know how to start.

I have an Alfen Eve Pro Single and a digital energy meter, I also use a Youless adapter to be able to read the energy usage.

I would like to plug in my hybrid car always when I’m home. As soon as there is solar energy available, which should normally be injected to the grid, I would like to upload it to my car. I would also like to have the possibilitty to put the system to “manual” so my car starts loading at maximum speed, which is 3.7 kw in my case.

Where do I start, do I need some extra hardware or do I have everything and is it only configuration I need to do. Can you help me to realise this?

regards,

Dries

Hey Dries,

to implement what you want to do you need the following:

  • information of the P1 port from your digital meter to be able to determine if there is injection into the net. This info you need to know when to start charging the car. This info needs to be available in home assistant.
  • the possibility to tell the Alfen how much current the car can pull (which you can do via the modbus over TCP interface from home assistant).
  • to be able to ‘pauze’ the charging of the car completely it depends which car you have. Mine (Volvo) goes into fault mode if I set the current on the Alfen to ‘0 A’. Other cars do support this to pauze the charge process, see the post from @bartland higher in this thread.
    To pauze the charging I am using the API to the car to stop the charge process. I have documented this here.

Basically all information you need to implement what you have in mind is available in this thread.
It will take some experimenting to get everything up and running, but that is part of the learning processfun :wink:

Best regards,
Lieven

Hi @bartland
I just have an Alfen Eve installed at home and got started adding the scripts. But I was wondering the following: is it possible to know how many fases is currently configured on the charger? If I look at the ACE service installer I see no change when running the script. So I’m wondering if this is intended or there is another way to know the current configuration of the fases.

EDIT:
I figured out what the problem was: In the ACE installer I had to enable Allow 1- and 3-phased charging in the Load balancing section.2023-03-18 08_54_05-ACE Service Installer 3.6.6-163 - Settings_ 2.3.0-1162 -  (Extern_ICU)

Doing so I can now see in the logs the trigger when running the script to run the phase. So I know now it’s working.

Is there a sensor we can create to monitor the current setting on the fases?

Thanks!

1 Like

Hi all,

based on this topic I got the balancing working.
Got 2 questions:

  1. 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)
  1. 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?

Thanks, and great topic!

Yes, you can create a sensor via modbus to READ the current phases.
This part in the code below creates the sensor sensor.charger_use_1_or_3_phases

      - name: charger_use_1_or_3_phases
        slave: 1
        address: 1215
        data_type: uint16

full code

modbus:
  - name: car_charger
    type: tcp
    host: 192.168.1.2
    port: 502
    sensors:
      - name: charger_use_1_or_3_phases
        slave: 1
        address: 1215
        data_type: uint16
      - name: car_charger_name
        unique_id: 'd7494313-3ce8-4871-9c8b-546fa826d45f'
        slave: 200
        address: 100
        count: 17
        data_type: string
      - name: charger_temperature
        slave: 200
        address: 1102
        data_type: float32
        unit_of_measurement: °C
      - name: charger_active_max_current
        slave: 200
        address: 1100
        data_type: float32
        unit_of_measurement: A
      - name: charger_real_power
        unique_id: '5d2cee9c-2485-4af4-a9a2-a901321924c0'
        slave: 1
        address: 344
        data_type: float32
        unit_of_measurement: W
      - name: charger_mode3_state
        slave: 1
        address: 1201
        count: 5
        data_type: string
        scan_interval: 5
      - name: charger_actual_applied_maxcurrent
        slave: 1
        address: 1206
        data_type: float32
        unit_of_measurement: A
      - name: charger_modbus_maxcurrent
        slave: 1
        address: 1210
        data_type: float32
        unit_of_measurement: A
      - name: charger_socket1_current_valid_time
        slave: 1
        address: 1208
        data_type: uint32
        unit_of_measurement: s
      - name: charger_energy_delivered
        slave: 1
        address: 374
        count: 4
        data_type: float64
        unit_of_measurement: Wh
        device_class: energy
        state_class: total_increasing
1 Like

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?

  1. 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)

  2. 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.

Hi Bart,

Thank you very much for sharing the code for the sensor reading out the current phases!

I’m looking to create an automation doing the same as your point 2: Start charging at 1300W and increase if needed and decrease when needed.

Would you mind sharing how you have it set up so I have a starting point to build on?

Much appreciated!

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
2 Likes

Hi, just bumped into your message, I have the exact same issue. Have you been able to solve this issue?

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)

- name: laadpaal_total_charged
  slave: 1
  address: 390
  count: 4
  data_type: float64
  unit_of_measurement: Wh

Hey Wim,

just do:

      - name: laadpaal_energy_delivered_sum_1
         slave: 1
         address: 374
         count: 4
         data_type: float64
         unit_of_measurement: Wh
         device_class: energy
         state_class: total_increasing

With the additional parameters you can also add the reading to your energy dashboard.

Best regards,
Lieven

Tnx Lieven,

That worked like a charm :slight_smile:

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.

Hi Lieven,

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?

Hey @rtdegraaf

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?

Best regards,
Lieven

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.

Altough te reboot problem still exists.

grts

Hi Lieven,

Thanks for your reply. I have not changed anything but it is working since a few days. Maybe it needed some time or a reboot, I really don’t know :sweat_smile:

Kind regards,

Ronald

1 Like