Analytics builder text replace with measurement value

I am on eu-latest.

I created a smart rule, that raises an alarm when a threshold is exceeded.
Then I want to send out an email, with the current measurement in the text.
How to achieve this?

Not working:

New #{severity} alarm has been received from #{} with value #{source.value}. Alarm text is: “#{text}”.
New #{severity} alarm has been received from #{} with value #{value}. Alarm text is: “#{text}”.

I also tried it with the analytics builder with text replace, but all things I tried did not resolve to the value:

Not working:
Value:: #{c8y_Humidity.value}. At #{time} → time works fine
Value:: #{c8y_Humidity.C.value}. At #{time}
Value:: #{source.value}. At #{time}

Thanks for your help.

Hi Johannes,

I can’t comment on the Analytics Builder, but maybe the behavior is the same as for Smart Rules. Smart Rules have common variables and variables, which are based on the context of the Smart Rule A Smart Rules always has a context, which is defined by the trigger of the Smart Rule. In your case, I assume you are using the On alarm send email rule. The trigger for this rule is the alarm, which means you only have access to fields and properties of the alarm. For alarms this would mean: status, severity and count (and of course all the common properties). This means you can’t access any properties from a measurement as it isn’t available in this particular context as the rule is only about an alarm being created and how you want to react to this event.

What you could do, is to modify the alarm text for your first threshold accordingly and have all necessary information of the measurement inside the alarm text. In your second rule you can access the alarm text property and display it in the email.

Best regards

Hi Christian,

sounds reasonable for Smart Rules, since the email is triggered from an alarm. But in analytics builder it is the measurement, that is going to be processed.

Best regards

Hi Johannes,

the problem is that the value of a measurement is not a property that can be extracted for text substitution but is the actual “thing” that is being transported. That’s why you observe that it works for the time.

The easiest solution would be to use the Set Properties block to store the measurement value in a property (e.g. “value”):

Alternatively, you could also use the Expression block and perform String concatenation. Just remember to convert the value to a string first.

Best regards,