CTEK Chargestorm EV-charger Intergration

Hi

I have a CTEK Chargestorm EV-charger, The unit can send MQTT to a broker. Can this be integrated as a new intergration? I have recieved information from the manufacturer:


Supported services
Currently, the following services are supported:
• EnergyMeter & status reports using MQTT

Energy Meter & status reports using MQTT
This was added in the CCU FW r3.11.15.1 and r3.12.6.

Configuration
The following configuration keys can be set:
Automation/MqttEnabled Boolean, set to true to enable the service.

Automation/MqttServer The address / IP address of the MQTT broker. An empty string
will use the internal MQTT broker on the Charging Station itself.

Automation/MqttLogin Login / username for the MQTT broker, if necessary. Otherwise,
leave empty.

Automation/MqttPassword Password for the MQTT broker, if necessary. Otherwise, leave
empty.

Automation/MqttBaseTopic Base topic to be use. If empty, CTEK will be used.

The topics described below, assumes that [Automation/MqttBaseTopic is empty, thus
they’re starting with CTEK. Thereafter, the identity of the charging station comes, denoted by
CBID in the topics

Energy Meter data
The following topics includet energy meter readings, according to the JSON structure below:
CTEK/CBID/mainMeter/em
CTEK/CBID/evse1/em
CTEK/CBID/evse2/em

Listing 1: Energy meter readings.
1 {
2 " current ":[1.5889999866485596,0.8399999737739563,3.7209999561309814],
3 " energy ":20218145,
4 " frequency ": 50,
5 " power ":1337.5999755859375,
6 " timestamp “:” 2021 -04 -09 T09 :09:47 Z",
7 " voltage ":[237.60000610351562,233.89999389648438,235.80000305175781]
8 }

The data are taken from the energy meter and should, apart from possible rounding errors
correspond to the meter readings.
Some fields can be missing, if the energy meter doesn’t support them, or the data can be
reported as nan or null.

Energy meter information

The following topics includes general information about the energy meter:
CTEK/CBID/mainMeter/meterinfo Currently not being sent, but will likely be added in
the future.

CTEK/CBID/evse1/meterinfo
CTEK/CBID/evse2/meterinfo

Listing 2: General information from the energy meter.

1 {
2 " serialno ": " xxxxxxx "
3 }

EVSE status information

The following topics has status informations from the EVSE(s):
CTEK/CBID/evse1/status
CTEK/CBID/evse2/status

Listing 3: EVSE information and status.

1 {
2 " assigned ":16,
3 " state “:” NCRQ ",
4 " timestamp “:” 2021 -04 -09 T09 :09:47 Z"
5 }

Assigned is the current assigned to the EV by the charging station.
The state is a four letter code:
AVAL Available, no EV connected.
PAUS Pause, the charging station doesn’t allow charging.
EVRD EV is ready.
CHRG Charging is on-going.
FLTY Faulty, something is wrong.
DSBL Disabled.
CONN EV is connected, waiting for authentication.
NCRQ No charging is requested by EV.
AUTH Authenticated, waiting for EV to be connected.
INVL Invalid, something is wrong.
GONE The EV has disappeared.
DONE The charging session is finished.
SUHT Temporary state while going to pause.
STHT Temporary state while stopping the charging session.

Hi, I also have a chargestorm connected charger. Did you get any instructions on how to enable and setup the MQTT settings?

Hi, yes see below :slight_smile:

Documentation: https://www.ctek.com/se/emobility-dokument

This is a link to the drivers you need to connect to the control board. You need a PC with which you connect a mini-USB cable to the control card.

Drivers (if you need) : drives

Link for the webui in the Chargestorm: Web-UI

See attached image, activate Automation when you are in the webUI, then activate and fill in the data needed for the MQTT communication.

OK, configured the CCU.
But the log file for the broker says:

new con

So it doesnt work, I have tried MQTT explorer and if I use that I see a difrent connection in the logfile:

I have wrotre a mail to CTEK about the issue. :slight_smile:

I scanned the ports on the charger and indeed 1883 is open. I connected as an anonymous user but there don’t seem to be any topics active. I also sent a mail to CTEK a few days ago. I haven’t tried connecting to the CCU yet. I’ll try that one of the coming days. By the way do you have the newer chargestorm connected 2 or the original one like me?

Yes i have the original chargestorm, not chargestorm 2 :grinning:

Hi, I got an answer from CTEK, with the same info as above. I managed to activate the internal broker and connect (I could read out the evse energy meter but it the main). However when I configured my external MQTTool broker I didn’t get any messages. I’ll need to check a bit more. More to follow…

Did a Wireshark capture yesterday, checked messages on protocol MQTT, noticed that the CCU only send the user name and not the password. So the broker replies with “connection refused, not authorised”. Checked the ccu configuration and the password is correct configured. So it seems that there might be a glitch in the CCU software. I have emailed ctek support with screenshots of the Wireshark capture. Would be super if someone else could confirm

image

Hi @pretori I can confirm your find. I also ran wireshark and indeed the password isn’t passed in the connect command:

MQ Telemetry Transport Protocol, Connect Command
    Header Flags: 0x10, Message Type: Connect Command
        0001 .... = Message Type: Connect Command (1)
        .... 0000 = Reserved: 0
    Msg Len: 36
    Protocol Name Length: 6
    Protocol Name: MQIsdp
    Version: MQTT v3.1 (3)
    Connect Flags: 0x80, User Name Flag, QoS Level: At most once delivery (Fire and Forget)
        1... .... = User Name Flag: Set
        .0.. .... = Password Flag: Not set
        ..0. .... = Will Retain: Not set
        ...0 0... = QoS Level: At most once delivery (Fire and Forget) (0)
        .... .0.. = Will Flag: Not set
        .... ..0. = Clean Session Flag: Not set
        .... ...0 = (Reserved): Not set
    Keep Alive: 300
    Client ID Length: 9
    Client ID: 000008409
    User Name Length: 11
    User Name: REDACTED

which is followed by a connection refused message:

MQ Telemetry Transport Protocol, Connect Ack
    Header Flags: 0x20, Message Type: Connect Ack
        0010 .... = Message Type: Connect Ack (2)
        .... 0000 = Reserved: 0
    Msg Len: 2
    Reserved: Not set
    Return Code: Connection Refused: not authorized (5)

When I downloaded the original chargemanager.ini file as a backup I noticed that it didn’t contain an MqttPassword entry under the automation section (althoug it got added after I entered the password in the CCU GUI).

@pretori I’m also in contact with CTEK, could you maybe DM me your contact name then we might be able to “merge” our requests instead of writing to them separately

A SW update fixed the password bug so now the data gets posted to the MQTT broker. Now it should be possible to get it in HA as a sensor. I’ll try to take a look at that a bit later.

I added the sensors as regular MQTT sensors.
Here is an example for the electricity meter of the charger:

sensor:
  - platform: mqtt
    name: "EV Charger Energy"
    state_topic: "CTEK/CBID/evse1/em"
    unit_of_measurement: "Wh"
    device_class: energy
    state_class: total_increasing
    value_template: "{{ value_json.energy }}"
  - platform: mqtt
    name: "EV Charger Power"
    state_topic: "CTEK/CBID/evse1/em"
    unit_of_measurement: "W"
    device_class: power
    value_template: "{{ value_json.power }}"

where you replace CBID with the serial number of the charger

Hi

I have taken it a bit further :slight_smile:

sensor:
  - platform: mqtt
    name: "MQTT MainMeter Energy"
    state_topic: "CTEK/CBID/mainMeter/em"
    value_template: "{{value_json['energy'] | multiply(0.001) | round | float }}"
    unit_of_measurement: "kWh"
    state_class: "total_increasing"
    device_class: "energy"
  - platform: mqtt
    name: "MQTT MainMeter Current L1"
    state_topic: "CTEK/CBID/mainMeter/em"
    value_template: "{{value_json['current'][0] | round(2) }}"
    unit_of_measurement: "A"
    state_class: "measurement"
    device_class: "current"
  - platform: mqtt
    name: "MQTT MainMeter Current L2"
    state_topic: "CTEK/CBID/mainMeter/em"
    value_template: "{{value_json['current'][1] | round(2) }}"
    unit_of_measurement: "A"
    state_class: "measurement"
    device_class: "current"
  - platform: mqtt
    name: "MQTT MainMeter Current L3"
    state_topic: "CTEKCBID/mainMeter/em"
    value_template: "{{value_json['current'][2] | round(2) }}"
    unit_of_measurement: "A"
    state_class: "measurement"
    device_class: "current"
  - platform: mqtt
    name: "MQTT MainMeter Power"
    state_topic: "CTEK/CBID/mainMeter/em"
    value_template: "{{value_json['power'] | multiply(0.001) | round(2) | float }}"
    unit_of_measurement: "kW"
    state_class: "measurement"
    device_class: "power"
  - platform: mqtt
    name: "MQTT EVMeter1 Energy"
    state_topic: "CTEK/CBID/evse1/em"
    value_template: "{{value_json['energy'] | multiply(0.001) | round | float }}" 
    unit_of_measurement: "kWh"
    state_class: "total_increasing"
    device_class: "energy"
  - platform: mqtt
    name: "MQTT EVMeter2 Energy"
    state_topic: "CTEK/CBID/evse2/em"
    value_template: "{{value_json['energy'] | multiply(0.001) | round | float }}" 
    unit_of_measurement: "kWh"
    state_class: "total_increasing"
    device_class: "energy"
2 Likes

This is very interesting. I’m looking at a CTEK Njord Go charger, where I want to read current data but also control power (I have a Watty unit that provides realtime data for each phase in the house). For example, my main fuse size is 20A. I may charge the car at 10A, but then I start the oven, and perhaps also the AC - in which case I want to reduce charging to 6A etc. Second use case is setting charging schedules based on hourly energy prices.

I’m not sure the same will be possible with this charger. For the chargestorm you have to open up the charger and connect a laptop to the box in order to access the configuration interface of the charger. Only then is it possible to turn on mqtt. I fear that for you charger this will not be configurable (haven’t tested though). I did some reverse engineering on the communication used by the taking charge app at some point (before I even knew it had mqtt), but I never turned that into code. Perhaps it would be possible that way, but that is definitely more of a grey zone.

This is very interesting. I have Chargestrom 2.

Edit3:
I only had to make an accesscontrollist for clients without username and password.

Edit2:
I got the new CCU firmware now and connecting to my HA broker works as expected.

But now the broker on charger is also running, without password or user. Just broadcasting everything to everyone. Is it supposed to do that?

Edit:
I couldn’t get it to work so I used the built in mqtt broker on the ccu instead of Mosquitto on HA and now everything works. Thanks!

Are you running Mosquitto broker on Home Asssistant? If so how do you setup the address in the CCU, with :port or without the port?

Exempel, should i use 192.168.1.120 or 192.168.1.120:1883 in the ccu mqtt config?

Also for username and password, I should use the account I setup for the Mosquitto broker on HA, right?

If I remember well, it will act as a broker (without credentials) if you don’t point it to your own MQTT broker. I pointed mine to the mosquitto broker I have running through HA.

The fact that the EV charger act as a broker would indicate that for example the Ferroamp Energyhub intergration might listen to the maimMeter message and the Energyhub can then send comand through modbusTCP (i think) to the EVcharger to enable/disable charging of the car, depending if of produced sunpower.
I have asked CTEK if the API is public, it would be very nice to controll the EV charger from HA rather than just listening on the MQTT messages.

I am thinink that it would be able to simulate a energymeter, and send information to the EV charger, then it would be able to tell the EV charger that the current outtake of power is high and the EV charger wouldnt start for example. Or you can tell it that it is medium and the load current would be lower.

But at the same time we would still want to check the actual load on the mainMeter so we dont use to much power.

If that would be able we could achieve the same function as Ferroamp and CTEK have done, we could also throw in functions for spot prices so we can load when price is low or when we produce sun power :slight_smile:

I have integrated the charger through MQTT. Really nice way of getting all data from a non smart power meter as the load balancer reports the mainMeter data.

Did anyone find a way of start/stop charging from the charger end of things? Both my PSA cars have dodgey hacks for integrations so I don’t trust them…

I have got this up and running but it all stoped working when the Mosquitto broker were uppgraded to 6.0.1, I don’t seem to get any updates any more. Are there any one else who got this problem too?

Check of the broker in HA is connecting to localhost. I have notice that it changes sometimes. Try to connect to the broker with MQTT Explorer.