Hey Derek,
First off, congrats on making such a fantastic service. I just came across it yesterday after slamming my head against the limitations of IFTTT and already I can see the potential. I'll certainly be donating.
One scenario I'd love some guidance with is this: I have a Kasa light switch for some outdoor lights and a Wyze camera. I have a sequence that can turn the Kasa light on for 5 minutes after motion is detected on a camera. I'll add in the conditions of after sunset after.
That Kasa light is on a schedule from sunset to 11pm. What I'd like is for a sequence is, after a motion trigger, to check the state of the light before deciding to turn it on (or off). If it's already on (either due to it being before 10pm or if it's manually turned on OR if it's on due to previous motion) then don't run the on-delay-off sequence.
Kasa does have a convoluted method of getting the current state of the light through a through a curl command similar to this:
curl -s --request POST https://use1-wap.tplinkcloud.com/?token=XXX_SECRET_TOKEN_XXX --data '{"method":"passthrough","params":{"deviceId":"XXX_SECRET_DEVICE_ID_XXX","requestData":"{\"system\":{\"get_sysinfo\":null},\"emeter\":{\"get_realtime\":null}}"}}' --header "Content-Type:application/json"
That results in a response like this:
{"error_code":0,"result":{"responseData":"{\"system\":{\"get_sysinfo\":{\"sw_ver\":\"1.5.11 Build 200214 Rel.152651\",\"hw_ver\":\"1.0\",\"mic_type\":\"IOT.SMARTPLUGSWITCH\",\"model\":\"HS220(US)\",\"mac\":\"XX:XX:XX:XX:XX:XX\",\"dev_name\":\"Smart Wi-Fi Dimmer\",\"alias\":\"Garage Soffits\",\"relay_state\":0,\"brightness\":68,\"on_time\":0,\"active_mode\":\"none\",\"feature\":\"TIM\",\"updating\":0,\"icon_hash\":\"\",\"rssi\":-50,\"led_off\":0,\"longitude_i\":-1135607,\"latitude_i\":535573,\"hwId\":\"XXXXXXXXXXXXXXXXXXXX\",\"fwId\":\"00000000000000000000000000000000\",\"deviceId\":\"XXX_DEVICE_ID_XXX\",\"oemId\":\"XXX_OEM_ID_XXX\",\"preferred_state\":[{\"index\":0,\"brightness\":100},{\"index\":1,\"brightness\":60},{\"index\":2,\"brightness\":30},{\"index\":3,\"brightness\":1}],\"next_action\":{\"type\":-1},\"err_code\":0}},\"emeter\":{\"get_realtime\":{\"err_code\":-1,\"err_msg\":\"module not support\"}}}"}}(base)
The piece to grab out of the JSON is the "relay_state" which will be 0 if off, 1 if on. I understand it would be something like responseData-system-get_sysinfo-relay_state but I'm not sure how to store that variable, or evaluate it as a condition.
Hope that makes sense!
Thanks again.