Pages: [1]   Go Down
Author Topic: Send/ Receive data to Fibaro HC2 using REST API  (Read 3 times)
0 Members and 2 Guests are viewing this topic.
Online Online
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Please could anyone help with the Arduino code required to PUT data on to a Fibaro Home Centre 2 (HC2) using their latest REST API? The plan is to connect I/O and temperature sensors to my Arduino Mega and send data to my HC2 using HTTP requests. I want to PUT the HTTP requests to global variables on the HC2 and create scenes to control lighting, heating, etc.

So far I have managed to GET data using the following code. The global variable is called test and only seems to work with Basic Authorization.

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.print("GET http://192.168.4.100:80/api/globalVariables/test");
    client.println(" HTTP/1.1");
    client.println("Host: 192.168.4.100");
    client.println("Authorization: Basic xxxxxxxxxxxxxxx");
    client.println();
  }

I'm not sure how to PUT data as I need to send a request parameter in JSON?

I managed to update the variable using WCFSTORM.REST, so I think it's possible. I'm just not sure what code is required (after many hours of failed attempts)? I've used WireShark but to be honest, this is beyond me. I'm also new to Arduino/ programming.

The request parameter I want to send follows:

{
  "test": "1"
}

Logged

Pages: [1]   Go Up
Jump to: