Aller au contenu

Créer Variable Avec Temps X Avant Le Couché Du Soleil


Diuck

Messages recommandés

Après plusieurs conseil de Jossalf J'ai modifié mes scènes bloc en Lua effectué quelques modif et Tout est parfait Encore un grand merci à  JOSSALF :60:  Reste à  affiner 

Ci-joint copie pour éventuellement avoir un Avis sur le Résultat.

 

 

Déclenchement scène en CAS d'ensoleillement.

--[[
%% autostart
%% properties
%% globals
JOUR_NUIT
METEO
--]]

local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do

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 os.date("%H:%M", os.time()+480*60) == fibaro:getValue(1, "sunsetHour")) )
and
 ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" )
and
 ( fibaro:getGlobalValue("METEO") == "DECOUVERT" )
)
then
	fibaro:call(25, "setValue", "40");
	fibaro:call(20, "setValue", "50");
	fibaro:call(22, "sendDefinedPushNotification", "5");
end

fibaro:sleep(60*1000);
end
else

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
 ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" )
and
 ( fibaro:getGlobalValue("METEO") == "DECOUVERT" )
or
startSource["type"] == "other"
)
then
	fibaro:call(25, "setValue", "40");
	fibaro:call(20, "setValue", "50");
	fibaro:call(22, "sendDefinedPushNotification", "5");
end

end

Déclenchement scène en fin d'Après midi Ouverture Totale 1 heure 30 avant le couché du soleil

--[[
%% autostart
%% properties
%% globals
JOUR_NUIT
--]]

local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do

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 os.date("%H:%M", os.time()+90*60) == fibaro:getValue(1, "sunsetHour")) )
and
 ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" )
)
then
	fibaro:call(25, "open");
	fibaro:call(25, "setValue2", "99");
	fibaro:call(20, "open");
	fibaro:call(20, "setValue2", "99");
	fibaro:call(22, "sendDefinedPushNotification", "6");
end

fibaro:sleep(60*1000);
end
else

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
 ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" )
or
startSource["type"] == "other"
)
then
	fibaro:call(25, "open");
	fibaro:call(25, "setValue2", "99");
	fibaro:call(20, "open");
	fibaro:call(20, "setValue2", "99");
	fibaro:call(22, "sendDefinedPushNotification", "6");
end

end

Lien vers le commentaire
Partager sur d’autres sites

--[[
%% autostart
%% properties
%% globals
JOUR_NUIT
METEO
--]]

local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do 

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 os.date("%H:%M", os.time()+45*60) == fibaro:getValue(1, "sunriseHour")) )
and
 ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" )
and
 ( fibaro:getGlobalValue("METEO") == "DECOUVERT" ) 
)
then
	fibaro:call(24, "setValue", "75");
	fibaro:call(19, "setValue", "75");
	fibaro:call(22, "sendDefinedPushNotification", "4");
end

fibaro:sleep(60*1000);
end
end

Modification des scènes précédente Shad peux tu me donner ton avis STP

 

 

Lien vers le commentaire
Partager sur d’autres sites

Moi je veux bien te donner mon avis mais tu vas pas l'aimer.

Ta scène est pas mal. Mais avec le scheduler tu pourrais énormément la simplifier et part la même occasion lui donner plus de possibilités. Je te poste comment je ferais d'ici 10 minutes.

Lien vers le commentaire
Partager sur d’autres sites

Déjà  dans le scheduler tu met le code suivant et remplace sceneID par le numéro:

luaDaySchedule:add("Sunset","sceneID", "" , "startScene", {"All"}, false , -45);

Donc déjà  ta scène ce lancera seul et tu peux enlever cette condition.

 

Après pour gérer la météo tu peux faire

--[[
%% properties
3 WeatherConditionConverted
%% globals
--]]

