-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathferm_auto_chambre.lua
55 lines (52 loc) · 2.14 KB
/
ferm_auto_chambre.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-----------------------------------------------
------------- Variables à éditer --------------
-----------------------------------------------
local reference = 'Dehors' --Sonde extérieure
local hysteresis = 0.5 --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
local sonde = 'Chambre' --Nom de la sonde de température
local volet = 'Volet chambre'
local actioneur = 'Fermeture_chambre'
-----------------------------------------------
--------- Fin des variables à éditer ----------
-----------------------------------------------
-----------------------------------------------
------- Fonction de découpage de string -------
-----------------------------------------------
function mysplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t,str)
end
return t
end
-----------------------------------------------
-- Fin de la fonction de découpage de string --
-----------------------------------------------
commandArray = {}
if (devicechanged[sonde]) then
local temperature = devicechanged[string.format('%s_Temperature', sonde)]
local exterieur = mysplit(otherdevices_svalues[string.format(reference)],";")
local statut = otherdevices[volet]
-- print ('Température de la chambre :' .. temperature)
-- print ('Température de dehors :' .. exterieur[1])
hour = os.date("%H")
if (tonumber(hour) > 9 and tonumber(hour) < 19 and otherdevices['Presence'] == "Off") then
if (tonumber(exterieur[1]) > temperature ) then
-- print('Il fait plus chaud dehors de dedans, il faut fermer la chambre')
if (tonumber(exterieur[1]) > temperature + 2 ) then
if ( statut ~= 'Closed' ) then
commandArray[0]={[volet]='On'}
end
else
if ( statut ~= 'Closed' and statut ~= 'Stopped' ) then
-- print('On ferme !')
commandArray[0]={[actioneur]='On'}
end
end
end
end
end
return commandArray