• 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
Using API webserver send page
#1
Hi,

I have setup pilight stable 6.0, and added some elro_800_switches succesfully. I can manage them with my remote, webpage. But now i want to switch them using de web send page.

I followed the instructions from http://www.pilight.org/development/api/#webserver, and i get a {"message":"success"} back, but the light doesn't switch.

The url i send is: send?%7B%0A%09%22action%22%3A%20%22send%22%2C%0A%09%22code%22%3A%20%7B%0A%09%09%22device%22%3A%20%22Lampbijdekeuken%22%2C%0A%09%09%22state%22%3A%20%22on%22%09%7D%0A%7D, translated:
Code:
send?{
    "action": "send",
    "code": {
        "device": "Lampbijdekeuken",
        "state": "on"    }
}
I also tried "action": "control" as stated in http://forum.pilight.org/Thread-Big-conf...ite?page=3, but that doesn't resolve my issue.

Anybody know's what i'm supposed to drop here? The docs seems a but unclear to me..
 
Reply
#2
You indeed need to use action control. This worked here:

Code:
{"action":"control","code":{"device":"kerstlicht","state":"off"}}
Ofc, urlencoded.
 
Reply
#3
Thanks for your quick response. Finally i found it: I had to remove all space's and tabs inside the message.. So it's working now!

my send message:
Code:
{"action":"control","code":{"device":"Lampbijdekeuken","state":"on"}}
translated as
Code:
send?%7B%22action%22%3A%22control%22%2C%22code%22%3A%7B%22device%22%3A%22Lampbijdekeuken%22%2C%22state%22%3A%22on%22%7D%7D
is working now!

You also need to put "send?" before the code, and do not 'encode' the question mark! Thats not working. Smile

ps: handy translator here: http://meyerweb.com/eric/tools/dencoder/
 
Reply
#4
Hey, I have a similar issue here with a "generic_label". Target is, using curl from other Pi send free disk space to pilight.

Label settings (without overhead):
Code:
"gen-lbl-satahdd-diskspace": {
                        "protocol": [ "generic_label" ],
                        "id": [{
                                "id": 202
                        }],
                        "label": "(none)",
                        "color": "black"
                },
Calling URL (encoded):
Code:
curl http://192.168.122.65:5001/send?%7B%22action%22%3A%22control%22%2C%22code%22%3A%7B%22device%22%3A%22gen-lbl-satahdd-diskspace%22%2C%22state%22%3A%22$size%22%7D%7D
URL (decoded):
Code:
curl http://192.168.122.65:5001/send?{"action":"control","code":{"device":"gen-lbl-satahdd-diskspace","state":"$size"}}
Also tried this without any changes:
Code:
curl http://192.168.122.65:5001/send?{"action":"control","code":{"device":"gen-lbl-satahdd-diskspace","label":"$size"}}
I then get a following message:
Code:
{"message":"success"}#
.. but nothing happens. Tailing /var/log/pilight.log gives this:
Code:
[ May 28 09:31:15:31498] pilight-daemon: ERROR: generic_label: insufficient number of arguments

What am I missing?
 
Reply
#5
http://forum.pilight.org/Thread-api-does...9#pid12909
 
Reply
#6
Thanks, working like a charm. I doubt I would have looked into that one topic though..
BTW, you have used my naming scheme there.. I'm impressed.. Big Grin
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Already fixed in 8.1.2] Loss of webserver-connection Ulrich.Arnold 34 2,312 08-02-2019, 02:25 PM
Last Post: curlymo
  pilight-send does not stop (terminate) va13 3 477 05-15-2019, 06:06 PM
Last Post: curlymo
  RSL366 receive fine, can't send? pukington 2 570 02-15-2018, 11:04 AM
Last Post: pukington
  pilight-send for like rc-switch "send" mindau 1 1,407 01-18-2018, 07:46 AM
Last Post: madmoses
  send-repeats and elro_800_switch Tiberian 2 1,059 11-04-2017, 06:24 PM
Last Post: Tiberian
  Webserver (REST API) - POST TopdRob 7 1,613 10-25-2017, 11:17 PM
Last Post: curlymo
Question How to send custom code? abash 2 987 10-11-2017, 06:11 PM
Last Post: curlymo
  pilight send URLEncode sibi 0 752 07-17-2017, 08:59 PM
Last Post: sibi
  i can send alright - no luck receiving varmluft 3 1,185 02-26-2017, 09:16 PM
Last Post: wo_rasp
  webserver-authentication problem with some browsers MorfelPi 4 1,831 09-21-2016, 06:59 PM
Last Post: Emiks5

Forum Jump:


Browsing: 1 Guest(s)