[SOLVED] How to include different variable "context" in the event message

I’d like to setup an event that is triggered by the value of one variable and send a message that includes the context of another variable.
Eg. I have a boolean that monitors the status of the system and an “alarm” variable which sends the description of the alarm in the context.
I’d like to create an event which is triggered by the true value of the ‘status’ boolean, and would send a message with the context of the ‘alarm’ variable.
bool status;
if trigger: status == 1
than action: send email
Message: “Device name” alert was triggered at “Trigger timestamp” due to: {“alarm” : { “context” : {“alarm” : “KEY-VALUE”}}}

What would be the proper entry in the Message field of the “then actions” tab for this?

  • Thanks!

Hi there, in your message setup select ‘context’ in the dropdown menu, make double click and add your context key using the dot ‘.’ char:

context.my-context-key

Find attached an example.

All the best

Thanks @jotathebest, but it seems that I’m missing something, because I couldn’t make it work.

Here is how it looks:

context_1

… and here is the message with nothing in place of the context field.

"WIP_TEST_Sensor technical alert was triggered at 2019-10-29 13:47:52 -0400, for "

The context I’m trying to include is this, from the same device:

“alarm”: { “value”: 0, “context”: {“alarm”: “{{{alarm}}}”

I was able to display {{context.alarm}} in a metric vidget as well as in a values table, so I know that the data is there.

What am I missing here?

Hi there @Gabor, please gently write using the embedded chat with your issue as actually I cannot reproduce it, so I suspect that is isolated and related only to your account, using the embedded chat an IoT support specialist may assist you better than me through this forum.

All the best.

This is the answer from Sergio:

“Unfortunately, this is not possible as the events engine only captures the variable value that fulfills the condition”

Too bad :frowning:
It would be great to create a more informative alert message by including additional data from variables other than the one that triggers the event.

Anyway, thank you for your help.

Hi there @Gabor, I did not get that you needed to send data from variables different than the one that triggered the event. Right now, two options come to my mind to reach your goal:

  1. To send the alarm context value in the value that triggers the event.
  2. To use the events engine to trigger an Ubifunction, in this way, you may run a logic that will trigger an alert with the values that you need from external sources.

If you wish to expand any of the above ideas, please write back to me using this post or the embedded chat (the last one is the fastest way to get answers).

All the best

Thank you @jotathebest, I think we’ll go for workaround 1.
I just thought that - in the future - it might be helpful for your users if they could construct an outgoing message by including any of the available variables and their values/context.
-I know that coming up with ideas is thousand times easier than implementing them, so sorry for playing Smart Aleck.
Thank you for your ongoing support!

1 Like