Alfen Eve Pro EV chargepoint interface via TCP modbus

I’m getting an Issue while configuring this integration.

Log Details (ERROR)
This error originated from a custom integration.
Logger: custom_components.alfen_wallbox.config_flow
Source: custom_components/alfen_wallbox/alfen.py:133
Integration: Alfen Wallbox (documentation)
First occurred: 12:35:09 (1 occurrences)
Last logged: 12:35:09

Unexpected error creating device
Traceback (most recent call last):
  File "/config/custom_components/alfen_wallbox/config_flow.py", line 42, in _create_device
    await device.init()
  File "/config/custom_components/alfen_wallbox/alfen.py", line 41, in init
    await self.async_update()
  File "/config/custom_components/alfen_wallbox/alfen.py", line 63, in async_update
    await self._do_update()
  File "/config/custom_components/alfen_wallbox/alfen.py", line 74, in _do_update
    self._status = AlfenStatus(response_json, self._status)
  File "/config/custom_components/alfen_wallbox/alfen.py", line 133, in __init__
    for prop in response['properties']:
TypeError: 'NoneType' object is not subscriptable

I’m using the same login credentials as the ACE Service installer for the charger.
Username: Owner

Do you have any idea?

Use default admin username

Found the issue…
I did try with the default admin username but i had an underscore in the name (Alfen_Charger) which gave the issue, i tried it this time without the underscore and it worked directly.

1 Like

Been trying to use this integration with my new Alfen Eve Pro, but I get an error message while creating the device. I’m using the correct ip address, and have tried both the login name “Owner” and “Admin” together with the password belonging to my Alfen Eve Pro. I used the name “laadpaal”.

Any idea what the issue might be?

The log shows the following message:


This error originated from a custom integration.

Logger: custom_components.alfen_wallbox.config_flow
Source: custom_components/alfen_wallbox/alfen.py:180 
Integration: Alfen Wallbox (documentation) 
First occurred: 13:02:50 (3 occurrences) 
Last logged: 13:09:41

Unexpected error creating device
Traceback (most recent call last):
  File "/config/custom_components/alfen_wallbox/config_flow.py", line 42, in _create_device
    await device.init()
  File "/config/custom_components/alfen_wallbox/alfen.py", line 37, in init
    await self.async_get_info()
  File "/config/custom_components/alfen_wallbox/alfen.py", line 90, in async_get_info
    self.info = AlfenDeviceInfo(generic_info)
  File "/config/custom_components/alfen_wallbox/alfen.py", line 180, in __init__
    if ALFEN_PRODUCT_MAP[self.model_id] is None:
KeyError: 'Generic Alfen Wallbox'

In HA: Try username: ‘admin’.
With the password which will match the Owner user (from the ACE installer or My Eve app)

Thanks but still same message. I installed the alfeneve API CLI in python and can connect with the same admin and password. The only difference is that with the CLI there is no need to define a name. I think any string like “laadpaal” should work right?

I’m using this HACS integration as well. I noticed that the device keeps rebooting 3-4 times per day. Has anyone noticed similar behaviour?
Not sure if this integration is causing it… according to the log there’s an out of memory exception.

image

