Aller au contenu
ebtjjn

Domotisation De La Piscine

Recommended Posts

bonjour

et merci ebtjjn pour son virtual device de filtration piscine.

je suis en attente d'un thermomètre pour ma piscine avant de tenter la mise en marche.

avez vous fait évoluer la scène et le device?

comment se lance le mode auto est il activé par défaut?

merci de votre réponse

pierre

Partager ce message


Lien à poster
Partager sur d’autres sites

Salut pgvuille,

voici en PJ lea dernière version du module qui fonctionne bien de mon côté.

 

Pour la scène la voici :

--[[
%% autostart
%% properties
%% events
%% globals
--]]

--****************************************
--*************PARAMETRAGE****************
local id_pompe = 69
local id_tel = 109 -- 109= tél SAMSUNG GM9530JJ : téléphone sur lesquel envoyer une notif push (start et stop)
				-- 110 = tel ONEPLUS Emma
local id_eau = 141
--****************************************
--****************************************

local sourceTrigger = fibaro:getSourceTrigger();
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();


function tempFunc()	--fonction de filtration en ETE
	local currentDate = os.date("*t");
	local startSource = fibaro:getSourceTrigger();

	if (
 	( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "10:28") )
		)
	then
    	fibaro:debug("Je filtre");
		fibaro:call(id_pompe, "turnOn");
    	fibaro:setGlobal("modefiltration", 1)
    	fibaro:call(id_tel, "sendDefinedPushNotification", "51");
 		fibaro:sleep(3600*2*1000)
		-- 	au bout de 2 heures, prise de température pour gestion auto du nbe d'heures à filtrer selon temp de l'eau
		local temppiscine = fibaro:getValue(id_eau, "value")
    	fibaro:setGlobal('tempref',temppiscine)
		-- test de la température : si > 27, filtration sur 21h30 de plus (=23h30 au total) sinon, règle BAROUDI		
    		if tonumber(temppiscine) > 27 then
      			fibaro:debug("T° eau piscine > 27 ==> filtration continue")
      			fibaro:setGlobal("modefiltration", 8)
	      		fibaro:call(id_tel, "sendDefinedPushNotification", "80");
		   		local nbheuresafiltrer = 21,5 * 3600 * 1000
      			fibaro:setGlobal("dureefiltration", nbheuresafiltrer)
    		else
		    	fibaro:debug("T° eau piscine = " ..temppiscine .. " °C")	
    			local temppiscinearrondi = math.floor(tonumber(temppiscine)+ .5)
				local nbheuresafiltrerenh = ((tonumber(temppiscinearrondi)/2)-2)
				fibaro:debug("nb heures a filtrer = " .. nbheuresafiltrerenh)
				local nbheuresafiltrer = nbheuresafiltrerenh *3600 * 1000
				-- on définit la variable dureefiltration = nb d'heures à  filtrer 
				fibaro:setGlobal("dureefiltration", nbheuresafiltrer)
			end	
		fibaro:debug("Valeur de la variable _dureefiltration_ : "..fibaro:getGlobalValue("dureefiltration"));
		fibaro:sleep(tonumber(fibaro:getGlobalValue("dureefiltration"))-(3600*2*1000));    
    		if fibaro:getGlobalValue("modefiltration") == "12" then
      			fibaro:debug("Fin du mode auto mais CHOC déjà en cours")
      		else
        		fibaro:debug("Fin du timer, j\'arrête de filtrer");
      			fibaro:setGlobal("dureefiltration", 0)
				fibaro:call(id_pompe, "turnOff"); 
      			fibaro:setGlobal('tempref', 99)
    			fibaro:setGlobal("modefiltration", 0)
    			fibaro:call(id_tel, "sendDefinedPushNotification", "52");
      		end

    end

  setTimeout(tempFunc, 60*1000)
  
end

if fibaro:getGlobalValue("Saison") == "Eté" then --je filtre en mode ETE
	fibaro:debug("c\'est l\'été, cool !! :-)")
	tempFunc()
		
