I have after some research and with the help of AI managed to read all RO registers from my EM2GO AC Wallbox “Home” EV charger using Home Assistant Modbus TCP. but I have not been able to write to the control registers. Windering if anyone has succeeded.
Has anyone succeeded controlling this charger as opposed to just reading registers? Defining switches in the Modbus section of configuration.yaml does not do the trick and ChatGPT proposed that Home Assistant use different register length when writing than EM2GO “Home” is expecting. I have also tried making small scripts that start and stop the charger or change mode but the write register call does not produce any result either.
My modbus configuration for EM2GO in configuration.yaml looks like this:
modbus:
- type: tcp
name: EM2GO_Home_CarCharger1
host: *THE_FIXED_IP_OF_MY_EM2GO*
port: 502
delay: 5
timeout: 10
message_wait_milliseconds: 30
sensors:
- name: "EM2GO Active power"
address: 12
unit_of_measurement: W
state_class: measurement
device_class: power
input_type: holding
data_type: int32
slave : 255
unique_id: em2go_active_power
- name: "EM2GO Charger state raw"
address: 0
input_type: holding
data_type: int16
slave : 255
unique_id: em2go_charger_state_raw_2
- name: "EM2GO Cable state"
address: 2
input_type: holding
data_type: int16
slave : 255
unique_id: em2go_cable_state
- name: "EM2GO Error code raw"
address: 4
input_type: holding
data_type: int16
slave : 255
unique_id: em2go_error_code_raw
- name: "EM2GO Charging current L1"
address: 6
unit_of_measurement: A
state_class: measurement
device_class: current
input_type: holding
data_type: int16
scale: 0.1
slave : 255
unique_id: em2go_charging_current_L1
- name: "EM2GO Charging current L2"
address: 8
unit_of_measurement: A
state_class: measurement
device_class: current
input_type: holding
data_type: int16
scale: 0.1
slave: 255
unique_id: em2go_charging_current_L2
- name: "EM2GO Charging current L3"
address: 10
unit_of_measurement: A
state_class: measurement
device_class: current
input_type: holding
data_type: int16
scale: 0.1
slave : 255
unique_id: em2go_charging_current_L3
- name: "EM2GO Active power L1"
address: 16
unit_of_measurement: W
state_class: measurement
device_class: power
input_type: holding
data_type: int32
scale: 10
slave : 255
unique_id: em2go_active_power_L1
- name: "EM2GO Active power L2"
address: 20
unit_of_measurement: W
state_class: measurement
device_class: power
input_type: holding
data_type: int32
scale: 10
slave : 255
unique_id: em2go_active_power_L2
- name: "EM2GO Active power L3"
address: 24
unit_of_measurement: W
state_class: measurement
device_class: power
input_type: holding
data_type: int32
scale: 10
slave : 255
unique_id: em2go_active_power_L3
- name: "EM2GO voltage L1"
address: 109
unit_of_measurement: V
state_class: measurement
device_class: voltage
input_type: holding
data_type: int16
scale: 0.1
slave : 255
unique_id: em2go_voltage_L1
- name: "EM2GO voltage L2"
address: 111
unit_of_measurement: V
state_class: measurement
device_class: voltage
input_type: holding
data_type: int16
scale: 0.1
slave : 255
unique_id: em2go_voltage_L2
- name: "EM2GO voltage L3"
address: 113
unit_of_measurement: V
state_class: measurement
device_class: voltage
input_type: holding
data_type: int16
scale: 0.1
slave : 255
unique_id: em2go_voltage_L3
- name: "EM2GO Meter value"
address: 28
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
input_type: holding
scale: 0.1
offset: 0
precision: 1
data_type: int32
slave : 255
unique_id: em2go_meter_value
- name: "EM2GO Charging energy"
address: 72
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
input_type: holding
scale: 0.1
offset: 0
precision: 0.1
data_type: int16
slave : 255
unique_id: em2go_chargin_energy
- name: "EM2GO Charging duration"
address: 78
unit_of_measurement: min
state_class: total_increasing
device_class: duration
input_type: holding
scale: 0.01667
offset: 0
precision: 1
data_type: int32
slave : 255
unique_id: em2go_charging_duration
switches:
- name: "EM2GO Plug & charge mode"
address: 93
write_type: holding
slave: 255
command_on: 0
command_off: 1
unique_id: em2go_plugncharge_mode
verify:
input_type: holding
address: 93
state_on: 0
state_off: 1
template:
- sensor:
- name: "EM2GO Charger Status"
state: >
{% set status = states('sensor.em2go_charger_state_raw') | int %}
{% if status == 0 %} Unknown
{% elif status == 1 %} Standby
{% elif status == 2 %} Connected
{% elif status == 3 %} Starting
{% elif status == 4 %} Charging
{% elif status == 5 %} Start failed
{% elif status == 6 %} Charging end
{% elif status == 7 %} EVSE system fail
{% elif status == 8 %} Transaction scheduled
{% elif status == 9 %} Firmware update
{% elif status == 10 %} Power on
{% else %} Invalid Status
{% endif %}
- name: "EM2GO Charger Error"
state: >
{% set error = states('sensor.em2go_error_code_raw') | int %}
{% if error == 0 %} No Error
{% elif error == 11 %} CP Fault
{% elif error == 12 %} Emergency Stop Pressed
{% elif error == 13 %} Under Voltage
{% elif error == 14 %} Over Voltage
{% elif error == 15 %} Over Temperature
{% elif error == 16 %} Meter Fault
{% elif error == 17 %} Leakage Fault
{% elif error == 18 %} Output Short
{% elif error == 19 %} Over Current
{% elif error == 21 %} Vehicle Fault
{% elif error == 22 %} Vehicle Communication Timeout
{% elif error == 23 %} Relay Fault
{% elif error == 24 %} RCD Fault
{% elif error == 25 %} PE Fault
{% elif error == 26 %} Start-up Charging Fault
{% else %} Unknown Error Code
{% endif %}
- name: "EM2GO Cable Status"
state: >
{% set cablestatus = states('sensor.em2go_cable_state') | int %}
{% if cablestatus == 0 %} Disconnected
{% elif cablestatus == 1 %} Connected
{% else %} false
{% endif %}
So you see that I have only one switch configured and once that is configured I will configure the other switches.
With this configuration all the read registers work so that I can see the status of the charger and I can see the charging current and time, and voltages and so on. The switch does not work. I have tried other switches as well but those do not work either.
I have also tried to run scripts instead of defining switches. Here is an example of one of the scripts as defined in scripts.yaml:
Finally I have also the charging current setting working. I am using a helper to input the current I want and then an automation that notices the change in the numeric value from the helper and then writed the new value to the charger using modbus write register to register 91. Note that the value needs to be multiplied by 10. Note also that the register is 16 bits so a matrix must be written with the value in the first 8 bits and 0 for the second 8 bits.
Note also that register 91 impacts the load balancing current limit. If a lower charging current value than 16 A has been set from the charger UI the charger will use which ever value is lower; the one set from the charger UI or the one set in register 91.