if (( fibaro:getValue(3, "WeatherConditionConverted") == "clear" ) then
  fibaro:setGlobal("METEO", "DECOUVERT");
elseif ( fibaro:getValue(3, "WeatherConditionConverted") == "cloudy" ) then
  fibaro:setGlobal("METEO", "COUVERT");
elseif ( fibaro:getValue(3, "WeatherConditionConverted") == "fog" ) then
  fibaro:setGlobal("METEO", "BROUILLARD");
elseif ( ( fibaro:getValue(3, "WeatherConditionConverted") == "rain" ) then
  fibaro:setGlobal("METEO", "PLUIE");
elseif ( fibaro:getValue(3, "WeatherConditionConverted") == "snow" ) then
  fibaro:setGlobal("METEO", "NEIGE");
elseif ( fibaro:getValue(3, "WeatherConditionConverted") == "storm" ) then
  fibaro:setGlobal("METEO", "ORAGE");
end
fibaro:sleep(60*1000);

Pour Ta variable JOUR_NUIT:

luaDaySchedule:add("Sunrise","JOUR_NUIT", "JOUR" , "setGlobal", {"All"}, false , 0);
luaDaySchedule:add("Sunset","JOUR_NUIT", "NUIT" , "setGlobal", {"All"}, false , 0);

Et pour finir voilà  le code que tu peux faire:

--[[
%% properties
%% globals
--]]

if ( ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" ) and ( fibaro:getGlobalValue("METEO") == "DECOUVERT" )) then
  fibaro:call(24, "setValue", "75");
  fibaro:call(19, "setValue", "75");
  fibaro:call(22, "sendDefinedPushNotification", "4");

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" ) and ( fibaro:getGlobalValue("METEO") == "PLUIE" )) then

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" ) and ( fibaro:getGlobalValue("METEO") == "COUVERT" )) then

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "JOUR" ) and ( fibaro:getGlobalValue("METEO") == "ORAGE" )) then

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "NUIT" ) and ( fibaro:getGlobalValue("METEO") == "PLUIE" )) then

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "NUIT" ) and ( fibaro:getGlobalValue("METEO") == "COUVERT" )) then

elseif ( ( fibaro:getGlobalValue("JOUR_NUIT") == "NUIT" ) and ( fibaro:getGlobalValue("METEO") == "ORAGE" )) then

end
fibaro:sleep(60*1000);

Voilà  tu as tout et tu peux lancer ta scène pour d'autre occasion

  • Upvote 2
Lien vers le commentaire
Partager sur d’autres sites

Merci pour le temps que tu m'as consacré

 

Très bien je commence à  comprendre :) le sheduler peux en effet simplifier la programmation des scènes, mais je ne veux pas te paraître idiot mais je n'arrive pas à  configurer le sheduler :( j'avance doucement mais j'avance

Lien vers le commentaire
Partager sur d’autres sites

Il n'y a rien pour te guider lol.

S'il n'y a pas d'erreur c'est que tout est bon.

Met juste mes lignes de code et tu verras le résultat.

Envoyé de mon SM-P600 en utilisant Tapatalk

Lien vers le commentaire
Partager sur d’autres sites

En plus lisible la ligne 3 c'est la ligne 637

--<ADD YOUR LINES HERE IN POFILE SECTIONS>
luaDaySchedule:add("19:14","16", "turnOn" , "call", {"all"} ,false)


--add to the standard schedule table
          if schedule[luaDaySchedule.days[d]][sTime] == nill then

Lien vers le commentaire
Partager sur d’autres sites

2.luaDaySchedule:add("Sunset","JOUR_NUIT", "JOUR" , "setGlobal", {"All"}, false , 0);

3.luaDaySchedule:add("Sunrise","JOUR_NUIT", "NUIT" , "setGlobal", {"All"}, false , 0);


Salut Jossalf une petite question

 

Si je rentre ces 2 variables dans le sheduler je peux supprimer les variables jour/nuit que j'ai créer en bloc sans modifier mes scènes actuel, les scènes en LUA bien sur

Lien vers le commentaire
Partager sur d’autres sites

--<ADD YOUR LINES HERE IN POFILE SECTIONS>
luaDaySchedule:add("20:36","16", "turnOn" , "call", {"All"} ,false)

Et si c'est le cas je les ajoute dans le sheduler à  la suite de cette ligne ?

Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...