Reading current state of a device

Hubitat 2.3.0.124.

Hi, I'm trying to get a current device state (the things that show up in 'Current States' on the device page). Based on the documentation it looks like I should be using:

device.getCurrentValue("name")

however, this throws an exception:

Code is:
image

To be clear, this is part of the device driver, not an app.

I'm new to driver writing so any pointers what is wrong here would be much appreciated!

https://docs.hubitat.com/index.php?title=Device_Object#currentValue

Looks like you misspelled "currentValue" as "getCurrentValue"

3 Likes

Thanks @tony.fleisher, using device.currentValue() works great. The getCurrentValue() was based on a comment by @mike.maxwell in Need help reading device attributes in device driver code, which I'm guessing refers to something different.