Logic Machine Forum
LM5 and Keba P30 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: LM5 and Keba P30 (/showthread.php?tid=1866)



LM5 and Keba P30 - Rune - 26.01.2019

Hi!

Just got myself a Keba P30 EV charger and would like to integrate it with my KNX-installation. Here is the information I got from the manual and is it possible to see out of this how to do it?

Link to pdf here.

Main and first goal is to send the status if it is charging or not charging.

UDP Broadcast

Messages:
{"State": 2}
{"Plug": 1}
{"Input": 0}
{"Enable sys": 1}
{"Max curr": 32000}
{"E pres": 999999}


Description:
"State" = Current state of the wallbox
0 : starting
1 : not ready for charging; e.g. unplugged, X1 or "ena" not enabled,
RFID not enabled,.....
2 : ready for charging; waiting for EV charging request (S2)
3 : charging
4 : error
5 : authorization rejected
"Plug" = Current condition of the loading connection
0 unplugged
1 plugged on wallbox
3 plugged on wallbox plug locked
5 plugged on wallbox plugged on EV
7 plugged on wallbox plug locked plugged on EV
"Input" = State of the potential free Enable input X1.
When using the input, please pay attention to the information
in the installation manual.
"Enable sys" = Enable state for charging (contains Enable input, RFID, UDP,..).
"Max curr" = Current preset value via Control pilot in milliampere.
"E pres" = Power consumption of the current loading session in 0,1Wh;
Reset with new loading session (state = 2).
"E pres" is used as a pulse output with a valence 10Wh per message
or 100 messages / kWh -> full load 22kW
= one message every 1.6 sec


******************************************************************************

UDP command: i
Reply:
"Firmware":"KEBA P20 v 2.01m11 (140606-055125)"
Description:
Returns the product family and the firmware version of the wallbox.
Serves to a possible inventory of the network by means of a broadcast command
with a subsequent report for detailed queries.


******************************************************************************

UDP command: failsafe [Timeout] [curr] [save]
Reply:
"TCH-OK :done"
Description:
[Timeout] 10...600 = Within this time, a command "ena" or "curr" must be
received, in order not to activate the failsafe mode.
[curr] 0 = Disables the charging process when triggering the failsafe
function, similar to command "ena 0".
6000...63000 = Reduces the maximum allowed charging current
to this value (in milliampere), when triggering the failsafe function.
[save] 0 = Activates the failsafe function only temporary until the next
startup of the device.
1 = Saves the settings into the EEPROM in order to activate the
failsafe function automatically, after restarting the device.
By default, this feature is disabled and must be enabled once or after each restart.
This function is used to limit a network wall box with a lost communication (network
error, server failure, ...) to a defined state. This can be necessary in conjunction with
a peak load limitation, in order not to overload the main fuses.
An activated failsafe function is indicated by the wallbox. In this case the LED segments
do not longer illuminate the full width, but only indicates the current state with
the middle two LED segments.
A triggered failsafe function can be also recognized over UDP: in the report 2 the
"Enable sys" value goes to 0, and the charge current setting "Max curr" goes to
the default value of "Curr FS".
After the failsafe function has been activated due to a timeout, you must set the values
of current and the load enable again using the associated commands "curr" and
"ena".


**********************************************************************

UDP command: report 1
Reply:
{
"ID": "1",
"Product": "KC-P20-ES240010-000 ",
"Serial": "15017355",
"Firmware":"KEBA P20 v 2.01m11 (140610-073512)"
}
Description:
"ID" = ID of the retrieved report.
"Product-ID" = Model name (variant)
"Serial" = Serial number
"Firmware" = Firmware version


************************************************************************

UDP command: report 2
Reply:
{
"ID": "2",
"State": 2,
"Error1": 99,
"Error2": 99,
"Plug": 1,
"Enable sys": 1,
"Enable user": 1,
"Max curr": 32000,
"Max curr %": 1000,
"Curr HW": 32000,
"Curr user": 63000,
"Curr FS": 63000,
"Tmo FS": 0,
"Output": 0,
"Input": 0,
"Serial": "15017355",
"Sec": 4294967296,
}
Description:
"ID" = ID of the retrieved report.
"State" = Current state of the wallbox
0 : starting
1 : not ready for charging; e.g. unplugged, X1 or "ena" not enabled,
RFID not enabled,.....
2 : ready for charging; waiting for EV charging request (S2)
3 : charging
4 : error
5 : authorization rejected
"Error 1" = Detail code for state 4; exceptions see FAQ on www.kecontact.com
"Error 2" = Detail code for state 4 exception #6 see FAQ on www.kecontact.com
"Plug" = Current condition of the loading connection
0 unplugged
1 plugged on wallbox
3 plugged on wallbox plug locked
5 plugged on wallbox plugged on EV
7 plugged on wallbox plug locked plugged on EV
"Enable sys" = Enable state for charging (contains Enable input, RFID, UDP,..).
"Enable user" = Enable condition via UDP.
"Max curr" = Current preset value via Control pilot in milliampere.
"Max curr %" = Current preset value via Control pilot in 0,1% of the PWM value
"Curr HW" = Highest possible charging current of the charging connection.
Contains device maximum, DIP-switch setting, cable coding and
temperature reduction.
"Curr user" = Current preset value of the user via UDP; Default = 63000mA.
"Curr FS" = Current preset value for the Failsafe function.
"Tmo FS" = Communication timeout before triggering the Failsafe function.
"Output" = State of the relay output X2.
"Input" = State of the potential free Enable input X1.
When using the input, please pay attention to the information
in the installation manual.
"Serial" = Serial number
"Sec" = Current system clock since restart of the wallbox.


