Using HTTP Shortcuts, I finally figured out the right JSON command to set the brightness level on my Kasa HS220 smart dimmer switch. You need to have a current token, UUID, and device ID for the Kasa switch.
First I created a variable in HTTP Shortcuts by clicking on the 3 dots and using variables to create a static variable (constant) and gave in the name KasaLevel. I put a value of 10 in for the level and checked the URL encode option. I also created variables for my KasaToken, KasaTermID, and KasaDevID and put my current token, UUID, and device ID for the switch into those variables also with the URL encode option checked.
1) I then created a shortcut with the text below as the basic request settings. The variables for {KasaToken} and {KasaTermID} need to be included by clicking on the {} in the upper right corner.
https://use1-wap.tplinkcloud.com/?token={KasaToken}&appName=Kasa_Android&termID={KasaTermID}&appVer=1.4.4.607&ospf=Android+6.0.1&netType=wifi&locale=en_US HTTP/1.1
2) I then added a request header with header of Content-Type and value of application/json.
3) And finally I set the request body/parameters with custom text and a request body as shown below with the variables for {KasaDevID} and {KasaLevel} included by clicking on the {} in the upper right corner.
{
"method":"passthrough",
"params":{
"deviceId":"{KasaDevID}",
"requestData":{
"system":{
"set_relay_state":{
"state":1
}
},
"smartlife.iot.dimmer":{
"set_brightness":{
"brightness":{KasaLevel}
}
}
}
}
}
Once the HTTP shortcut is created, a long click on the title pops up a new menu and choosing "Show Info" gets a Deep-Linking URL. The URL can be used in macrodroid with a send intent as described above.
For me, in macrodroid, I created a macro with a local variable called "KasaLevel" and gave it a value. Then I inserted a "Send Intent" action with the Target set as "Activity" and Data as the URL copied from the HTTP Shortcut Deep-Linking URL, followed by ?KasaLevel=[lv=KasaLevel] with the last part inserted via the "..." button and choosing the local variable I named KasaLevel.