Allumage par capteur et inter

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Allumage par capteur et inter

Message par Wolfen38 »

Salut à tous, j'ai 2 script pour ma sdb, un pour allumer 2min quand le capteur de présence détecte quelqu'un qui ressemble a ca :

Code : Tout sélectionner

t1 = os.time()
s = otherdevices_lastupdate['Virtuel SDB']

year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)

commandArray = {}

t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (devicechanged['Detecteur SDB'] == 'On' and difference > 10 and otherdevices['Virtuel SDB Coupure'] == 'Off') then
	commandArray['Virtuel plafonnier']='On FOR 2'

end 


return commandArray
et un autre script pour allumer si on appuie sur l'inter pour que la lumiere reste allumer.

Code : Tout sélectionner

commandArray = {}
 
 if (devicechanged['Virtuel plafonnier'] == 'On') then
    commandArray['Group:Plafonnier SDB']='On'
	
	else
	
	if (devicechanged['Virtuel plafonnier'] == 'Off') then
    commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Plafonnier SDB']='Off'
	end

end
	

 if (devicechanged['Interrupteur SDB'] == 'Click' and otherdevices['Virtuel SDB'] == 'Off') then
    commandArray['Interrupteur SDB']='Off'
	print("Inter sdb OFF de ON")
	commandArray['Group:Plafonnier SDB']='Off'
	print("Groupe Plafonnier SDB Off de ON")
	commandArray['Virtuel plafonnier']='Off'
	print("Virtuel plafonnier OFF de ON")
	commandArray['Virtuel SDB']='On'
	print("Virtuel sdb ON de ON")
	commandArray['Group:Plafonnier SDB']='On'
	print("Groupe Plafonnier SDB ON de ON")
		
	
	else
	if (devicechanged['Interrupteur SDB'] == 'Click' and otherdevices['Virtuel SDB'] == 'On') then
		commandArray['Interrupteur SDB']='Off'
		print("Interrupteur SDB off de off")
		commandArray['Group:Plafonnier SDB']='Off'
		print("Groupe Plafonnier SDB OFF de Off")
		commandArray['Group:Plafonnier WC']='Off'
		print("Groupe Plafonnier WC Off de off")
		commandArray['Group:Ampoule SDB']='Off'
		print("Group:Ampoule SDB Off de Off")
		commandArray['Group:Lumiere SDB']='Off'
		print("Groupe Lumiere SDB Off  de Off")
		commandArray['Plafonnier SDB']='Off'
		print("Plafonnier SDB Off de Off")
		commandArray['Ampoule SDB']='Off'
		print("Ampoule SDB Off de Off")
		commandArray['Virtuel SDB']='Off'
		print("Virtuel SDB Off e Off")
		end
	
end

if (devicechanged['Interrupteur SDB'] == 'Double Click' and otherdevices['Virtuel SDB'] == 'Off') then
	commandArray['Interrupteur SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Virtuel SDB']='On'
	commandArray['Group:Ampoule SDB']='On'
		
	else
	if (devicechanged['Interrupteur SDB'] == 'Double Click' and otherdevices['Virtuel SDB'] == 'On') then
		commandArray['Interrupteur SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Virtuel SDB']='On'
	commandArray['Group:Plafonnier SDB']='On'
	end
	
end

if ((devicechanged['Interrupteur SDB'] == 'Long Click' and otherdevices['Virtuel SDB Coupure'] == 'Off') or (devicechanged['Interrupteur SDB'] == 'Long Click Release' and otherdevices['Virtuel SDB Coupure'] == 'Off')) then
	commandArray['Interrupteur SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Group:Lumiere SDB']='Off'
	commandArray['Virtuel SDB Coupure']='On'
		
	
		
	else
	if ((devicechanged['Interrupteur SDB'] == 'Long Click' and otherdevices['Virtuel SDB Coupure'] == 'On') or (devicechanged['Interrupteur SDB'] == 'Long Click Release' and otherdevices['Virtuel SDB Coupure'] == 'On')) then
	commandArray['Interrupteur SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Group:Plafonnier SDB']='Off'
	commandArray['Group:Lumiere SDB']='Off'
	commandArray['Virtuel SDB Coupure']='Off'
	end
	