else	
	local temppiscine = fibaro:getValue(id_eau, "value")
	fibaro:debug("c\'est l\'hiver...!! :-(")
  	-- test de la température : si < 2, filtration sur 24h, sinon 2h de 4h à 6h du mat		
    	if tonumber(temppiscine) < 2 then
      		fibaro:debug("T° eau piscine < 2 ==> filtration continue")
	      	fibaro:call(id_tel, "sendDefinedPushNotification", "79");
		   	--local nbheuresafiltrer = 23,5 * 3600 * 1000
			fibaro:call(id_pompe, "turnOn"); 
		    fibaro:setGlobal('tempref', temppiscine)
    		fibaro:debug("Je filtre en continu");			
      		fibaro:setGlobal("modefiltration", 8)
			fibaro:sleep(23,5*3600*1000)
    		fibaro:call(id_pompe, "turnOff");
    		fibaro:setGlobal("dureefiltration", 0)
    		fibaro:setGlobal('tempref', 99)
    		fibaro:debug("Fin du timer, j\'arrête de filtrer");
    		--fibaro:call(id_tel, "sendDefinedPushNotification", "52");
    		fibaro:setGlobal("modefiltration", 0)
		--end
	
    
  		elseif ( --à 4h du matin, j'active la filtration
 		( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "03:45") )
			) then
		-- s'il y a un CHOC en cours --> priorité au CHOC : je ne fais rien. Sinon, je filtre 2h.
			fibaro:debug("je filtre en mode HIVER")			
    			if fibaro:getGlobalValue("modefiltration") == "12" then
					fibaro:debug("CHOC déjà en cours : la durée de filtration est celle définie par le CHOC") 
      			elseif
      				fibaro:getGlobalValue("EdfTempoJour") == "1" then
        			fibaro:call(id_pompe, "turnOn"); 
		    		fibaro:debug("Je filtre");			
      				fibaro:setGlobal("modefiltration", 1)
      				fibaro:call(id_tel, "sendDefinedPushNotification", "51");
					fibaro:sleep(1.9*3600*1000)
					fibaro:debug("Fin du timer, j\'arrête de filtrer");
					fibaro:call(id_pompe, "turnOff");
    				fibaro:setGlobal("modefiltration", 0) --je ne teste pas s'il ya un CHOC en cours : il faudrait l'avoir déclenché entre 4h et 6H du matin...
    				--fibaro:call(id_tel, "sendDefinedPushNotification", "52");
      			
    			end
		end

end

 

Je n'ai pas réussi à mettre la filtration été et hiver dans une seule scène. Celle du dessus est la scène que j'active l'été.

J'ai créé une variable prédéfinie "2té" ou "Hiver" que je change (2 fois par an) selon si je passe en hivernage ou en mode été.

 

Celle ci-dessous est pour l'hiver : 

--[[
%% autostart
%% properties
%% events
%% globals
--]]

--****************************************
--*************PARAMETRAGE****************
local id_pompe = 69
local id_tel = 110 -- 109= tél SAMSUNG GM9530JJ : téléphone sur lesquel envoyer une notif push (start et stop)
				-- 110 = tel ONEPLUS Emma
local id_eau = 141 --sonde température eau piscine
--****************************************
--****************************************

local sourceTrigger = fibaro:getSourceTrigger();
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();


function tempFunc()	--fonction de filtration en HIVER
	local currentDate = os.date("*t");
	local startSource = fibaro:getSourceTrigger();

	if (
 	( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "03:43") )
		)
	then
    	fibaro:debug("Je filtre en mode hiver");
		fibaro:call(id_pompe, "turnOn");
    	fibaro:setGlobal("modefiltration", 1)
    	fibaro:call(id_tel, "sendDefinedPushNotification", "51");
 		fibaro:sleep(2*3600*1000)
		-- 	au bout de 2 heures, prise de température pour gestion auto du nbe d'heures à filtrer selon temp de l'eau
		local temppiscine = fibaro:getValue(id_eau, "value")
    	fibaro:setGlobal('tempref',temppiscine)
		-- test de la température : si < 2, filtration sur 21h30 de plus (=23h30 au total) sinon, règle BAROUDI		
    		if tonumber(temppiscine) < 2 then
      			fibaro:debug("T° eau piscine < 2 ==> filtration continue")
      			fibaro:setGlobal("modefiltration", 8)
	      		fibaro:call(id_tel, "sendDefinedPushNotification", "79");
		   		local nbheuresafiltrer = 21,5 * 3600 * 1000
      			fibaro:setGlobal("dureefiltration", nbheuresafiltrer)
    		end	
		
    		if fibaro:getGlobalValue("modefiltration") == "12" then
      			fibaro:debug("Fin du mode auto mais CHOC déjà en cours")
      		else
        		fibaro:debug("Fin du timer, j\'arrête de filtrer");
      			fibaro:setGlobal("dureefiltration", 0)
				fibaro:call(id_pompe, "turnOff"); 
      			fibaro:setGlobal('tempref', 99)
    			fibaro:setGlobal("modefiltration", 0)
    			fibaro:call(id_tel, "sendDefinedPushNotification", "52");
      		end

    end

  setTimeout(tempFunc, 50*1000)
  
end

if fibaro:getGlobalValue("Saison") == "Hiver" and tonumber(fibaro:getGlobalValue("EdfTempoJour")) < 2 then --je filtre en mode HIVER
	fibaro:debug("c\'est l\'hiver... :-( mais jour bleu donc ça tourne...")
	tempFunc()
  else 
  fibaro:debug("c\'est l\'hiver... :-( mais jour blanc ou ROUGE donc ça tourne pas...")

end

 

Pour être honnête, la scène hiver ne marche pas comme je voudrai... mais elle tourne de 4 à 6h du matin; je n'ai pas réussi à la faire tourner si  l'eau est à moins de 2°C... probablememnt un mauvais codage...

 

A dispo si besoin.

Bonne baignade !! :)

 

PISCINE.vfib

Partager ce message


Lien à poster
Partager sur d’autres sites

×