Aller au contenu

Recommended Posts

Bonjour a vous , j'ai essayé de mettre cet code en LUA  dans ma HC2 (vers 4.080) avec l'aide de IFTTT si il y'a une porte/fenêtre ouverte , on peut couper la chaleur tant qu'une porte ou fenêtre est ouverte .


--[[
%% properties
239 value   --here you add your sensor ID and the word value. This section is checking for changes in the    			 --value field for your sensors to start below code. I am using 3 door/window sensors 
%% globals
--]]

local PorteCuisine  --defining variables for window sensor
local NestSetpoint 
local param1
local key

PorteCuisine = fibaro:getValue(239, 'value') --this will pull a current state(value) of the sensor
											  --1 is on and 0 is off
 
NestSetpoint = fibaro:getValue(111, "setpointTemp2")  --this is a current temperature you have set on Nest

if (PorteCuisine == '1') then
 
	param1 = "17"  --this is the termperature you want to be set when windows/door are open

end

if (PorteCuisine == '0') then
  
	fibaro:debug(NestSetpoint)
  	param1 = NestSetpoint    -- once all door/windows are closed, temperature will be set to previous set.
  
end

	fibaro:debug(NestSetpoint)	
	fibaro:debug(param1)

	--------------------------------------
         --this section is used to send command to IFTTT with required Nest temperature    

        key = "GWG27en7Bm6x5UHaAxOF6"  --use your key from the Maker channel on IFTTT

	function PushData(key, event, param1)
 
	local httpClient = net.HTTPClient({ timeout = 2000 });
 
	local url = 'https://maker.ifttt.com/trigger/set_nest_temperature/with/key/'..key..'?value1='..param1;
 
	--debug url
 
	print(url);
 
	httpClient:request(url, {
 
	success = function(response)
 
		if tonumber(response.status) == 200 then
 
			print("Updated at " .. os.date());
 
		else
 
			print("Error " .. response.status)
 
		end
 
	end,
 
	error = function(err)
 
	print('error = ' .. err)
 
	end,
 
	options = {
 
	method = 'GET'
 
	}
 
	});
 
	end
 
	PushData(key, event, param1);
  


[DEBUG] 13:41:32: 17
[DEBUG] 13:41:32: https://maker.ifttt.com/trigger/set_nest_temperature/with/key/GWG27en7Bm6x5UHaAxOF6?value1=17
[DEBUG] 13:41:33: Updated at Sat Mar 26 13:41:33 2016
[DEBUG] 13:45:42: 23
[DEBUG] 13:45:42: 23
[DEBUG] 13:45:42: 23
[DEBUG] 13:45:42: https://maker.ifttt.com/trigger/set_nest_temperature/with/key/GWG27en7Bm6x5UHaAxOF6?value1=23
[DEBUG] 13:45:43: Updated at Sat Mar 26 13:45:43 2016
[DEBUG] 13:46:10: 23
[DEBUG] 13:46:10: 23
[DEBUG] 13:46:10: 23
[DEBUG] 13:46:10: https://maker.ifttt.com/trigger/set_nest_temperature/with/key/GWG27en7Bm6x5UHaAxOF6?value1=23
[DEBUG] 13:46:10: Updated at Sat Mar 26 13:46:10 2016
[DEBUG] 14:52:14: 23
[DEBUG] 14:52:14: 17
[DEBUG] 14:52:14: https://maker.ifttt.com/trigger/set_nest_temperature/with/key/GWG27en7Bm6x5UHaAxOF6?value1=17
[DEBUG] 14:52:15: Updated at Sat Mar 26 14:52:15 2016

 le problème est que j'ouvre ou je ferme la porte rien qui se passe sur Nest, 

Es-ce que quelqu'un d'entre vous a une idée ...

Merci d'avance 

Partager ce message


Lien à poster
Partager sur d’autres sites

×