Kasa tp-link and currentValue

I came from ST and can't seem to get currentValue to work with Hubitat like it did in Smartthings.
Any ideas?

Example of code....
note: desklamp is a tp-link plug (HS105)
def desklamp_state = "on"

desklamp_state = desklamp.currentValue("switch") //get state of desk lamp

if (desklamp_state == "on"){
....do stuff.....

1 Like

in a driver it's device.currentValue("attribute name")
this whole thing here can be simplified to:

if (device.currentValue("switch") == "on") { //do stuff here...}

Welcome to the community!

Just an FYI @djgutheinz has created a phenomenal local solution for TP-Link/Kasa devices. Check it out: [RELEASE] TP-Link Plug, Switch, and Bulb integration


Agreed, it works amazingly well and locally!

1 Like

Opps. My problem was in the ....do stuff here.... code. Thanks for the input and code reduction idea.