Travaillant en 3*8 je souhaiterais automatiser mon éclairage en fonction de ma semaine de travail mais je bloque un peu.
Effectivement, changeant chaque semaine d'horaire j'aurais souhaité pouvoir récupérer le N° de la semaine dans domoticz ou établir un planning toute les 3 semaines mais je ne trouve rien à ce sujet.
Quelqu'un aurait il une idée ?
Je vous en remercie d'avance.
Bonne fin de journée.
A+
Fab
Script à jour
Ne pas oublier de créer la variable
Code : Tout sélectionner
commandArray = {}
local heure = os.date("%H:%M")
local semaine = (os.date("%W"))
local num = semaine +1 --- le numéro de la semaine ayant une semaine de retard
local horaire = uservariables['Semaine 3*8']
-- retourne le jour actuel en français ex: "mardi"
days = {"dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"}
jour = days[(os.date("%w")+1)]
-- il fait nuit
nightTime = timeofday['Nighttime']
if heure == '00:05' then
-- Matin
if num % 3 == 0 then
commandArray['Variable:Semaine 3*8']=tostring(1)
-- Nuit
elseif (num - 1) % 3 == 0 then
commandArray['Variable:Semaine 3*8']=tostring(2)
-- Après midi
elseif (num + 1) % 3 == 0 then
commandArray['Variable:Semaine 3*8']=tostring(3)
end
end
---------------------------------------------------------------------------------------
if nightTime and otherdevices['Congé']=='Off' and otherdevices['Férié']=='Off' then
-- Eclairage huit du matin
if heure == "04:18" and horaire == 1 and (jour ~= "samedi" and jour ~= "dimanche") then
commandArray['Eclairage entréé']='On for 5'
commandArray['Eclairage séjour']='On for 5'
commandArray['Eclairage préau']='On for 3'
end
-- Eclairage huit de nuit
if heure == "05:30" and horaire == 2 and (jour ~= "samedi" and jour ~= "dimanche" and jour ~= "lundi") then
commandArray['Eclairage entréé']='On for 5'
commandArray['Eclairage séjour']='On for 5'
commandArray['Eclairage préau']='On for 3'
end
if heure == "23:30" and horaire == 2 and jour == "vendredi" then
commandArray['Eclairage entréé']='On for 5'
commandArray['Eclairage séjour']='On for 5'
commandArray['Eclairage préau']='On for 3'
end
-- Eclairage huit d' après midi
if heure == "21:30" and horaire == 3 and (jour ~= "vendredi" and jour ~= "samedi" and jour ~= "dimanche") then
commandArray['Eclairage entréé']='On for 5'
commandArray['Eclairage séjour']='On for 5'
commandArray['Eclairage préau']='On for 3'
end
end
return commandArray