Can you share a screenshot of the rule or PM @support the rule ID so we can take a closer look?
This is the section of the rule throwing the error:
For clarity, hereās my test rule. The top action fails, the lower action works. And I canāt find a way to have the context variable in the latter.
Update: The JSON Editor now supports inline expressions!
The JSON data format currently does not support inserting a variable. If your original screenshot showing the logs was for JSON argument, then it makes sense that it showed the raw {{$context.response.data.result}}
string as it is not currently translated. I can look into what it would take to support that, but itās not something Iāll be able to get to immediately.
In the follow-up reply that showed a string argument that has a variable in it, that should be handled fine from the SharpTools side of things and your SharpTools logs should show the context variable being parsed and injected as expected. From what I understand, the driver doesnāt seem to handle that format though?
Have you tested the exact same format that worked as a JSON argument type {}
(from the second part of the second screenshot) as a string Aa
to verify that the driver isnāt handling the JSON data formatted as a string?
Have you watched the driver logs to see how it is handling the arguments that are being passed to it? Considering the string format of an object has worked for other device types, I suspected that maybe the SmartThings API was inherently handling the parsing of these requests, but itās possible that the parsing is something they coded into specific drivers. In which case, I wonder if Mariano would entertain parsing a string formatted JSON object. I think the first step here is identifying what the driver is actually seeing though.
Thanks for your feedback Josh.
In the first example I showed that was using a string argument.
I am getting the failure message when sending the argument as a string.
For the test rule I show above hereās the log for the first action using a string argument containing the context variable (this one fails):
Hereās the log for the second action using a JSON argument (this works):
If I submit the argument as a string WITHOUT the context variable it also fails:
Iāll have to work on this. I donāt currently know how to get driver logs. I guess Iām going to have to learn the CLI properly.
Thanks for the clarification. You could also just try floating the question to Mariano. He might know off the top of his head why it would work with one driver but not another.
I suspected the SmartThings REST API was handling the parsing, but itās possible they were doing it within all the drivers that Iāve tested with so far. Without knowing why the JSON as a String format is failing with his driver (eg. no logs), I donāt have a lot of insight as to why it doesnāt work with his driver. Itās certainly possible that it was a per-driver thing with the parsing and maybe Mariano would be open to adding that to his driver.
Otherwise, I will take a look at what it would take to add the context variable parsing to the JSON argument format, I just wonāt be able to get to it right away.
Will do. Iāll bring it up to him over on the ST community and Iāll follow-up here with anything I learn.
Thank you.
Latest update after working with Mariano.
It appears nothing makes it through the API with the argument sent as a string. Doesnāt make sense to me.
I guess at this point Iām lost.
I send a string/text in other cases and it works. But those that work are DTHs not drivers. Is that the issue here?
Thanks for the update. Iāll look into it ā in the meantime, could you call the setHue()
command to change the color with your variable?
If the saturation of your bulbs also change, you could use the setSaturation()
command as well.
Iāll give this a try today, thanks.
As expected, working fine when sending the numeric values.
As Iām reading through this, am I understanding correctly that SmartThings isnāt parsing the setColor() parameters? Iām using the stock Zigbee RGBW Bulb DTH and passing the input argument {āhueā:83,āsaturationā:100,ālevelā:7} and it isnāt working.
If I am understanding correctly, I should just sent those one at a time with setHue, setSaturation, and setLevel?
Can you share a screenshot of your rule? Or at least the setColor() command?
Interesting. Iām also using the āZigbee RGBW Bulbā DTH with a Sengled Multicolor bulb and that format works (though the device ignores the level
parameter within the object).
Iād be curious if the issue persists once the device gets moved over to an Edge Driver. Kind of concerning that these devices havenāt been moved to Edge Drivers with only 26 days until the expected Groovy shutdown.
You could try using the advanced toggle and changing the argument type to a string and using the same format, but I suspect that may only work for Groovy devices and might stop working when the device cuts over to an Edge driver.
As you noted, the individual setHue()
and setLevel()
commands could be an option for you as well.
Just to confirm, are you actually having an issue with those commands or you were just curious based on reading through the thread?
If youāre having issues, what do the rule logs say? Iām curious if the commands are going through successfully and theyāre just being dropped or if thereās an error reported.
The hue and saturation values do match, but they were already that before the device turned on. Itās the level that I saw that didnāt change, so I just assumed all of it didnāt work. Looks like my behavior is the same as what you are seeing then.
My thoughts exactly, but Iāll keep my fingers crossed
Has anyone had any luck with this? Iām unable to use a variable to setColor. Hardcode works fineā¦ Iām trying to sync color between devices when one changes.
HI @Jim_Ray - welcome to the community. Have you tried either of the below approaches? Using the setHue()
command is usually pretty standard across all the devices whereas trying to put an color object in string format is more hit-or-miss.
Hi @josh, Thanks for the reply. Yes, I cut this device over to an edge driver and thatās what started all this for me. It isnāt an official driver, so I may just be out of luck for now. I tried setting only the hueā¦ I do not get an error, but nothing happens.