Author Topic: Is Vera able to receive a http POST ?  (Read 482 times)

Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Is Vera able to receive a http POST ?
« on: June 20, 2018, 06:33:06 am »

I used Luup requests a lot these last year (http://wiki.micasaverde.com/index.php/Luup_Requests) in order to trigger action in my Vera communicated by other devices (FreePbx, IPX800, ?)

As fas as I understand (?), these requests are send as http GET message to Vera and read as such.

I have now a device (Grandstream GDS3710) that can only transmit events as http POST to the Vera. The extra difficulty is that in Post message, the parameters are in the body/payload of the message.

Is someone aware of a way to trigger action in vera and read parameters transmitted in the POST http message ?

Thanks for your help :-)

Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Is Vera able to receive a http POST ?
« Reply #1 on: June 24, 2018, 06:31:46 am »

To explain a bit further, here is the result of the POST request sent by my device (GDS3710)?

Do you see a possibility to have this understood by the Vera API ?

Thanks !

-----

Hypertext Transfer Protocol
    POST / HTTP/1.1\r\n
    User-Agent: Wget/1.16 (linux-gnueabihf)\r\n
    Accept: */*\r\n
    Host: 192.168.1.37:8000\r\n
    Connection: Keep-Alive\r\n
    Content-Type: application/x-www-form-urlencoded\r\n
    Content-Length: 105\r\n
    \r\n
    [Full request URI: http://192.168.1.37:8000/]
    [HTTP request 1/1]
    File Data: 105 bytes

HTML Form URL Encoded: application/x-www-form-urlencoded
    Form item: "id" = "lu_action"
    Form item: "DeviceNum" = "91"
    Form item: "serviceId" = "urn:upnp-org:serviceId:SwitchPower1"
    Form item: "action" = "SetTarget"
    Form item: "newTargetValue" = "1"


Offline therealdb

  • Full Member
  • ***
  • Posts: 180
  • Karma: +3/-0
  • Automate all the things!
Re: Is Vera able to receive a http POST ?
« Reply #2 on: June 24, 2018, 06:50:24 am »
Try with http handlers. AFAIK you can access parameters via POST, but can't find the exact code right now.

http://forum.micasaverde.com/index.php/topic,39814.msg296454.html#msg296454
Vera Edge EU, Fibaro FGRM 222 (12), Fibaro FGS 223 (20), Fibaro FGS 222 (5), Fibaro Universal Binary Sensor (2), Fibaro Plug (3), NeoCoolCam Door Sensor (3), NeoCoolCam PIR (2), Nest (3), Home Server running my own integrations, Harmony Hub, OpenSprinkler, Personal Weather Station, Sonoff TH & more

Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Is Vera able to receive a http POST ?
« Reply #3 on: June 24, 2018, 08:04:44 am »
Hello therealdb.

If I understand correctly, these http handlers are a solution to transmit parameters to a  lua scene via the url.

My problem is that with the post message sent by my device, it seems I am not able to perfom any lua action at all...

Offline therealdb

  • Full Member
  • ***
  • Posts: 180
  • Karma: +3/-0
  • Automate all the things!
Re: Is Vera able to receive a http POST ?
« Reply #4 on: June 24, 2018, 05:21:07 pm »
No, these are a way to execute any code you want.
You can post any Parameter and then execute some Lua code to change your desired variable.
Vera Edge EU, Fibaro FGRM 222 (12), Fibaro FGS 223 (20), Fibaro FGS 222 (5), Fibaro Universal Binary Sensor (2), Fibaro Plug (3), NeoCoolCam Door Sensor (3), NeoCoolCam PIR (2), Nest (3), Home Server running my own integrations, Harmony Hub, OpenSprinkler, Personal Weather Station, Sonoff TH & more

Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Is Vera able to receive a http POST ?
« Reply #5 on: June 25, 2018, 05:04:13 am »
I have been able to define a new handler mfh for function MyFirstHandler and to launch it using a http url in my browser http://Vera_IP:3480/data_request?id=lr_mfh

But when i try to put the same url in my device that send a http POST, nothings :-(


Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Is Vera able to receive a http POST ?
« Reply #6 on: June 25, 2018, 05:10:42 am »
Here is a screenshot of my device interface if it gives idea to someone...

The device is of course on the same network than the Vera...




Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1418
  • Karma: +80/-30
Re: Is Vera able to receive a http POST ?
« Reply #7 on: June 25, 2018, 06:38:06 am »
Hi,

The build in handler is only for GET requests. You can add parameters to the GET URL and parse those in your handler. Here is an example https://github.com/reneboer/vera-Harmony-Hub/blob/master/chm-ludl/L_Harmony.lua starting at line 1114.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline gedeon999

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Is Vera able to receive a http POST ?
« Reply #8 on: June 25, 2018, 11:09:04 am »

The build in handler is only for GET requests. You can add parameters to the GET URL and parse those in your handler. Here is an example https://github.com/reneboer/vera-Harmony-Hub/blob/master/chm-ludl/L_Harmony.lua starting at line 1114.


Thanks Rene, I will investigate if I can use this in my POST url. As it seems it is a bit beyond my level, it will get me busy sometimes :-)