Jump to content
C4 Forums | Control4

Example - WWW request


Recommended Posts

Hi all,

 

I have been digging around the SDK and the developer forums, I am trying to use a thermostat driver as the base to display a temp value that is coming from my weather station (before you say EV has one - they don't have one for my weather station).

 

Now my weather station shows:

Humidty

Rain Fall

Temp

Air Condition

 

All of which are excellent variables for me to have to be able to program around. I have a weather station in each of the rooms in the house in my green house outside and a rain station in the green house to.

 

My theory:

 

I currently have  the Axxess Door bell which comes with temperature sensor and they use a "Thermostat" driver to display (in the navigator's) the temperature value. This is neat. I would like to do the same thing. Now I have done some driver coding before so I unstand the construct of a .c4i file and the XML nodes and their meaning. What I haven't done is connected out to the net and done some coding with LUA, For example to first get a Auth Token you would construct something like:

 

 

POST /oauth2/token HTTP/1.1
Host: api.netatmo.net
Content-Type: application/x-www-form-urlencoded;charset=UTF-8

grant_type=password
client_id=[YOUR_APP_ID]
client_secret=[YOUR_CLIENT_SECRET]
username=[uSER_MAIL]
password=[uSER_PASSWORD]
scope=[sCOPES_SPACE_SEPARATED]

 

And expect a response:

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"expires_in":10800,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
}

 

Then you could go ahead and construct your request: GET /api/getthermstate?access_token=[YOURTOKEN]&device_id=[RELAY_ID]&module_id=[THERM_ID] HTTP/1.1
    Host: api.netatmo.net

 

It would then return an array of values.

 

I don't need all to be explained I would appreciate if someone could point me in the right direction or has a sample driver I can have a look at?

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.