How to save the value of an attribute

I’m just getting started creating pistons, and I can’t see how to save the current value of one of a thing’s attributes. For instance if I create a piston that fires when a bulb changes from off to on or vice versa, I want to capture the new state to a variable. There’s an action to set a variable but how do I reference the on/off state or other attributes like brightness, temperature, color, etc.?

I see the system variables but how do I access attributes of a specific
device I’m working with, like the current brightness or color of a light?