![]() |
|
Nest Thermostat - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Nest Thermostat (/showthread.php?tid=203) |
Nest Thermostat - Erwin van der Zwart - 25.01.2016 Hi, Does anyone tried to link LM to Google's Nest thermostat? If yes, can you post scripting to connect to the (online/cloud) API? Thanks! BR, Erwin van der Zwart RE: Nest Thermostat - admin - 26.01.2016 First, you need to get auth token, after that it's pretty simple with HTTP requests. Nest docs: https://developer.nest.com/documentation/cloud/rest-quick-guide/ Here's a short code sample: Code: function request()
local auth, url, res, stat, hdrs
require('json')
require('ssl.https')
auth = '...'
url = 'https://developer-api.nest.com/devices.json?auth=' .. auth
res, stat, hdrs = ssl.https.request(url)
if stat == 307 then
res = ssl.https.request(hdrs.location)
end
return json.decode(res)
end
res, data = pcall(request)
log(data)RE: Nest Thermostat - Erwin van der Zwart - 29.01.2016 Hi, Thanks for the info, i have a fully working connection with the REST APIĀ (read and write) Going to add Firebase now to bypass the API call maximum (: BR, Erwin |