end



return commandArray
Donc quand je rentre, le détecteur allume pour 2 min, ca, ca fonctionne.

Mais si j'appuie ensuite sur l'inter pour que ca reste allumer en continu, parfois ca fonctionne, et parfois ca éteint....

D'où vient le problème ?

Merci.
Dernière modification par Wolfen38 le 19 juin 2018, 13:50, modifié 1 fois.
thier
Messages : 807
Inscription : 26 sept. 2015, 10:32
Localisation : charente

Re: Allumage par capteur et inter

Message par thier »

Mets des prints dans ton script ça t'aidera à debugger en t'indiquant par où passe ton script.
PI3+, Buster, Domoticz V2020.2, rflink, zwave, chauffage piloté par qubino, sondes oregon et Vil1d, boite aux lettres détection passage facteur, volets roulants qubino fibaro.
Wolfen38
Messages : 1983
Inscription : 19 oct. 2017, 14:49

Re: Allumage par capteur et inter

Message par Wolfen38 »

thier a écrit :Mets des prints dans ton script ça t'aidera à debugger en t'indiquant par où passe ton script.
Voila ce que j'ai comme rapport.

Code : Tout sélectionner

2018-06-19 13:33:15.819 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sdb2.lua
2018-06-19 13:33:15.863 (Gateway) Light/Switch (Detecteur SDB)
2018-06-19 13:33:15.884 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sdb.lua
2018-06-19 13:33:15.896 (Virtualsensor) Lighting 1 (Virtuel plafonnier)
2018-06-19 13:33:15.937 Activating Scene/Group: [Plafonnier SDB]
2018-06-19 13:33:15.938 Activating Scene/Group Device: Plafonnier SDB (On)
2018-06-19 13:33:16.427 (Ampoule) Lighting Limitless/Applamp (Plafonnier SDB)
2018-06-19 13:33:18.043 LUA: Inter sdb OFF de ON
2018-06-19 13:33:18.043 LUA: Groupe Plafonnier SDB Off de ON
2018-06-19 13:33:18.043 LUA: Virtuel plafonnier OFF de ON
2018-06-19 13:33:18.043 LUA: Virtuel sdb ON de ON
2018-06-19 13:33:18.043 LUA: Groupe Plafonnier SDB ON de ON
2018-06-19 13:33:18.045 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sdb.lua
2018-06-19 13:33:18.069 (Gateway) Light/Switch (Interrupteur SDB)
2018-06-19 13:33:18.119 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_sdb.lua
2018-06-19 13:33:18.131 (Virtualsensor) Lighting 1 (Virtuel plafonnier)
2018-06-19 13:33:18.132 Activating Scene/Group: [Plafonnier SDB]
2018-06-19 13:33:18.132 Activating Scene/Group Device: Plafonnier SDB (On)
2018-06-19 13:33:18.589 (Ampoule) Lighting Limitless/Applamp (Plafonnier SDB)
2018-06-19 13:33:18.823 (Gateway) Light/Switch (Interrupteur SDB)
2018-06-19 13:33:18.890 (Virtualsensor) Lighting 1 (Virtuel SDB)
2018-06-19 13:33:18.931 Activating Scene/Group: [Plafonnier SDB]
2018-06-19 13:33:18.932 Activating Scene/Group Device: Plafonnier SDB (Off)
2018-06-19 13:33:19.049 (Ampoule) Lighting Limitless/Applamp (Plafonnier SDB)
2018-06-19 13:33:19.282 (Ampoule) Lighting Limitless/Applamp (Plafonnier SDB)
Je comprends pas pourquoi ca s'eteint tout le temps....
Répondre