Rules Channel trigger hardcoded


Is there a way not to hardcode channel value if it is a trigger in rules file?

Like Items are configured in items file. Is there a way to configure needed channels in there as well? Then in rules file I could just use them the same as Items.
Maybe there is a way to access item channel some how?

rule "Room 1 Light Off Button Channel Triggered"
    Channel "homematic:HmIP-BSM:aaaaaaa:bbbbbbb:1#BUTTON" triggered
    // this sucks because I need to keep channel value "homematic:HmIP-BSM:aaaaaaa:bbbbbbb:1#BUTTON" in rules file And in Items file too.
    // following would be nicer to have. Is there something like this available?
    // or Channel Channel_Button_Off triggered
    // or Channel Item_Button_Off.getChannel() triggered
    // or Channel triggered
    logInfo("DEBUG", "Rule was triggered")

In Rules DSL - No, you must define triggers at rules load time.

You might be interested in this thread, which is also about dynamic triggers that cannot be done but can be worked around -

@rossko57 Thanks! I will.

ok. I see. proposal is to generate rules based on some templating language.

I think your challenge would still be that you need to find out the unique name of something that you are trying to avoid using the unique name of. I don’t know of a way to add some extra tag to an event channel, that you might use as your own unique key.

Hello, @Andrejs! What do you mean by this statement? If you have an Item linked to this Channel, then why wouldn’t you trigger your rule with that Item? From your original post, I’m not understanding what difficulty you are having.

I think that’s an event channel and cannot be linked to an Item with a friendly name.
Well, it can, but via a rule …

I think the complaint is that you use an abstract Item to drive rules. Later, you can edit its channels etc. (Say, the hardware changes) without having to revisit rules. Good Stuff.

But event channels are not as abstract and are a step closer to being hardware dependent.

1 Like