Alfen Eve Pro EV chargepoint interface via TCP modbus

Thank you @Bergerie. That clarifies some things.

If only I could change it to only using EMS … Originally I asked the installer to set it to “Meter + EMS monitoring”. But I can’t change it myself as the provided passwords don’t work and the “Password Reset Code” doesn’t work either. So, first to get that solved.

Hi,
Could you share your config for evcc & alfen? I get
modbus: exception ‘1’ (illegal function), function ‘16’…

Hi Epper202,

I also experience weird measurements. I have the Alfen for a week enabled modbus and of course immediately started playing with the Modbus_slave_max_current parameter.
The Alfen followed the programmed current nicely, but the read currents and power_sum are not in line with each other. As if there is a bug in the Alfen software.

I will post my results in a separate message.

Inconsistent values read from Alfen via modbus

I programmed a loop in which I set the “Modbus Slave Max Current” (register 1210/1211) to 8 Ampere every 30 seconds to avoid a fallback to the “Active Load Balancing Safe Current” parameter (registers 1212/1213).

First the theory, what I would expect:

8 Ampere x 230 V = 1840 Watt
3 phases x 1840 = 5,5 kWatt charging power in total.

But when reading the registers from the Alfen I see very weird behavior / values.

  1. The “Actual Applied Max Current” (reg. 1206/1207) nicely follows my setpoint: also 8 Amps
  2. The registers 320-325 “Current Phase L1/2/3” show current values around the 6,9A which I think could be right. It is pretty close to the requested 8 Amps.
  3. The registers 344-345 “Real Power Sum” however only shows a value of 2030 W.
  4. If I calculate the derivative of the “Real energy delivered sum” value (reg. 374-377) it increases with a slope of 1350 Wh per 40 minutes, which is equal to 2025 Watt.
  5. Inspection of the values of my smart electricity meter via P1 port and taking the regular home usage into account, shows 692 Watt per phase.

So… I’m completely puzzled… is there a mistake in my reasoning? Or bugs in software?

Items 1 and 2 above look more or less in line with each other.

Items 3, 4, and 5 also show the same energy/power figures. But these are not in line with the requested current, and the measured currents.

Are there people willing to

a) verify my reasoning?
b) try this at home?

Looks like the measured current figures are not right and the my car charges with a much slower rate (only 3 Amps in stead of the requested 8).

I have the latest firmware on my Alfen Eve Single pro-line.
I used pymodbus to write the current setpoint:

#

from pymodbus.client import ModbusTcpClient
#import pymodbus
import struct

###
#
# paramters:

current = 8.0	# 8.0 Ampere max current as an example

#
###


client = ModbusTcpClient( "alfen.fam-vdberg.local", 502 )

print("connect to server")
client.connect()

# Convert the float32 value to a 32-bit binary representation
packed_value = struct.pack('>f', current)  # '>f' for big-endian float
# Split the 32-bit representation into two 16-bit integers
registers = struct.unpack('>HH', packed_value)  # '>HH' for two big-endian 16-bit integers

print("write registers")
client.write_registers(1210,registers,1)

print("close connection")
client.close()

and as said… put that in a loop every 30 seconds.

The idea of the 60 seconds is that when your software crashes for whatever reason, that the Alfen charger falls back to a safe current.
So, I think you better consider leaving the 60 seconds to what it is, and build your software such that it writes, let’s say, every 30 seconds a new value. Even if it is the same value as 30 seconds earlier.

Thank you so much @all for the information that you share here.
I tried to collect everything that I have read here in this whole topic and I have put it all together in one file.
I wanted to share it in case someone else finds it useful as well.
If this file is placed in a folder called integrations, it can be included like this in the configuration.yaml:

homeassistant:
  packages: !include_dir_named integrations
