Smartswitch - if wattage is lower than 10.. Vera Alert send

I was searching around the forum and came up with this code

[code]luup.sleep(10000)

local lul_watts1=luup.variable_get(“urn:micasaverde-com:serviceId:EnergyMetering1”,“Watts”,19)
local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, 19)

if (( tonumber(lul_watts1) < 10 ) and (lul_tmp == “1”))
then
return true
else
return false
end[/code]

This is the the Luup section of a scene that’s triggered when the Dehumidifer (Smartswitch) turns on. If the Smartswitch is on and the wattage is lower than 10, then send a Vera Alert notifying me that the Dehumidifier is full.
The problem is it sends the notification even if wattage is over 10. When the Smartswitch is off, it won’t send the notification (which would make it false). I’m not sure what in the luup code is making it true when wattage is over 10. Any insight would be greatly appreciated.

I took out luup.sleep function. Instead, I delayed the vera alert notification, but it’s still not working.

Ok, so when the scene is triggered, it will alert me. I believe the setting of the variables is too soon and the device needs a couple seconds to get the actual wattage. I’ve tested this by running the scene manually after the smartswitch has been on for about 5 seconds. When I do this, vera alert will not notify me because the luup code returns false. That’s why I tried the sleep function not knowing exactly what it did. How else do I delay luup code? I tried luup.call_delay(function, sec) but that didn’t work (or perhaps I had it wrong).

I’ve decided to use PLEG for this. I’m not sure if I’ve got it right though.

I have 1 Trigger which is the Dehumidifier(Smartswitch) ON - Dehumid_On
I have 2 Device Properties which are :
dehumidStatus - Status
dehumidWatt - Watts

Condition (DehumidFull) Dehumid_On AND (Dehumid_On; NOW > 00:00:10) AND dehumidStatus AND dehumidWatt < 5

I think it’s working. When I run the dehumidifer, no notification is sent because the wattage is over 5. I switched the operator (for testing purposes) to > 5 and a notification was sent. Will have to test it out further tomorrow as it’s getting late.