Now I change for another version so before delete and never see again I think is a good idea share.
I try to explain.
I have 2 temperature selectors ( not sure the english name) and I use to init and finish times (Habitación-Encender and Habitacion-Apagar)
I use it bc i cant found another switch I can change easy. (If there is another easy version welcome please)
So I use this 2 temperature selector to put hours. I put a lua script in folder with name "script_time_habitacion.lua" and executes every minutes.
And another switch "Hab-Activa" to disabled all this hours.
Now I use google calendar to control the switches with python so I dont need more this
hope your replys and sorry for my english
Code: Select all
function dentroHorario(ahora, ini, fin)
ahora = tonumber(ahora)
ini = tonumber(ini)
fin = tonumber(fin)
if fin<ini then
if ahora>=ini then
return true;
elseif ahora<=fin then
return true
else
return false
end
else
hi = ini - ahora;
hf = fin - ahora;
if hi<=0 and hf>=0 then
return true
else
return false
end
end
end
commandArray = {}
now = os.date("*t")
habitacion = otherdevices['Habitación']
horaActual = now.hour
horaInicio = otherdevices_svalues['Habitación-Encender']
horaFin = otherdevices_svalues['Habitacion-Apagar']
print('Mirando habitacion')
print(horaActual)
print(horaInicio)
print(horaFin)
print(habitacion)
if otherdevices['Hab-Activa']=="On" then
if dentroHorario(horaActual, horaInicio, horaFin) then
if habitacion=="Off" then
commandArray['Habitación']='On'
print('**HABITACION-ON')
else
print('**HABITACION-DEJO ON')
end
else
if habitacion=="On" then
commandArray['Habitación']='Off'
print('**HABITACION-OFF')
else
print('**HABITACION-DEJO OFF')--*
end
end
end
return commandArray