Page 3 sur 3

Re: Problème script LUA chauffage

Publié : 28 déc. 2018, 23:27
par lmet
En gros :

Code : Tout sélectionner

function IsWeekend()
     local dayNow = tonumber(os.date("%w"))
     local weekend
     if (dayNow == 0) or (dayNow == 6) then weekend = true
     else weekend = false
     end 
     return weekend
end

commandArray = {}

	-- get current time
	minutesnow = timenow.min + timenow.hour * 60


	-- PROG radIATEURS VACANCES
	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "true") then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end


	-- PROG radIATEURS WEEK END
	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 06 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 10 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 35'
		commandArray['rad salon rue']='Set Level 35'
		commandArray['rad chloe']='Set Level 35'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 35'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 12 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 35'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 14 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 35'
		commandArray['rad salon rue']='Set Level 35'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 35'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 17 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 35'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 19 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 22 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 02 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'
	end
	

	if(IsWeekend() == true and uservariables["HOLIDAYS"] == "false" and timenow.hour == 04 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end
	

	-- PROG radIATEURS SEMAINE

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 05 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'	
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 06 and timenow.min == 30) then

		commandArray['rad ch1']='Set Level 25'
	end
	


	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 07 and timenow.min == 15) then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 17 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 55'
		commandArray['rad salon rue']='Set Level 55'
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 21 and timenow.min == 30) then
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 22 and timenow.min == 30) then
		commandArray['Salon jardin']='Set Level 25'
		commandArray['rad salon rue']='Set Level 25'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 23 and timenow.min == 00) then
		commandArray['rad ch1']='Set Level 25'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 02 and timenow.min == 30) then
		commandArray['rad chloe']='Set Level 55'
		commandArray['rad ch1']='Set Level 55'
		commandArray['rad Tristan']='Set Level 55'
	end
	

	if(IsWeekend() == false and uservariables["HOLIDAYS"] == "false" and timenow.hour == 04 and timenow.min == 00) then
		commandArray['rad chloe']='Set Level 25'
		commandArray['rad ch1']='Set Level 25'
		commandArray['rad Tristan']='Set Level 25'
	end

	
return commandArray

Re: Problème script LUA chauffage

Publié : 28 déc. 2018, 23:33
par fenx2002
re

bon j'ai remis des end partout et effectivement ca passe mieux

mais j'ai un nouveau problème

2018-12-28 23:30:00.134 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_all.lua: /home/pi/domoticz/scripts/lua/script_time_all.lua:13: attempt to index global 'timenow' (a nil value)

la ligne 13 est la suivante : minutesnow = timenow.min + timenow.hour * 60

Re: Problème script LUA chauffage

Publié : 28 déc. 2018, 23:48
par lmet
Avant la ligne 13 il manque peut-être :

Code : Tout sélectionner

timenow = os.date("*t")

Re: Problème script LUA chauffage

Publié : 28 déc. 2018, 23:54
par fenx2002
halleluja!

pas de pb dans le log pour le moment

j'attends de voir si ça passe au niveau des commandes

Merci en tout cas à tous pour votre aide

Bonne fin de soirée

Re: Problème script LUA chauffage

Publié : 28 déc. 2018, 23:59
par lmet
Content pour toi
Par contre cela fait beaucoup de conditions il faudra optimiser ...
Bonnes vacances :D

Re: Problème script LUA chauffage

Publié : 29 déc. 2018, 00:01
par fenx2002
yes mais avec des gamins dans les chambres je suis obligé de découper un peu mais après je me plongerais plus dedans
en tout cas merci pour tout