eKey Binding and compatibility with ekey Multi and/or OpenHAB2

edit: NOTE: see next post for solution:

I’m still a bit confused on the items, the RARE protocol updates. As I see it, only two items “action” and “userid” are updated.

// openhab.log
2016-11-21 23:22:56.715 [INFO ] [ab.binding.ekey.internal.EKeyBinding] - new packet arrived: RarePacket [version=3, terminalid=1933640080, relayid=2, action=136, userid=0, fingerid=6(right index), name=0, personalid=0, serial=38150400, reserved=0, event=, terminalSerial=, time=]
2016-11-21 23:22:58.204 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'ekey Aktion': An error occured during the script execution: The name 'ekey_door_fingerID' cannot be resolved to an item or type.

// events.log
2016-11-21 23:22:56.717 [ItemStateChangedEvent     ] - ekey_door_userid changed from NULL to 1
2016-11-21 23:22:56.734 [ItemStateChangedEvent     ] - ekey_door_action changed from NULL to 0

in my .items there’s

/* eKey - Fingerprint */
Number ekey_door_action				"Letzte Aktion [MAP(ekey_action.map):%d]"								<lock>	(EG_Windfang)		{ekey="action"}
Number ekey_door_userid				"letzter Benutzer [%s]"													<lock>	(EG_Windfang)		{ekey="userid"}
String ekey_door_username			"Last user that accessed the house was [%s]"                            <boy0>	(EG_Windfang)		{ekey="username"}
Number ekey_door_userstatus			"The status of the last user that entered was [MAP(ekey_userstatus.map):%d]" <lock>	(EG_Windfang)	{ekey="userstatus"}
String ekey_door_terminalID			"The last used terminal was the one at the [MAP(ekey_terminal.map):%s]"	<lock>	(EG_Windfang)		{ekey="terminalid"}
String ekey_door_terminalName		"The short name of the last used terminal was: [%s]"					<lock>	(EG_Windfang)		{ekey="terminalname"}
Number ekey_door_fingerID			"Last used finger was the [MAP(ekey_finger.map):%d]"					<lock>	(EG_Windfang)		{ekey="fingerid"}
Number ekey_door_keyID 				"Last defined key was: [MAP(ekey_key.map):%d]"							<lock>	(EG_Windfang)		{ekey="keyid"}
Number ekey_door_inputID			"The input that triggered the last action: [MAP(ekey_input.map):%d]"	<lock>	(EG_Windfang)		{ekey="inputid"}
Number ekey_door_relayID			"The relay that switched at the last action: [MAP(ekey_relay.map):%d]"	<lock>	(EG_Windfang)		{ekey="relayid"}
Number ekey_door_mode				"The packet mode was [MAP(ekey_mode.map):%d]"							<lock>	(EG_Windfang)		{ekey="mode"}´

in my .rules there’s

rule "ekey Aktion"
when
	Item ekey_door_action received update
then
	if(ekey_door_action.state==-1) {
		logInfo("ekey", "Es wurde kein Finger erkannt!")
	} else {
		var String name = transform("MAP","ekey_names.map",ekey_door_userid.state.toString())
		var String finger = transform("MAP","ekey_finger.map",ekey_door_fingerID.state.toString())
		var String terminal = transform("MAP","ekey_terminal.map",ekey_door_terminalID.state.toString())
		var String vorgang = ""
		
		if ((ekey_door_fingerID.state < 6) && (ekey_door_fingerID.state != 0)) {
			// es war die linke Hand => zussperren
			postUpdate(Nuki_EG_door, OFF) 
			vorgang = "zugesperrt"
		}
		if ((ekey_door_fingerID.state > 5) or (ekey_door_fingerID.state == 0)) {
			// es war die rechte Hand => aufsperren
			postUpdate(Nuki_EG_door, ON) 
			vorgang = "aufgesperrt"
		}

		var String text = name + " hat seinen " + finger + "-Finger beim " + terminal + " Terminal eingelöst und damit die Tür "+vorgang
		logInfo("ekey", "ekey-Aktion: "+text)
	}    
end

I Need the fingerid to determine, if it was a right hand finger (=open door) or a left hand finger (=close door).

What I learned now after several times going to the door, swiping the finger on the fingerprint is this:

  1. a bundle installed via the console (like I did with ekey-binding) doesn’t get the item updates via simple file-saving
  2. a bundle installed via the console only gets new item changes if the bundle (or even the openHAB service?) restarts

ad 2. I can’t test a simple bundle:restart in the console, because the ekey-bundle won’t stop (it loops at some point endlessly); I had to restart the Pi.

