Ah, so it seems that the counter only starts when writing a value in 1210 (previously mentioned 1208 which is indeed incorrect. See below post for Lieven). Thought it is continuously running. That is why I always got a value of 0. It works now. Thanks @hollie.
Hey @appletowr
youâre welcome. I just think you are confusing the register addresses.
For other people reading this: the counter (in register 1208) start running when writing a value to the current setting register (in register 1210).
Yes, it is giving the command every 55 seconds, like in your code. The repeater in Node Red is facilitating that.
I also monitor âSocket current vallid timeâ and it stays within reach (it never gets to 0).
Also, when I stop my Node Red script, the âmodbus max currentâ falls back to 15A while it normally stays at 20A.
So, with the Node Red script running, it looks good but the charger still does not give more than 15A.
I monitor âModbus Slave receivedsetpoint accounted forâ as well and it is always on 1, which means it does account Modbus for the Actual Applied Current.
This is the note in the modbus document about this value:
Note: Register 1214 âModbus Slave received setpoint accounted forâ indicates whether the received Max Current (registers 1210-1211), also called a setpoint, is taken into account to determine the Actual Applied Max Current (registers 1206-1207). Depending on other setpoints, registers 1206-1207 may read the settings requested by the external device (e.g. EMS).
It drives me crazy. I cannot find the issue why the charger still maxes out on 15A.
Thanks in advance for you replies!
Hey @BevelvoerderNr1
there are a few other settings in the software that can limit the maximum current. I donât know the exact setting names but there is a global station limit and there is a limit per charge port. Can you check if those setting are not causing the 15 A limit?
Best regards,
Hollie
Hi Hollie,
Thanks for your reply.
Everything was set to 20A.
The weird thing is, I have installed another integration (Alfen Wallbox), changed some settings back and forth and now it does change at 20 amps again.
I did change those exact same settings in ACE as well, but only now it actually changed something. I donât know what I did differently as before.
Iâm happy it works as expected now.
Appreciate some help and advice here trying to make the connection with the alfen charger, After configuring the charger IP address a see the following in the home assistant logs
2024-06-17 21:06:42.417 ERROR (SyncWorker_5) [pymodbus.logging] Connection to (192.168.2.8, 502) failed: [Errno 111] Connection refused
2024-06-17 21:06:51.755 ERROR (SyncWorker_0) [pymodbus.logging] Connection to (192.168.2.8, 502) failed: [Errno 111] Connection refused
2024-06-17 21:06:51.775 ERROR (SyncWorker_0) [homeassistant.components.modbus.modbus] Pymodbus: laadpaal: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.2.8:502)]
Hey @dehigama
Home Assistant is telling you that it cannot connect to 192.168.2.8 on port 502. Either the IP address is wrong, or Home Assistant is on a different network segment so that it cannot reach that IP address or the modes service is not running on your chargepoint.
Youâll need to check those 3 things and fix it before Home Assistant can connect to the chargepoint.
Best regards,
Lieven
Thanks @hollie,
Im in contact with the supplier to get to know if the 2 parameters are set (as its via a lease company in NL i dont get the full owner account âyetâ.) The charge point is connected with both ethernet and the cable to the P1 port, its on the same ip range.
settings i have asked to check
- Active load balancing
- Data Source to âEnergy Management Systemâ
As of now everything from the dsmr-reader side is fully operational and have created a card in home assistant reading values in the meantime I get the charge point side up and running.
Just to share with anyone who is starting this I had to enable mqtt in the dsmr-reader configurations and enable âTelegram: Split topicâ to get the messages published.
Thanks @hollie and @bartland for the examples youâve shared in this thread. It helped with getting things started.
I managed to read values via modbus. But when writing values I bump into errors.
For example:
- when trying to set the power, I get the following in the logs:
Pymodbus: laadpaal: Error: device: 1 address: 1210 -> Exception Response(144, 16, IllegalFunction)
- when trying to switch to a single phase:
Pymodbus: laadpaal: Error: device: 1 address: 1215 -> Exception Response(134, 6, IllegalFunction)
Does anyone know what might be causing this?
Unfortunately my journey interfacing the Alfen comes to an end, this is due to the fact that I donât have an owners account for the charge point since its from a lease company. And itâs set to âMeteredâ. I can understand them from a safety point of view as âMeteredâ will make the charge point in control of the charge amps where as âEnergy management systemâ would listen to commands sent to the charge point so if you get it wrong then circuits breaker would start popping. Im now going through an alternative route that is to interface the vehicle in home assistant which Iâm not keen as now via home assistant you can even start/unlock the car! and also the fact that im now creating a vehicle specific dependency.
@dehigama Are you able to change it from âmeterâ to âMeter + EMS monitoringâ?
@Bergerie has posted a question on this before and later on confirms this works as advertised as a reply to somebody else asking about it.
Reconfirm that with âMeter + EMS monitoringâ setting, HA monitoring of Alfen Charge Point using Modbus and load balancing using Smart Meter via P1 connection to Alfen Charge Point works perfect. No Modbus write capability in this configuration. Hence, scheduled charging is done using the respective EV charge scheduler.
Does anyone use the HACS integration Alfen Modbus?
The alfen wallbox I have also have but you canât control the current with that one.
But with the alfen modbus integration i get only not availible in each entity while alfen wallbox integration works perfect.
Loadbalancing on energy management system and socket selected.
Does any one of you use the alfen modbus integration because for it look much more easy than always format the current to Hexadecimal.
And another question. I now searching what is the best, use Solar charge with P1 reading that it is controlled by Alfen. Or control the current from HA because i have solar power and energymeter in HA. I have 3 phase 32A supply. But i have a 4kW 3phase inverter if the minimum current is 6A then i can only charge fully from solar energy when inverter give the max 4kW? And single phase charging is stupid with 3 phase inverter. In ACE software i can lower the 6A safe current setting does it still work if you charge 3phase? Or it is like single phase below 6A it switch off?
Thank you all guys for all the information, this topic is really interesting.
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.
- The âActual Applied Max Currentâ (reg. 1206/1207) nicely follows my setpoint: also 8 Amps
- 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.
- The registers 344-345 âReal Power Sumâ however only shows a value of 2030 W.
- 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.
- 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
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?