LCN OH3 hitkey action


after trying some other home automation systems I now want to relaunch my openHAB implemetation.
So I upgraded to OH3 with LCN-Binding. All went fine until I reached the topic to create a script for the “hitkey action”.
Now I’m quite helpless.
The sample code from the binding looks like this:

val actions = getActions(“lcn”,“lcn:module:b827ebfea4bb:S000M010”)
actions.hitKey(“C”, 4, “HIT”)

But how can I transform this to Javascript syntax?

Stiil working on it!

if ( actions.get(“lcn”,“lcn:15251F4BF1:S000M044”) == true)
always gives false

The Thing ID is lcn:module:0142301d08b8:15251F4BF1,
The Module is M044,

What should be the right input for the second argument in getactions?

General template

I got it!
An LCN-Thing uses a syntax like this :

Javascript example:
var logger = Java.type(‘org.slf4j.LoggerFactory’).getLogger(‘org.openhab.rule.’ + ctx.ruleUID);
var M044 = “lcn:module:0242402d08b9:15A52F4BF3”;

actions = actions.get(“lcn”,M044)
if ( actions == null )
{“Error module action”) }
{ actions.hitKey(“A”, 2, “HIT”)“Key was hit successfully”)

Rule definition file example:
// Modulnamen
val M044 = “lcn:module:0743701d09b8:18A58F8CE8”

rule "Hit key A1 "

Time cron “0 0/10 * * * ?”
val actions = getActions(“lcn”,M044)
if(actions === null)
logError(“actions”, “Modul nicht gefunden!” )
logInfo(“actions”,"Action is OK " + actions.toString() )
// actions.hitKey(“A”, 1, “HIT”) // AUF
// Thread.sleep(5000)
// actions.hitKey(“A”, 2, “BREAK”) // STOP

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.