2023-01-29T23:44:20.960Z:RESET:application.c:353:=========================================
2023-01-29T23:44:20.972Z:INFO:application.c:361:build: Aug 15 2022 12:20:52
2023-01-29T23:44:20.980Z:INFO:application.c:362:version: 5.8.1-4123
2023-01-29T23:44:20.988Z:INFO:application.c:363:compiler: gcc 4.8.3
2023-01-29T23:44:20.996Z:INFO:application.c:216:fwu state inactive
2023-01-29T23:44:21.003Z:INFO:application.c:236:Bootloader version 0.1.6
2023-01-29T23:44:21.234Z:USER:taskCANopen.c:224:Persistent configuration retrieved, 243 items
2023-01-29T23:44:21.246Z:INFO:application.c:269:FLASH read protection 0xcc level 2 (permanent)
2023-01-29T23:44:21.269Z:WARNING:bspI2c.c:670:I2C slave not responding #-3 AUXBOARD@0x0028, attempting bus recovery
2023-01-29T23:44:21.285Z:WARNING:bspI2c.c:689:Device AUXBOARD@0x0028 not available
2023-01-29T23:44:21.292Z:USER:application.c:412:Using P1 port
2023-01-29T23:44:21.300Z:INFO:application.c:305:System boot #69, cause Watchdog reset
2023-01-29T23:44:21.308Z:ERROR:bspCrashDump.c:173: -- Crash details recovered. 
2023-01-29T23:44:21.316Z:ERROR:bspCrashDump.c:192:Out of memory
2023-01-29T23:44:21.324Z:ERROR:bspCrashDump.c:192:free 3968 bytes,  lowest ever free 3352 bytes
2023-01-29T23:44:21.335Z:ERROR:bspCrashDump.c:192:fragmentation: 108240048.0%
2023-01-29T23:44:21.343Z:ERROR:bspCrashDump.c:192:fragmentation: 4K blocks -3.2%
2023-01-29T23:44:21.351Z:ERROR:bspCrashDump.c:192:# free blocks: 64
2023-01-29T23:44:21.359Z:ERROR:bspCrashDump.c:192:largest free: 6312 bytes
2023-01-29T23:44:21.367Z:ERROR:bspCrashDump.c:192: 2023-01-29T23:44:17.757Z SW Watchdog (fffe7e4e) triggered.
2023-01-29T23:44:21.378Z:ERROR:bspCrashDump.c:192:Missing: Modbus NFC 
2023-01-29T23:44:21.382Z:ERROR:bspCrashDump.c:192:determining cpu hog...
2023-01-29T23:44:21.390Z:ERROR:bspCrashDump.c:192:Tmr Svc                  1    <1% 
2023-01-29T23:44:21.402Z:ERROR:bspCrashDump.c:192:display              25155    97% 
2023-01-29T23:44:21.410Z:ERROR:bspCrashDump.c:192:lwip                     0    <1% 
2023-01-29T23:44:21.417Z:ERROR:bspCrashDump.c:192:WebClients               0    <1% 
2023-01-29T23:44:21.425Z:ERROR:bspCrashDump.c:192:NFC                      0    <1% 
2023-01-29T23:44:21.433Z:ERROR:bspCrashDump.c:192:Modbus                   0    <1% 
2023-01-29T23:44:21.445Z:ERROR:bspCrashDump.c:192:PPP                      0    <1% 
2023-01-29T23:44:21.453Z:ERROR:bspCrashDump.c:192:OCPP                     0    <1% 
2023-01-29T23:44:21.460Z:ERROR:bspCrashDump.c:192:WebServer                0    <1% 
2023-01-29T23:44:21.468Z:ERROR:bspCrashDump.c:192:CommandLine              0    <1% 
2023-01-29T23:44:21.476Z:ERROR:bspCrashDump.c:192:IDLE                     0    <1% 
2023-01-29T23:44:21.484Z:ERROR:bspCrashDump.c:192:Eth_if                   5    <1% 
2023-01-29T23:44:21.496Z:ERROR:bspCrashDump.c:192:Modem                    2    <1% 
2023-01-29T23:44:21.503Z:ERROR:bspCrashDump.c:192:ModbusTCPIPSlav          0    <1% 
2023-01-29T23:44:21.511Z:ERROR:bspCrashDump.c:192:P1Meter                  2    <1% 
2023-01-29T23:44:21.519Z:ERROR:bspCrashDump.c:192:CANopen                427    1% 
2023-01-29T23:44:21.527Z:ERROR:bspCrashDump.c:192:ModbusTCPIPMast          0    <1% 
2023-01-29T23:44:21.539Z:ERROR:bspCrashDump.c:192:Main                     0    <1% 
2023-01-29T23:44:21.546Z:ERROR:bspCrashDump.c:192:TCP/IP                   0    <1% 
2023-01-29T23:44:21.554Z:ERROR:bspCrashDump.c:192:Master                   0    <1% 
2023-01-29T23:44:21.562Z:ERROR:bspCrashDump.c:197: -- End of crash details
2023-01-29T23:44:21.570Z:INFO:board_ng9xx.c:1475:Registered timeout getHardware
2023-01-29T23:44:21.593Z:WARNING:bspI2c.c:670:I2C slave not responding #-3 MMA8451@0x000d, attempting bus recovery
2023-01-29T23:44:21.609Z:WARNING:bspI2c.c:689:Device MMA8451@0x000d not available
2023-01-29T23:44:21.628Z:WARNING:bspI2c.c:670:I2C slave not responding #-3 BMA456Q@0x0000, attempting bus recovery
2023-01-29T23:44:21.644Z:WARNING:bspI2c.c:689:Device BMA456Q@0x0000 not available

