Inline code at messages like at strings in Groovy

Hello folks!

I've tried to find any post related to this subject but with no success, so, here I'm again.

I have, for example, this simple RM rule:

Is it possible to do something like this (similar as can be done with Groovy):

Notify Marco's iPhone and Speak on Echo - Plus de Marco: 'A porta foi ${if(%value% == 'open', 'aberta', 'fechada')}

Ok, I know that the RM rule covers this case, however, with it a wide range of possibilities would be open, like string handling, calculations, and so on, right inside the text.

Everybody stay safe!


No, but the general workaround that works in RM for these situations is to create a variable (a local variable is fine), set its value however you want (either directly from a specific value, a device attribute, or by calculating it--which again must be done using the operations in the RM UI and not directly in a Groovy-esque fashion), then using that variable in your Rule Machine action instead. This will probably spare you from needing to write nearly the same action multiple time as in your example rule (though as you note there are easy solutions in this particular example).

Alternatively, for more complicated situations, you may wish to consider just building a custom app instead--then you can use Groovy directly. :slight_smile: Good luck!