LCN: Send Key does not appear in OpenHAB

Hello everyone.

I use the LCN binding for light, temperature, contacts, etc. and it works great. Thanks a lot for this!

The only thing I have trouble with is the handling of sent buttons with rules. The sent keys do not appear in the OpenHAB log viewer, but I can see them in the LCN-PRO. I have also checked in LCN-PKE that PCHK has module ID 4. I had to choose Group 3 (all modules). Is that correct?

This is my configuration:


rule "Glastaster Wohnzimmer: Hue Lichtszene schalten"
when
    Channel "lcn:module:0242fb441d47:S006M022:hostcommand#sendKeys" triggered "C1:HIT"
then
    Wohnen_Lichtszene = "Rm14ZRlOARTix23" // Gedimmt (31 %)
end

LCN-PRO log:

21:09:20:355 -      LPRO → S003_M004 Sende Tasten: 1 - - - - - - -  C=kurz
21:09:20:355 -      LPRO → S000_M004 Sende Tasten: 1 - - - - - - -  C=kurz

Thank you.
Andreas

I tried the same a few days ago and it didn’t work either. I’ll look into it.

1 Like

I tried to reproduce the issue I had a few days ago and … it simply works. It should look like this:

11:35:26.974 [TRACE] [g.lcn.internal.connection.Connection] - Received: '+M004000012.STH080001'
11:35:26.975 [INFO ] [openhab.event.ChannelTriggeredEvent ] - lcn:module:dca632c61631:S000M012:hostcommand#sendKeys triggered C1:HIT

I had to choose Group 3 (all modules). Is that correct?

The destination must be the PCHK ID (4 in most cases), like in your screenshot. Only if the sending module and PCHK are on different segments, the segment ID, PCHK is in must be configured. Otherwise the segment ID should be 0. You configured segment 3 (all segments). I’m not sure if this works as I never had the opportunity to test this binding with segments.

To improve the code I’d highly appreciate if you could paste the PCK command from the trace log when you send a host command to segment 3 module 4. One from a module in the same segment as PCHK and another from a module in a different segment. You can enable the trace logging by setting org.openhab.binding.lcn to TRACE.

I think I made the same mistake as you and try to test the host command by pressing “Test Kommando” in LCN-PRO. But that sends a command from LCN-PRO to openHAB, which will be ignored as openHAB expectes the module as the sender. So, test the command by letting the module send it, e.g. by pressing the physical key at the module.

Hi Fabian.

I have three segments:

  • Segment 5 = Basement. Currently no modules. Only LCN-PKE (PCHK) is located there.
  • Segment 6 = First Floor (this is my flat) with 18 modules. One of them sends key to PCHK.
  • Segment 7 = Second Floor (another flat) with 18 modules

This is how it looks in LCN-PRO when I program a new key:


I cannot select “—” as segment and module ID 4 as it leads to an error “Invalid target segment”.
I can select segment “3”, “5” or “6” and module ID 4. This was one thing I wondered about when reading the openHAB documentation for the LCN binding.

I added the following line into log4j2.xml:

<Logger level="TRACE" name="org.openhab.binding.lcn"/>

I tried with segment 3, 5 and 6.

Test with segment 3 (all segments)

Log LCN-PRO:

14:42:58:708 - S006_M022 EG Wohnen GT12 → S000_M004 Send keys: 1 - - - - - - -  C=HIT

Log OpenHAB:

2021-05-29 14:42:58.847 [INFO ] [openhab.event.ChannelTriggeredEvent ] - lcn:module:0242fb441d47:S006M022:hostcommand#sendKeys triggered C1:HIT
2021-05-29 14:42:59.403 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'hm51-4' failed: An error occurred during the script execution: Cannot assign a value in null context. in hm51

This looks quite promising, doesn’t it? hm51-4 is the rule from my previous post.

Test with segment 5 (with LCN-PKE / PCHK)

Log LCN-PRO:

15:10:00:721 - S006_M022 EG Wohnen GT12 → S000_M004 Send keys: 1 - - - - - - -  C=HIT

Log OpenHab:

2021-05-29 15:09:59.074 [TRACE] [g.lcn.internal.connection.Connection] - Received: '+M004006022.STH080001'
2021-05-29 15:09:59.095 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'hm51-4' failed: An error occurred during the script execution: Cannot assign a value in null context. in hm51

Test with segment 6 (same as module)

No log entry in LCN-PRO so probably not working.

From the LCN-PRO perspective it does not seem to make a difference if I choose segment 3 or 5.

Best regards
Andreas

Update: It works now after I adjusted the rule to set the scene. I still don’t know why the event can now be handled by OpenHAB. Pressing the physical button (instead of sending command via LCN-PRO) is crucial like you stated. I tested this, too. Yesterday I updated OpenHABian and rebooted it several times today… maybe that fixed it. Thanks a lot!

rule "Glastaster Wohnzimmer: Hue Lichtszene schalten"
when
    Channel "lcn:module:0242fb441d47:S006M022:hostcommand#sendKeys" triggered "C1:HIT"
then
    Wohnen_Lichtszene.sendCommand("Rm14ZRlOARTix23") // Gedimmt (31 %)
end

Great that it works! Just to get things right, does it work with segment 5, too? Because I don’t see any ChannelTriggeredEvent in your log.

BTW: I added a notice to the readme: [lcn] Improve readme; Allow special module IDs <5 by fwolter · Pull Request #10770 · openhab/openhab-addons · GitHub

Yes, at least in my case both segments 3 and 5 work. The log entries are identical.

Log LCN-PRO:

23:10:30:327 - S006_M022 EG Wohnen GT12 → S000_M004 Sende Tasten: - 2 - - - - - -  C=kurz

Log OpenHab:

2021-06-03 23:10:30.451 [INFO ] [openhab.event.ChannelTriggeredEvent ] - lcn:module:0242fb441d47:S006M022:hostcommand#sendKeys triggered C2:HIT

It didn’t work in the first place because of the mistake in the rule. This probably suppressed the log entry in the OpenHab log. Due to the fact that the rule triggered and the error message was in the log, the send key command must have been received by OpenHab.

Thank you for improving the readme. Will you add an info about the choice of segments? Maybe there is a difference if you run more than on LCN-PKE (if this is even possible) on different segments. I could imagine that using segment 3 would trigger on all instances of LCN-PKE, and using segment 5 only on the LCN-PKE in this segment. Using segment 3 seems to be some kind of broadcast.

Great that both segment IDs work! This was the first test of the binding with segments I’m aware of. There’s only one PC coupler allowed in an entire LCN installation. Segement 3 is indeed the broadcast segment. I stripped all non-openHAB (but LCN) related information from the readme as it is quite long. The info about segment 3 is rather an LCN related fact.