I can see an important indication.

“2023-01-29T23:44:21.316Z:ERROR:bspCrashDump.c:192:Out of memory”
Could be a memory leak with the integration causing the component to crash.

That’s exactly my suspicion. But maybe the device is giving this error anyway and rebooting every day… I just wouldn’t know about it if I didn’t have this integration… :wink:
Found 1 person on another forum now who is experiencing the same issue.

I have 1 Alfen configured a couple of weeks ago. I now try to add a second Alfen and when filling in all parameters, I get “an unknown error occured”.

The logs give

 Logger: py.warnings
Source: custom_components/alfen_wallbox/alfen.py:70
Integration: Alfen Wallbox (documentation)
First occurred: 11:59:52 (5 occurrences)
Last logged: 12:48:28
/config/custom_components/alfen_wallbox/alfen.py:70: RuntimeWarning: coroutine 'ClientSession._request' was never awaited self._session.request(ssl=self.ssl, method='POST', headers = HEADER_JSON, url=self.__get_url('logout')) 

and

Deze fout is ontstaan door een aangepaste integratie.

Logger: aiohttp.server
Source: custom_components/alfen_wallbox/config_flow.py:29
Integration: Alfen Wallbox (documentation)
First occurred: 12:05:25 (3 occurrences)
Last logged: 12:49:06

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 145, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 253, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 335, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/alfen_wallbox/config_flow.py", line 65, in async_step_user
    return await self._create_device(user_input[CONF_HOST], user_input[CONF_NAME], user_input[CONF_USERNAME], user_input[CONF_PASSWORD])
  File "/config/custom_components/alfen_wallbox/config_flow.py", line 52, in _create_device
    return await self._create_entry(host, name, username, password)
  File "/config/custom_components/alfen_wallbox/config_flow.py", line 29, in _create_entry
    if entry.data[KEY_IP] == host:
KeyError: 'ip'

Try also to install this integration, however i get the following error:

Unexpected error creating device.

Someone an idea of where the problem came from?

1 Like

In order to set the correct values for modbus using py, I figured out a quite straightforward solution.

  • Installed HACS
  • Installed pyscript from HACS

Created the following script in the /pyscript directory and call it alfen.py (name doesn’t matter as long as it has extension .py)

import struct

@service
def set_ev_power(power):
    """Set the EV POWER (watt)"""
    log.info(f"Set EV power to {power} watt")
    voltage = 235 #average voltage in Belgium, but you should probably best take value from metered sensor
    evCurrent = to_hex(power/voltage)
    modbus.write_register(address=1210, slave=1,hub="alfenpro", value=evCurrent )

def to_bytes(f):
    return struct.pack('!f', f)

def to_hex(f):
    hexString = to_bytes(f).hex()
    first = int(hexString[0:4],16) 
    second = int(hexString[4:8],16) 
    return  [first, second]

Then you can call it as a service

Alternatively you can add function decorators so that in case of change in PV power it changes the EV power settings. Then it looks something like this

@state_trigger("sensor.solis_inverter_dc_power")
def set_ev_power():
       """Set the EV POWER (watt)"""
    power =  state.get('sensor.solis_inverter_dc_power')
    voltage = 235
    log.info("Power: %s", power)
    evPower = to_hex(float(power)/voltage)
    modbus.write_register(address=1210, slave=1,hub="alfenpro", value=evPower)

Enough for you guys to experiment with :slight_smile:

4 Likes

Hi peebee01,

Do you got it working?
I have the same problem as you.

for the people who also get an error on alfen.py line 180, in the file const.py you type (in my case)" ‘NG910-60583’: 'Eve Single S-line, 3 phase, LED, type 2 socket ', " do a restart and you can add the box.

1 Like

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