Rule OH3 - channel xxx triggered

Hi all,

i would need your help or maybe just a hint.
Would like to migrate my rules from OH2 - all good except my channel triggered rules.
I use this for my zigbee switch.

OH2 rule:

rule "SchalterBüro"
when
    Channel "mqtt:topic:mybroker:SchalterBuero:click" triggered
then
    var actionName = receivedEvent.getEvent()
    switch(actionName) {
        case "single": {
            
            Alexa_Buero_RadioStationID.sendCommand("s15547")
            }
           
        
        case "double": {
           Alexa_Buero_Radio.sendCommand("OFF")
        }
    }
end

My issue now is that i am not able to select this channel via the gui:

“a trigger channel fires” i am only able to select my harmony hub activity trigger.
Thanks for your assistance.

As a workaround i have now added the rules via good old text config.
We can close this thread.

EDIT:
Rule is created but now working:

Error

Script execution of rule with UID 'default-1' failed: 'getEvent' is not a member of 'java.lang.String'; line 5, column 22, length 24 in default

Any idea?

I have now splitted the rule and everything is fine:

rule "SchalterBüroMusikEIN"
when
    Channel "mqtt:topic:mybroker:SchalterBuero:click" triggered single
then   
            Alexa_Buero_RadioStationID.sendCommand("s15547")
      
end

rule "SchalterBüroMusikAUS"
when
    Channel "mqtt:topic:mybroker:SchalterBuero:click" triggered double
then   
            Alexa_Buero_Radio.sendCommand("OFF")
      
end

I trie to do what you trie to do but as ECMA script. Any idea how this should work?
what i am struggeling with is, how to get the event. i would like to do it with swich case and not in a seperate rule for all six events.

okay, i think i found it. trie:

switch(event.event)
{
    case "single":     
        events.sendCommand('Alexa_Buero_RadioStationID', 's15547');
    break;
    case "double": 
        events.sendCommand('Alexa_Buero_Radio','OFF');
    break;
}

as an ECMAscript.

1 Like

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