Send value of a Device via Email using Analytics Builder

Product/components used and version/fix level:

Cumulocity IOT and Analytics Builder

Detailed explanation of the problem:

we are trying to send a value of a Device via eMail ones a Day.

Question related to a free trial, or to a production (customer) instance?

Production

how to get the device value in the eMail Text.?

Thank you

Mirko

Hi,

What do you mean by the device value? Is it the name of the device, or id of the device or some property on the device?

You can use Text Substitution block. If you are connecting the output of the Managed input block to the Object input port of the Text Substitution block, you can use a string with placeholders like #{prop_name}. So, for example:

  • To get ID of the device: #{id}
  • To get name of the device: #{name}
  • To get a simple custom property on the device: #{my_prop_name}
  • To get a nested custom property on the device: #{my_prop.value}

Thanks,
Gyan

Hi Gyanendra,

sorry its a while ago.

i mean i want send the Latest Measurement of the device by email.

like:
This is the latest Measurement: #{latestMeasurement}

Best Regards

Mirko

Hi Mirko,

In that case, connect the output port of the Measurement Input block to the Object port of the Text Substitution block like you have already done. Then you can use This is the latest Measurement: #{value} in the Text Substitution block to replace the #{value} with latest measurement value.

Thanks,
Gyans

Hi Gyanendra,

unfortunately it is not working. I recive an email with #{value} and it is sill not replaced.

Mirko

Hi Mirko,

Can you export the model JSON and share it with me?

Thanks,
Gyan

Hi Gyanendra,

here it is. Thank you very much.

Mirko
email.json.zip (1.5 KB)

You have connected to the Source port of the Text Substitution block. When connected to this port you have to prefix the property names with source. and when connected to the Object port of the block, you do not have to prefix anything. See the ‘Input Port Details’ section of the output doc.

In your case, you should use: This is the latest #{source.value}.

1 Like

Hello,

Thank you very much for your help. I finally got it done.

I found the mistake. My sensor only transmits a measured value every 2 hours and #{value} shows the last measured value AFTER the analytics rule was set to ACTIVE. Until then, no value (in my case an empty email) is sent. After I simply wait until a valid measurement value has been received, the email also works.

Best Regards

Mirko

2 Likes