Using $context Values in Expression

Hi Kevin - you can find the high level documentation on Context Variables on the following page:

I would note that the documentation was written around using context variables directly through the Variable Picker (eg. in a condition or inserting it into a notification), so each of the full $context.xxx.yyy names aren’t necessarily documented there.

You can temporarily create a condition block and as you pick an option from the picker, you’ll be able to see the final variable name in the condition and you can use that in your expression. I’ve made note of the feedback though as the documentation should probably contain that information now that you can freeform enter it into an expression.

It sounds like you’re trying to get an arbitrary device’s state to use in an expression. As briefly mentioned in our other discussion, you would need to temporarily store the device state into a variable to use it in a condition. While you can access context variables about the event that triggered the rule to run (eg. $context.event.value) or reference global variables (eg. $MyTemperature), you can’t access arbitrary device state directly in an expression.

@Jeff_L recently posted a similar discussion with a similar interest. As I mentioned over there, the best way to get these kind of enhancements in place is to create a feature request and get it upvoted. Feature requests are a key part of how we prioritize what we work on and with other WebCoRE users switching over, I suspect you could probably get some votes on it.

I’ll post an update as to the ‘why’ of expressions not currently being able to reference device state directly in Jeff’s thread if you’re looking for some insight if you want to draft a feature request.