Global function: Send command only if condition XY true

Hi,

I’m looking for a global script function or blockly component which sends a command to an item only if a condition is true.

I’m thinking about somthing like this:

function sendCommandCondition(commandValue, item, conditionOperator, conditionValue) {
.....
}

sendCommandCondition(30, "rollershutterBedroom", ">=", 40); 

In my example I want to lower the rollershutter to 30 only if the current value is greater or equal 40.

Does such a function already exist?

Regards,
Vince

Not as an individual function but a rule can really be configured with a condition (but only if) and called from another rule.

But you’ll have to create a rule for each Item with that approach.

You can create a script and pass the name of the item and condition but if you have a lot of these that are likely to call the rule at the same time you are likely to see errors.

The best approach is to create a library and import that into the rules that need this. But for Blocky you’ll have to use the inline script block to both import and make the call to the function or create a block library (under developer tools).

Thank you for your reply. Then I’ll try to create my first blockly component :slightly_smiling_face:.