Re: Correction de script LUA
Publié : 08 févr. 2019, 13:24
Salut
Merci pour ta réponse, ça valide ce que je pensais faire.
Bonne journée.
A+
Fab
Merci pour ta réponse, ça valide ce que je pensais faire.
Bonne journée.
A+
Fab
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Code : Tout sélectionner
commandArray={}
local heure = os.date("%H:%M")
now=os.date("*t")
local Var = uservariables['Filtration']
---------------------------------------------------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
print("Temp.piscine " .. t..' °C')
print("Heure " .. heure)
print("Durée filtration " .. Var..' min.')
if (t <= 12 and (heure == "09:00" or heure == "17:00")) and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 30'
commandArray['SendNotification']='Filtration piscine#En marche pour 30 minutes.##0###GCM'
elseif t > 12 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 'Var''
commandArray['SendNotification']='Filtration piscine#En marche pour .. 'Var' .. minutes.##0###GCM'
end
end
return commandArrayCode : Tout sélectionner
(t <= 12 and (heure == "10:06" or heure == "17:00"))Je ne vois rien d'anormal, pour moi cela signifie que la condition sera respecté si la température de la piscine est <= à 12 °, et qu'il est (10:06 ou 17:00). Cela est cohérent avec une exécution toute les minutes.f0emm a écrit : 10 févr. 2019, 10:08 Le script le plus important de mon système domotique qui doit être d'une fiabilité à toute épreuve.
Si quelqu'un peut me le confirmer sachant qu'il y a une erreur ici je penseBon dimanche à tous.Code : Tout sélectionner
(t <= 12 and (heure == "10:06" or heure == "17:00"))
A+
Fab
Code : Tout sélectionner
commandArray['SendNotification']='Filtration piscine#En marche pour .. 'Var' .. minutes.##0###GCM'Code : Tout sélectionner
commandArray['SendNotification']='Filtration piscine#En marche pour '..Var..' minutes.##0###GCM'Code : Tout sélectionner
commandArray['D1-Filtration']='On FOR 30'Code : Tout sélectionner
commandArray['D1-Filtration']='On' -- mise en route de la pompe
commandArray['D1-Filtration']='Off AFTER 1800' -- arrêt au bout de 1800 s (30 mn)Code : Tout sélectionner
commandArray['D1-Filtration']='On' -- mise en route de la pompe
commandArray['D1-Filtration']='Off AFTER 1800' -- arrêt au bout de 1800 s (30 mn)Code : Tout sélectionner
commandArray={}
local heure = os.date("%H:%M")
now=os.date("*t")
---------------------------------------------------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local matemperature = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local Duree = matemperature /16*60
print("Temp.piscine " .. t..' °C')
print("Heure " .. heure)
print("Durée filtration " .. Duree..' min.')
-- Si température piscine est inf. ou égale à 12 and heure égal 09:00 ou 17:00 and D1 Filtration=Off
if t <= 12 and (heure == "14:56" or heure == "17:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 'Duree'' -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour '.. Duree ..' minutes.##0###GCM'
-- Si température piscine est supérieure à 12 and heure égal 07:00 ..... 21:00 and D1 Filtration=Off
elseif t > 12 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 'Duree'' -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour '.. Duree ..' minutes.##0###GCM'
end
end
return commandArrayCode : Tout sélectionner
Filtration auto: [string "commandArray={}..."]:19: attempt to call local 'Duree' (a number value)
2019-02-10 15:12:28.735 Status: LUA: Durée filtration 41.25 min.Code : Tout sélectionner
'On FOR '..Duree..''Code : Tout sélectionner
commandArray={}
local heure = os.date("%H:%M")
now=os.date("*t")
---------------------------------------------------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local matemperature = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local Duree = matemperature /16*60
print("Temp.piscine " .. t..' °C')
print("Heure " .. heure)
print("Durée filtration " .. Duree..' min.')
-- Si température piscine est inf. ou égale à 12 and heure égal 09:00 ou 17:00 and D1 Filtration=Off
if t <= 12 and (heure == "09:00" or heure == "17:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 30' -- arrêt au bout de 30 minutes
commandArray['SendNotification']='Filtration piscine#En marche pour 30 minutes.##0###GCM'
-- Si température piscine est supérieure à 12 and heure égal 07:00 ..... 21:00 and D1 Filtration=Off
elseif t > 12 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR '..Duree..'' -- arrêt au bout du temps calculé 'Duree'
commandArray['SendNotification']='Filtration piscine#En marche pour '.. Duree ..' minutes.##0###GCM'
end
end
return commandArrayCode : Tout sélectionner
commandArray={}
local heure = os.date("%H:%M")
now=os.date("*t")
-----------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t1 = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local t2 = tonumber(string.format("%.1f", otherdevices_temperature['Temp. exterieur']))
if otherdevices['D1-Filtration']=='Off' and (t1 <= 5 and t2 <= -3) then
commandArray['D1-Filtration']='On FOR 30' -- mise en route de la pompe
commandArray['SendNotification']='Filtration piscine#Hors gel : mise en marche pour 30 minutes.##0###GCM'
end
end
return commandArrayCode : Tout sélectionner
commandArray={}
local heure = os.date("%H:%M")
now=os.date("*t")
---------------------------------------------------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local t2 = tonumber(string.format("%.1f", otherdevices_temperature['Temp. exterieur']))
local matemperature = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local Duree = matemperature /16*60
print("Temp.piscine " .. t..' °C')
print("Heure " .. heure)
print("Durée filtration " .. Duree..' min.')
-- Si température piscine est inf. ou égale à 12 and heure égal 09:00 ou 17:00 and D1 Filtration=Off
if t <= 10 and (heure == "09:00" or heure == "17:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 30' -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour 30 minutes.##0###GCM'
-- Si température piscine est supérieure à 12 and heure égal 07:00 ..... 21:00 and D1 Filtration=Off
elseif t > 10 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00") and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR '..Duree..'' -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour '.. Duree ..' minutes.##0###GCM'
-- Hors gel
elseif (t <= 5 and t2 <= -3) and otherdevices['D1-Filtration']=='Off' then
commandArray['D1-Filtration']='On FOR 30' -- mise en route de la pompe
commandArray['SendNotification']='Filtration piscine#Hors gel : mise en marche pour 30 minutes.##0###GCM'
end
end
return commandArrayOui, c'est cohérent, même l’ordre n'est pas important, puisque pour les 3 conditions, les 3 actions sont identiques.f0emm a écrit : 10 févr. 2019, 15:35 D'ailleurs je dois pouvoir l'incorporer au premier script avec un deuxième 'elseif' ?
Code : Tout sélectionner
--si D1 Filtration=Off
if otherdevices['D1-Filtration']=='Off' then
-- Hors gel
if (t <= 5 and t2 <= -3) then
-- Si température piscine est inf. ou égale à 12 and heure égal 09:00 ou 17:00
else if (t <= 10 and (heure == "09:00" or heure == "17:00")) then
-- Si température piscine est supérieure à 12 and heure égal 07:00 ..... 21:00 and D1 Filtration=Off
elseif (t > 10 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00")) then
end
endCode : Tout sélectionner
local heure = os.date("%H:%M")
now=os.date("*t")
commandArray={}
---------------------------------------------------------------------------------------
if now.min % 1 == 0 then -- exécution toutes les minutes
local t = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local t2 = tonumber(string.format("%.1f", otherdevices_temperature['Temp. exterieur']))
local matemperature = tonumber(string.format("%.1f", otherdevices_temperature['Temp. piscine']))
local Duree = matemperature /16*60
print("Temp.piscine " .. t..' °C')
print("Heure " .. heure)
print("Durée filtration " .. Duree..' min.')
--si D1 Filtration=Off
if otherdevices['D1-Filtration']=='Off' then
-- Hors gel
if (t <= 5 and t2 <= -3) then
commandArray['D1-Filtration']='On FOR 30' -- mise en route de la pompe
commandArray['SendNotification']='Filtration piscine#Hors gel : mise en marche pour 30 minutes.##0###GCM'
-- Si température piscine est inf. ou égale à 10 and heure égal 09:00 ou 17:00
else if (t <= 10 and (heure == "09:00" or heure == "17:00")) then
commandArray['D1-Filtration']='On FOR 30' -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour 30 minutes.##0###GCM'
-- Si température piscine est supérieure à 10 and heure égal 07:00 ..... 21:00 and D1 Filtration=Off
elseif (t > 10 and (heure == "07:00" or heure == "09:00" or heure == "11:00" or heure == "13:00" or heure == "15:00" or heure == "17:00" or heure == "19:00" or heure == "21:00")) then
commandArray['D1-Filtration']='On FOR '..Duree -- arrêt au bout de variable
commandArray['SendNotification']='Filtration piscine#En marche pour '.. Duree ..' minutes.##0###GCM'
end
end
end
return commandArrayCode : Tout sélectionner
local heure = os.date("%H:%M")
-- retourne l'heure du coucher de soleil ex: "22:15"
coucherSoleil = string.sub(os.date("!%X",60*timeofday['SunsetInMinutes']), 1, 5)
local coucherSoleil2 = (coucherSoleil + 00:20)Code : Tout sélectionner
timeofday['SunsetInMinutes']
Code : Tout sélectionner
timeofday['SunsetInMinutes'] + 20
Code : Tout sélectionner
60 * (timeofday['SunsetInMinutes'] + 20)
Code : Tout sélectionner
coucherSoleil2 = string.sub(os.date("!%X",60*(timeofday['SunsetInMinutes']+20)), 1, 5)