I have a networked lighting controller that accepts post commands. Simple on/off commands work but I can’t seem to get the level value to pass in the POST request. It just keeps reporting as ‘null’ and sets intensity to 0%.
Commands are formatted like this :
I’m trying to get the slider level to be a variable in the passed POST but it always returns ‘null’
Like @tgauchat said have you tried doing a simple log.debug $level to see if the variable even has what you’re looking for? Also, I’m doing something somewhat similar and had to use the code device.currentValue(“level”) to get the current slider level. You might try that as well.
I have a log.debug stating the level inside of def setLevel. It shows the slider value. I was trying to get the value into the def on() but it would always be null. I added the post command inside of setLevel and it works. I don’t quite understand the way the “def”'s work yet.
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
The scope of a “defined variable” is only the current method.
SmartTiles “sandbox” does not allow creation global variables, but provides “state” map as an option that already has scope of the entire SmartApp (or DTH?). Please see the developer documentation.
However, if you are using an Attribute – they are NOT variables!!! But they can be read using currentValue(attribute-name), and written using “sendEvent”.
Great! Thanks for all your help @tgauchat !! Now if I could just figure out this hubAction thing for local network post I’d be all set. Currently works with dyndns setup and forwarded ports, but I’d rather my server not be publicly accessible for lack of authentication ability.
Wow, I feel really dumb now. After seeing it in github I noticed the sendEvent value didn’t have quotes. All works now. lol no more null numbers. Any direction on the hubAction would be appreciated though.