Context ID in Device Get Node

I have a Context ID in a dashboard of ctx.deviceId-0. When I click a button on this dashboard it issues a button trigger which triggers a workflow. In that workflow I need my contextual device ID. How do I get it? I’ve tried passing it like {“deviceId”:"{{ctx.deviceId-0"}}} in on the payload which doesn’t work and reading it in the workflow as {{ctx.deviceId-0}}, neither of which work.

I’m perplexed as to why this doesn’t work:

My test workflow is just this simple:

Annotation 2019-12-12 0216372

Hi @Jason_Farque,

I would first recommend including a Debug Node within your workflow so that you can see the data as it moves in your workflow, and to reference the payload path correctly.

I see in your example above that your quotes are mismatched, which could cause an issue within the block. Would you be able to also include a screenshot of your dashboard block configuration as well?

Thanks!
Julia

I have had Debug Nodes in the workflow, I was trying to be minimalistic with my example.

The mismatched quotes are a typo, I should have cut and pasted the proper json code. Should be {“deviceId”:"{{ctx.deviceId-0}}"}. The block wouldn’t have saved with that typo in place.

Here’s my dashboard block for the button. You can see I’m trying to pass the device ID to the workflow triggered by the button. deviceId is [object Object] within the workflow.

Because I’m trying to figure out what I’m doing wrong I’m also trying to get the ctx.deviceId-0 value in the workflow itself in the Device Get node image in my original post. Neither are working. the {{ctx.deviceId-0}} in the ID Template field of the Device Get returns null.

I know this is a misunderstanding on my part but I’m stuck.

Jason

1 Like

Hi @Jason_Farque,

Thank you so much for the screenshot and additional information! I have a suspicion that you have enabled “include full device info in context” when defining your context variable. If you have enabled this checkbox, you can pass the device ID to the workflow with “{{ctx.deviceId-0.id}}”. The documentation for the Device ID context variable can be found here, and goes into further details on the object properties.

Please ket me know if I can answer any further questions! :smile:

Have a great day,
Julia

Ah, I knew it would be something simple.

Thank you, Julia!

Jason

1 Like