hello all, I have been successfully sending requests to my device, but i need to make my coding a little more versatile. this is what i have so far:
def post_to_dev(def dev_link, def dev_type, def dev_action)
{
log.debug "sending request to device: ${dev_link} -> ${dev_type}:${dev_action}"
def params = [
uri: "https://xxxxxx.com/${dev_link}",
body: ["${dev_type}" : "$dev_action"]
]
try {
httpPostJson(params)
}
catch (e)
{
log.debug "something went wrong: $e"
}
}
sending like this:
post_to_dev("xxxxxxxxxxxxxxxxxx" , "pin9" , "ON")
when i send pin9: ON it never goes as "ON"
my problem is at this line:
body: ["${dev_type}" : "$dev_action"]
i need the “$dev_action” to br variable.
I have tried:
"$dev_action"
$dev_action
dev_action
nothing works. It only works when i replace specifically
body: ["${dev_type}" : "ON"]
or
body: ["${dev_type}" : "OFF"]
Could someone help?