so: long story short: if the (ekey-)binding is installed via console bundle:install, you have to at least restart the respective bundle to get updates e.g. for the .items file.

What was the exact feature:install command you’re referring to?

oh. sorry. it was bundle:install, typo changed above!

like in this one:

bundle:install https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/binding/org.openhab.binding.ekey/target/org.openhab.binding.ekey-1.9.0-SNAPSHOT.jar
1 Like

OK, thanks! After the binding is proven to work on OH2, it will be installable as a feature like the others that are already installable.

yes, but for this to achieve, I think we need some input from the maintainer of the binding on my configuration. I guess, the CV LAN is putting the payload correctly in the three protocols available - but I think, I just can’t find the right delimter-configuration for HOME or what brings the most attributs: MULTI.

Hi
Whats happen to the ekey binding. Couldn’t find version 1.9 anywhere, any idea?
Thanks

Hi Christian,

the binding moved to version 1.10:

It works with RARE protocol - RARE is lacking some really useful attributes, which come with MULTI (my preferred mode), but at least it works - I opened two issues on github: one for including it in the normal build and one hoping for Fixing MULTI and HOME mode.

Hi Thomas

Thanks for you feedback :slight_smile:

Best regards
Christian

I’m also trying to get communication with the ekey home convertor. I installed a UDP test tool and get packets in the HOME and RARE protocol form. But no succes with the ekey binding so far. I have the following binding installed;
217 | Active | 80 | 1.10.0.201705190111 | openHAB eKey Binding
and tried the RARE protocol, if i see in the openhab log file, no entry is written when a doortrigger is done. Where can i look further to tackle the communcation? Thank in advance.Tom

Hi there,

post your.items and ekey.cfg (perhaps .rules) here, so we can have a look. At best with a screenshot of the "ekey_home_converter_LAN_config", where your settings are visible for the CV LAN.

Thomas,

I use no rules for the moment on the ekey part, just items.

ekey.cfg

    # ip address of the eKey udp converter (optional)
    ip=192.168.0.200
    # port number for the UDP packets
port=51000
    # mode can be RARE, MULTI or HOME depending on what your system supports - RARE is default
    mode=RARE
    # the delimiter is also defined on the eKey udp converter - use the eKey configuration
    # software to determine which delimiter is used or to change it.
    # Not defining this is the same as " "
    delimiter=_

items

// ekey

Number ekey_action				"Letzte Aktion"									<lock>	(deurstation)		{ekey="action"}
Number ekey_userid				"letzter Benutzer"								<lock>	(deurstation)		{ekey="userid"}

If i use the UDP test utility, i get a byte code back.

I’m a bit confused as to where the UDP port numbers come from and I’m sure I haven’t set it up right.

Firstly, the EKEY config. I’m using a RPI for openHAB. What port number do I use and how do I find it?

port number for the UDP packets

port=51000

Secondly, in the EKEY LAN config there’s a Sender and a Receiver port. What values do I put in here and where do I get them from?
Is the Receiver IP address the address of the RPi running Openhab .

Current values as shown are made up.

Any pointers would be great. Thanks!

Hi Tom,

I’m a bit confused on the port number for the UDP packets. In both ekey.cfg and UDP Test Tool 3.0 your listening to port 51000, whereas in the ekey home converter LAN you defined 56000?

other than that, the two most important questions:

  1. your openHAB is running on 192.168.0.150?
  2. your openHAB listens to 56000 (see above)?

with that, we’ll dive into OH2-config:

ekey.cfg
your config seems ok, if your CVLAN is 192.168.0.200
only thing I did, I commented the delimiter line (as it isn’t needed in RARE mode):

# ip address of the eKey udp converter (optional)
ip=192.168.xx.xx
# port number for the UDP packets
port=21000
# mode can be RARE, MULTI or HOME depending on what your system supports - RARE is default
mode=RARE
# the delimiter is also defined on the eKey udp converter - use the eKey configuration
# software to determine which delimiter is used or to change it.
# Not defining this is the same as " "
#delimiter=_

saying this: Be sure, your OH2 is able to receive UDP packets, please check your router and/or your OH2-server on this. I once used the TCP-binding to check, if the UDP packets are received - but you could also use udp-receiver.

ekey.items
also seems legit to me, you could try the spelling, though I use “Action” and “User ID” instead of “action” and “user id”:

/* eKey - Fingerprint */
DateTime ekey_doorActionTime		"Letzte EKey-Aktion Zeit [%1$td %1$tb um %1$tR]]"		<lock>	(gEkey, EG_Windfang)
Number ekey_doorAction			"EKey-Aktion [MAP(ekey_action.map):%s]"				<lock>	(gEkey, EG_Windfang)				{ekey="Action"}
Number ekey_doorUserid			"Benutzer [MAP(ekey_names.map):%s]"				<lock>	(gEkey, EG_Windfang)				{ekey="UserID"}
Number ekey_doorFingerID		"Benutzter Finger [MAP(ekey_finger.map):%s]"			<lock>	(gEkey, EG_Windfang)				{ekey="FingerID"}
String ekey_doorTerminalID		"Benutzes Terminal [MAP(ekey_terminal.map):%s]"				(gEkey)						{ekey="TerminalID"}

Hi Tom(Saracen),

which Version of “ekey home converter LAN” do you use? Seems pretty old? :wink:
My CV LAN have Firmware 3.2.31.6 and the Windows-Exe is Version 4.3.34.24.

So my first suggestion is to update both your CV LANs and download the newest exe from ekey.net.
Second, please read through my post before this in response to the other Tom (Wouters), you should find all the Information there for your config.

Thanks for the help.

My ekey LAN config tool is not t he home version - it’s the ekey net converter and the software was all the latest last year. The system itself is quite old though.
With regard to the UDP ports, what I’m still not clear about is how I find the port number used by my RPi running openHab. Where are people getting the number 51000 from?

Hi Thomas,

Thanks for the advice. I was a little bit playing with the port numbers, i was actually using the same number on both sides, eg. 21000. My openhab is on address 192.168.0.150 and i’m listening on port 21000.

First i commented the delimiter line

# ip address of the eKey udp converter (optional)
ip=192.168.0.200
# port number for the UDP packets
port=21000
# mode can be RARE, MULTI or HOME depending on what your system supports - RARE is default
mode=RARE
# the delimiter is also defined on the eKey udp converter - use the eKey configuration
# software to determine which delimiter is used or to change it.
# Not defining this is the same as " "
# delimiter=_

changed the ekey naming, installed the NTP binding and added a test object in the items list, without success.

Number test		"test"	(deurstation) 	{udp="<[192.168.0.200:21000:'REGEX((.*))']"}
Number ekey_action				"Letzte Aktion"									<lock>	(deurstation)		{ekey="Action"}
Number ekey_userid				"letzter Benutzer"								<lock>	(deurstation)		{ekey="UserID"}

and enabled the udp port in my RPI as mentioned below.

iptables -A INPUT -p udp -m udp --dport 21000 -j ACCEPT

But still no success. Is there maybe a command to listen to a specific udp port in the RPI?

Thanks for the help so far, Tom

So I played around a bit an openHab is now picking up the UDP datagrams. The Home format appears to be the same as the NET format so I set my LAN converters to NET format and the EKEY config to "HOME format.

The error I get now is:

[ing.ekey.internal.EKeyPacketReceiver] - Error parsing packet
java.lang.IllegalArgumentException: Invalid Packet! Delimiter-match failed
at at.fhooe.mc.schlgtwt.parser.HomePacket.(HomePacket.java:46

The delimiter is set in the config and LAN converter to “_”.

Any ideas?

I’m not sure, if the “test”-item listening on the same Port as your ekey works within OpenHab… Did you restart the OH2-server? In my tests, I had the feeling that just changing the config didn’t work at first, I had to restart the server.

Nevertheless, normally you don’t need anything apart configuring the ekey-binding (ekey.cfg) and adding items with the ekey-actions.

In the events.log I get only the “Userid”, not the “Action”?

2017-05-31 16:03:47.353 [ItemStateChangedEvent     ] - ekey_doorUserid changed from 1 to 2

two Things:

  1. do you use openHABian?
  2. try getting the log-Level of the ekey-Binding to “TRACE”: log:set TRACE <<ID>>

for the latter:

  1. go to the openhab-console
  2. bundle-list
  3. normally the last one should be the ekey-binding the left column is the ID of the bündle

perhaps that leads to a bit more Information.

That’s sadly exactly how far I did come while trying the non-RARE protocols. I tried a bunch of different delimiters, all of which didn’t work out - I opened an issue at github: [ekey] binding works with RARE, but not with MULTI or HOME · Issue #5014 · openhab/openhab1-addons · GitHub - unfortunately without further success until now.
I understand, you use an old Version of the CV LAN (the one with the RS232?) - I don’t know this one, but if it supports RARE, just try this protocol, at least it works for me.