How do I read a device value?
More specifically - I want to get the value of a Switch (on/off) and the value of a Dimmer.
You making a webhook smartapp or Groovy?
The App is Groovy
The link I posted above is the documentation for the Device object in Groovy, which includes several examples of pulling the latest state of device attributes in a smartapp.
Thanks.
Based on my understanding from the document, to get the switch state I should do:
def swState = mySwitch.switchState
I’d expect that to return on or off. What I’m actually getting is something like:
physicalgraph.device.cassandra.DeviceState@ad93674
What I’m looking for is to get on/off, or for the dimmer level a value 0-100. Is that possible?
Did you read the first paragraph in the description of that method?
The state is an object, not a value.
https://docs.smartthings.com/en/latest/ref-docs/state-ref.html#state-ref
If you just want the value, currentValue() may be a better choice.
currentValue(“switch”) and currentValue(“level”) are what I need.
Thank you so much Tony!