• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switch device with http request
#1
Hello,

is there any way to send a http request to the pilight webserver, to switch a device?

For example: "http://192.168.100.5:80/switch?device=tv&state=on"

Thanks
 
Reply
#2
Yes, check the API page.
 
Reply
#3
I already read this before but it don't understand, what i have to send.

This:

Code:
http://192.168.100.42:80/{"action":"control","code":{"device":"device2","state":"on"}}

Edit:

Thanks! No i can switch my lights with the pebble.

The hyperlink to switch is:

Code:
http://192.168.1.2/send?{%22action%22%3A%22control%22%2C%22code%22%3A{%22device%22%3A%22TVWohn%22%2C%22state%22%3A%22off%22}}
 
Reply
#4
Yes, just URL-encode all the characters of the code.
 
Reply
#5
I am also having trouble with my HTTP send requests now that I am on nightlies (was fine on V5 but now I am on V7.0). The webserver GUI works a treat but I am going to use my phone and mobotix IP cameras to trigger events using HTTP requests.

My device code from config.json:

Code:
"studyfloorlamp": {
    "protocol": [ "kambrook" ],
    "id": [{
        "id": 12058,
        "unit": 2
    }],
    "state": "off"
}

the URL I am sending to:

Code:
http://172.16.1.17:5001/send?%7B%0D%0A%09%22action%22%3A+%22control%22%2C%0D%0A%09%22code%22%3A+%7B%0D%0A%09%09%22device%22%3A+%22studyfloorlamp%22%2C%0D%0A%09%09%22state%22%3A+%22on%22%0D%0A%09%7D%0D%0A%7D

the message decoded:

Code:
{
    "action": "control",
    "code": {
        "device": "studyfloorlamp",
        "state": "on"
    }
}

all i get as a response now is

{"message":"failed"}

Can somebody point me in the right direction please?
 
Reply
#6
I would advice you to use the new API present in the latest nightly.:
Code:
http://x.x.x.x/control?device=studyfloorlamp&state=on
 
Reply
#7
Is this also possible from outside your own network ( so with login credentials)?
 
Reply
#8
I'm not sure about login credentials, but if you configure port-forwarding on your router for the pilight daemon, you should be able to access it remotely. But it's kind of insecure, anyone can control your pilight devices then (if they know your IP and pilight port...)
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [SOLVED] Home Assistant switch gpio segalion 5 817 09-10-2018, 12:39 PM
Last Post: segalion
  pilight 8.1 and switch with date and time not working Pikeman 7 991 06-30-2018, 11:28 PM
Last Post: curlymo
  pilight-send for like rc-switch "send" mindau 1 1,467 01-18-2018, 07:46 AM
Last Post: madmoses
  Windows HTTP connection andbehtls 1 1,090 01-14-2018, 02:24 PM
Last Post: bnk72
  [Fully Supported] Conrad RSL Switch Hexcode 137 45,881 12-02-2017, 08:48 AM
Last Post: Micha_123
Smile config, device uuid <-> id Twain 2 1,206 06-22-2017, 05:49 PM
Last Post: Twain
  rev switch: maybe mismatch in sending on and off codes picrafter 2 1,582 04-15-2017, 02:49 PM
Last Post: redraid
  Problem with a Switch rule viper2035 2 1,311 01-12-2017, 04:33 PM
Last Post: viper2035
  Light Switch with integrated ON/OFF Button ilir@ademi.org 4 1,931 01-04-2017, 09:22 PM
Last Post: ilir@ademi.org
  All remotes should switch via pilight Laret 2 1,515 12-07-2016, 08:36 PM
Last Post: Laret

Forum Jump:


Browsing: 1 Guest(s)