integrations/alfen.yaml
#
# https://alfen.com/file-download/download/public/1610
# https://community.home-assistant.io/t/alfen-eve-pro-ev-chargepoint-interface-via-tcp-modbus
#
modbus:
  - name: wallbox
    type: tcp
    host: 192.168.1.237
    port: 502
    sensors:
      - name: Wallbox name
        unique_id: wallbox_name
        slave: 200
        address: 100
        count: 17
        data_type: string
      - name: Wallbox uptime
        unique_id: wallbox_uptime
        slave: 200
        address: 174
        data_type: uint64
        unit_of_measurement: ms
      - name: Wallbox temperature
        unique_id: wallbox_temperature
        slave: 200
        address: 1102
        data_type: float32
        unit_of_measurement: °C
      - name: Wallbox max current (active)
        unique_id: wallbox_active_max_current
        slave: 200
        address: 1100
        data_type: float32
        unit_of_measurement: A
      - name: Wallbox real power sum
        unique_id: wallbox_real_power_sum
        slave: 1
        address: 344
        data_type: float32
        unit_of_measurement: W
      - name: Wallbox mode3 state
        unique_id: wallbox_mode3_state
        slave: 1
        address: 1201
        count: 5
        data_type: string
      - name: Wallbox max current (applied)
        unique_id: wallbox_actual_applied_max_current
        slave: 1
        address: 1206
        data_type: float32
        unit_of_measurement: A
      - name: Wallbox max current
        unique_id: wallbox_max_current
        slave: 1
        address: 1210
        data_type: float32
        unit_of_measurement: A
      - name: Wallbox amount of used phases
        unique_id: wallbox_amount_of_used_phases
        slave: 1
        address: 1215
        data_type: uint16
      - name: Wallbox max current valid time
        unique_id: wallbox_max_current_valid_time
        slave: 1
        address: 1208
        data_type: uint32
        unit_of_measurement: s

template:
  - sensor:
      - name: Wallbox Status
        state: >
          {% set m3 = states('sensor.wallbox_mode3_state').replace('\0','') %}
          {% if m3 in ['A', 'E'] %} available
          {% elif m3 in ['B1', 'B2', 'C1', 'D1'] %} connected
          {% elif m3 in ['C2', 'D2'] %} charging
          {% else %} {{ m3 }}
          {% endif %}

input_number:
  wallbox_set_max_power:
    name: Set wallbox max power
    unit_of_measurement: kW
    min: 0
    max: 11
    step: 0.1