*************************************************************************

UDP command: report 3
Reply:
{
"ID": "3",
"U1": 230,
"U2": 230,
"U3": 230,
"I1": 99999,
"I2": 99999,
"I3": 99999,
"P": 99999999,
"PF": 1000,
"E pres": 999999,
"E total": 9999999999,
"Serial": "15017355",
"Sec": 4294967296,
}
Description:
"ID" = ID of the retrieved report.
"U1"|"U2"|"U3"| = Current voltage in V.
"I1"|"I2"|"I3"| = Current current value of the 3 phases in mA.
"P" = Current power in mW (Real Power).
"PF" = Power factor in 0,1% (cosphi)
"E pres" = Power consumption of the current loading session in 0,1Wh;
Reset with new loading session (state = 2).
"total" = Total power consumption (persistent) without current loading
session 0,1Wh;
Is summed up after each completed charging session (state = 0).
"Serial" = Serial number


***********************************************************************

UDP command: ena [n]
Reply:
"TCH-OK :done"
Description:
[n] is the enable state (binary)
0 = Disabled; is indicated with a blue flashing LED.
The same as used with the external enable input.
1 = Enabled
The answer TCH-OK confirms only the receiving of the command and not the correctness
of the value.
A value unequal to 0 or 1 is also confirmed and is leading to deactivation.
The correct reception can be verified using the proper report or by getting the corresponding
broadcast message.
ATTENTION:
Some electric vehicles (EVs) do not yet meet the standard requirements and an "ena
0" can lead to an error in the wallbox.


*****************************************************************************

UDP command: curr [n]
Reply:
"TCH-OK :done"
Description:
[n] is the maximum allowed loading current in milliampere.
The answer TCH-OK confirms only the receiving of the command and not the correctness
of the value.
Allowed are values between 6000mA und 63000mA. Invalid values are discarded
and the default is set to 63000mA. The value is also depending on the DIP-switch
settings and the used cable of the charging station.
The correct reception can be verified using the proper report or by getting the corresponding
broadcast message.


*******************************************************************************

UDP command: output [n]
Reply:
"TCH-OK :done"
Description:
[n] is output state of the relay terminal X2 under the connector panel cover of the
wallbox (binary value).
0 = open
1 = closed
>=10 = Pulse output with the specified number of pulses (pulses / kWh)
and is stored in the EEPROM; reasonably usable up to 150.
The answer TCH-OK confirms only the receiving of the command and not the correctness
of the value.
Values between 2 and 9 are not answered (reserved functions). Invalid values (e.g.
letters) are leading to a deactivation of the relay.
The correct reception can be verified using the proper report.


RE: LM5 and Keba P30 - admin - 28.01.2019

You will need a resident script for receive side and several event scripts for sending requests. Keep in mind that UDP must be enabled separately: Enabled UDP function with DIP-switch DWS1.3 = ON.

Receive script, change 192.168.1.1 to IP address of P30. Since messages are sent via broadcast this script will receive messages that are sent from other scripts. Remove logging once receive is working.
Code:
if not client then
  require('socket')
  require('ifinfo')
  require('json')

  ip = ifinfo().eth0.bcast
  port = 7090

  client = socket.udp()
  client:setoption('broadcast', true)
  client:setoption('reuseaddr', true)
  client:setsockname(ip, port)
  client:settimeout(1)
end

data, src = client:receivefrom()
if data then
  log(data, src)
  
  if src == '192.168.1.1' then
    data = json.pdecode(data)
    log(data)
  end
end

Send script, change data request as needed:
Code:
require('socket')
require('ifinfo')

data = 'i'

ip = ifinfo().eth0.bcast
port = 7090

client = socket.udp()
client:setoption('broadcast', true)
client:setoption('reuseaddr', true)
client:sendto(data, ip, port)
client:close()

Another thing to consider is that reply examples for reports are not valid JSON so you might have to add some extra code for parsing.