LUA Usage Question - Accessing an attribute

Still getting my feet wet with the LUA Architecture. Trying to retrieve an attribute and somehow my syntax is not correct.

I can issue a command:

device:emit_component_event(device.profile.components.switch1, capabilities.switch.switch.off())

but I can’t seem to find the right syntax to retrieve the capability.

local state = capabilities.switch1.switch

Not sure what the syntax needs to retrieve a capability attribute.

Thanks

It should be something like this:

local state = device:get_latest_state("switch1", "switch", "switch")

Here’s the documentation:

https://developer.smartthings.com/docs/edge-device-drivers/device.html#st.Device.get_latest_state

1 Like