Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
Unified_io 0
Hi!
Let me start off by saying I've zero experience and knowledge with working with API's so I'm not sure if this is even going to be possible.
I'm trying to make a Virtual Device to turn on/off some TP-Link Smart Plugs I have.
The Controller I'm using is a HCL
I've scoured the Internet and found a way of controlling these plugs via a HTTP POST request. To turn on the plug you can use the following (and to turn off you can simply substitute the state value with a 0 to turn off)
curl --request POST "https://your_region_specific_url/?token=your_token_here HTTP/1.1" \
--data '{"method":"passthrough", "params": {"deviceId": "your_device_id_here", "requestData": "{\"system\":{\"set_relay_state\":{\"state\":0}}}" }}' \
--header "Content-Type: application/json"
And to get the device state, you can use the following:
curl -s --request POST "https://your_region_specific_url/?token=your_token_here HTTP/1.1"\
--data '{"method":"passthrough", "params": {"deviceId": "your_device_id_here", "requestData": "{\"system\":{\"get_sysinfo\":null},\"emeter\":{\"get_realtime\":null}}" }}'\
--header "Content-Type: application/json" | grep -q '..relay_state..:1' && echo "ON" || echo "OFF"
How would I format this to make it compatible for buttons on a HCL compatible VD? I've spent a couple of hours trial and error but getting nowhere (mainly because I can't seem to find any error logs - does the HCL even have any?)
I'd be incredibly appreciative of some help!
UPDATE
I'm guessing this would be the correct format for the buttons however I still don't seem to be able to get this to work?
POST /?token=your_token_here HTTP/1.1
Host: your_regional_specific_url_here
Content-Type: application/json
{"method":"passthrough", "params": {"deviceId": "your_device_id_here", "requestData": "{\"system\":{\"set_relay_state\":{\"state\":0}}}" }}
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.