automation:
  - id: "wallbox_automation_set_max_power"
    alias: Wallbox - Set max power
    description: "Calculates and sets the amount of phaees and the max current"
    trigger:
      - platform: state
        entity_id:
          - input_number.wallbox_set_max_power
    condition: []
    action:
      - variables:
          power: "{{states('input_number.wallbox_set_max_power') | float }}"
          current: |
            {# no loading #}
            {% if power <= 1.38 %} 5

            {# 1 phase loading #}
            {% elif power < 1.61 %} 6   {# 1.38kW #}
            {% elif power < 1.84 %} 7   {# 1.61kW #}
            {% elif power < 2.07 %} 8   {# 1.84kW #}
            {% elif power < 2.30 %} 9   {# 2.07kW #}
            {% elif power < 2.53 %} 10  {# 2.30kW #}
            {% elif power < 2.76 %} 11  {# 2.53kW #}
            {% elif power < 2.99 %} 12  {# 2.76kW #}
            {% elif power < 3.22 %} 13  {# 2.99kW #}
            {% elif power < 3.45 %} 14  {# 3.22kW #}
            {% elif power < 3.68 %} 15  {# 3.45kW #}
            {% elif power < 4.14 %} 16  {# 3.68kW #}

            {# 3 phases loading #}
            {% elif power < 4.83 %} 6   {# 4.14kW #}
            {% elif power < 5.52 %} 7   {# 4.83kW #}
            {% elif power < 6.21 %} 8   {# 5.52kW #}
            {% elif power < 6.90 %} 9   {# 6.21kW #}
            {% elif power < 7.59 %} 10  {# 6.90kW #}
            {% elif power < 8.28 %} 11  {# 7.59kW #}
            {% elif power < 8.97 %} 12  {# 8.28kW #}
            {% elif power < 9.66 %} 13  {# 8.97kW #}
            {% elif power < 10.35 %} 14 {# 9.66kW #}
            {% elif power < 11.00 %} 15 {# 10.35kW #}
            {% else %} 16               {# 11.04kW #}
            {% endif %}
          # https://www.h-schmidt.net/FloatConverter/IEEE754.html
          registervalue: |
            {% if current == 5 %}[0x40a0, 0x0000]
            {% elif current == 6 %}[0x40c0, 0x0000]
            {% elif current == 7 %}[0x40e0, 0x0000]
            {% elif current == 8 %}[0x4100, 0x0000]
            {% elif current == 9 %}[0x4110, 0x0000]
            {% elif current == 10 %}[0x4120, 0x0000]
            {% elif current == 11 %}[0x4130, 0x0000]
            {% elif current == 12 %}[0x4140, 0x0000]
            {% elif current == 13 %}[0x4150, 0x0000]
            {% elif current == 14 %}[0x4160, 0x0000]
            {% elif current == 15 %}[0x4170, 0x0000]
            {% elif current == 16 %}[0x4180, 0x0000]
            {% endif %}
        alias: Calculate max current
      - if:
          - condition: template
            value_template: "{{ power < 4.14 }}"
        then:
          - service: modbus.write_register
            data:
              address: 1215
              unit: 1
              hub: wallbox
              value: 1
        else:
          - service: modbus.write_register
            data:
              address: 1215
              unit: 1
              hub: wallbox
              value: 3
        alias: Set amount of phases to 1 or 3
      - service: modbus.write_register
        data:
          address: 1210
          unit: 1
          hub: wallbox
          value: "{{ registervalue }}"
        alias: Set max current
    mode: single

This includes an automation that sets the max current (from 5A to 16A) and the amount of used phases depending on the set max power.

Here is an example card that can be used in a dashboard to show all the entitiees:

Dashboard Card
- type: entities
  entities:
    - entity: sensor.wallbox_name
    - entity: sensor.wallbox_temperature
    - entity: sensor.wallbox_uptime
    - entity: sensor.wallbox_status
    - entity: sensor.wallbox_mode3_state
    - entity: sensor.wallbox_real_power_sum
    - entity: input_number.wallbox_set_max_power
    - entity: sensor.wallbox_max_current_active
    - entity: sensor.wallbox_max_current_applied
    - entity: sensor.wallbox_max_current
    - entity: sensor.wallbox_amount_of_used_phases
    - entity: sensor.wallbox_max_current_valid_time
  title: Wallbox

4 Likes

As I can’t access ACE installer (mac user), I’m looking for the property values visible in MyEve as the app doesn’t offer (yet) the option ‘Meter + EMS monitoring’.
Does somebody have these values visible with option ‘Meter + EMS’ via Advanced > Station Properties > Smart Meter?

I’m puzzled as to what you are really after. In my opinion your question is already answered by the first post in this thread (Alfen Eve Pro EV chargepoint interface via TCP modbus).
All available parameters can be obtained from Modbus Register Table contained in document “Modbus Slave TCP/IP - Implementation of Modbus Slave
TCP/IP for Alfen NG9xx platform”, availble for download from Alfen Website.
If this is not what you were after, let me know!

Unfortunately it’s not what I’m looking for. I’m - like many in this thread - using the Modbus registers to consume various data. Instead of steering myself the max current, I’d like to activate the P1 meter to let the Alfen handle the load balancing.

For that I need to activate “Meter + EMS monitoring”. An option which is not available in the MyEve app, it’s only via the ACE installer (windows).

In the MyEve app however it’s possible to check and edit the configuration via “properties”. Make a change via the menus and you’ll see that properties change accordingly (I think Alfen Eve is configured via these properties, the MyEve is a layer over this).

It shows like this. I’d like to know what these settings show like if you’re using “Meter + EMS monitoring”. Current observations:

  • -1 = For EMS monitoring
  • 4 = Modbus TCPIP
  • 5 = DSMR P1

I got some support from Dutch tweakers forum: I was focussed on the wrong property.
Activate your load balancing on P1 DSMR (at least in my case).
Then update the follow registers to enable Modbus slave:

  • 2530_01 => 1
  • 2530_02 => 0

This delivers via MyEve the “Meter + EMS monitoring” solution.

My single Eve was also to far from my meter, out the solution was the p1 dongle from HomeWizard put the P1 value’s on the internet connection via wifi. The Single Eve is via wire connecties to the router.

Hello,
I also have an Alven wallbox with the activ load balancing licence. I can also charge the car and switch the charging power. However, if I don’t charge the car for a few minutes, I have to reconnect the charging cable every time. Which setting is wrong? Does anyone have any ideas?
I have made these settings in the ACE service installer:

But I can’t activate the Solar Cahrging.Alfen Eve Pro EV chargepoint interface via TCP modbus - #275 by aerrow5

Hi guys,

I had my alfen ev charger installed last month and I am now trying to integrate it to my homeassistant. I have found plenty of useful information in this thread, so thank you all for that.

However, I am facing an issue when trying to connect to the hacs integration called “Alfen Wallbox”. As you can see, I am inputting admin as the username, my charger’s IP, the password I’m using to log into ACE windows app and my charger’s name.

There is an error message called “Unexpected error occured”. Please see the attached pictures for reference…

My system’s log looks like this:
Logger: custom_components.alfen_wallbox.config_flow
Source: custom_components/alfen_wallbox/config_flow.py:53
integration: Alfen Wallbox (documentation)
First occurred: 13:53:28 (3 occurrences)
Last logged: 15:58:40

ClientError
Traceback (most recent call last):
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 1061, in _wrap_create_connection
sock = await aiohappyeyeballs.start_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py”, line 104, in start_connection
raise first_exception
File “/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py”, line 82, in start_connection
sock = await _connect_sock(
^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py”, line 174, in _connect_sock
await loop.sock_connect(sock, address)
File “/usr/local/lib/python3.12/asyncio/selector_events.py”, line 641, in sock_connect
return await fut
^^^^^^^^^
File “/usr/local/lib/python3.12/asyncio/selector_events.py”, line 681, in _sock_connect_cb
raise OSError(err, f’Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed (‘192.168.1.11’, 443)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/config/custom_components/alfen_wallbox/config_flow.py”, line 53, in _create_device
await device.init()
File “/config/custom_components/alfen_wallbox/alfen.py”, line 105, in init
await self.get_info()
File “/config/custom_components/alfen_wallbox/alfen.py”, line 128, in get_info
response = await self._session.get(
^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohttp/client.py”, line 659, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 557, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 1002, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 1336, in _create_direct_connection
raise last_exc
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 1305, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/aiohttp/connector.py”, line 1076, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.11:443 ssl:<ssl.SSLContext object at 0x7f04ea0ae0d0> [Connect call failed (‘192.168.1.11’, 443)]

any ideas?

Hi,
I also installed my wallbox and want to integrate it.
Have you closed myEVE mobile app and ACE installer?
Wallbox accepts ONLY ONE connection at a time.
If you enable the device in HA you wont be able to use the mobile app.
In my case, the logout button also does not work, i had to “disable” and “enable” the whole device in HA, to be able to connect via ACE again.
image

I got another pretty basic question (my car will ship in january, so i dont own an EV atm)
The documentation of solar charging is a bit poor. I own a Fronius Smart meter and it doesnt seem to integrate directly with Alfen WB.

I want to use HA / Modbus to tell the wallbox when and with what power to load.
How can I do that?
Can I set Solar Charging mode to “comfort” and use the comfort level (1400W - 11KW) for it? Or do I need to configure a smart meter to get this whole solar thing working?

How can I achieve, that I plug in the car and loading will first start, when ha sends a command?

Hi, I’m trying to do the same thing.
Can you confirm this setting allows the default P1 loadbalancing AND the readout/monitoring via modbus?

You are correct!

Thanks for confirming!