Je rajoute le END juste avant cette ligne ?
if (otherdevices[switch2]=='On') then
Code : Tout sélectionner
-- Ce script permet de remonter la durée de fonctionnement d'un appareil de type "Counter Incremental"
--------------------------------
------ Variables à éditer ------
--------------------------------
local switch = 'Célia Téléphone' -- Nom de l'interrupteur virtuel dans Domoticz
local counter = 57 -- Numéro idx du Counter Incremental dans Domoticz
local current_date = (os.date("01/01/2017")) -- Date courante
local current_heure = (os.date("00:01")) -- Heure courante
--------------------------------
-- Fin des variables à éditer --
--------------------------------
-------------------
-- Fonction time --
-------------------
time = os.date("*t")
function timedifference(d)
s = otherdevices_lastupdate[d]
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)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
------------------- --------------------
-- Fonction arrondir à deux décimales --
------------------- --------------------
-- Le chiffre"x" (dec or x) correspond au nombre de décimales à prendre en compte dans le resultat
function arrondir(num, dec)
if num == 0 then
return 0
else
local mult = 10^(dec or 2)
return math.floor(num * mult + 0.5) / mult
end
end
commandArray = {}
-----------------------------------------------------------------------------------------------------
--------------------Calcul du temps de fonctionnement du téléphone de Célia -------------------------------
-----------------------------------------------------------------------------------------------------
-- Si chauffage ON incrémentation de la variable Domoticz "Total_Téléphone_Célia" --
if (otherdevices[switch]=='On') then
commandArray['Variable:Total_Téléphone_Célia']= tostring(uservariables["Total_Téléphone_Célia"] +1)
end
-- Envoi de la varaible valeur Total_Téléphone_Lylou dans le Custom Counter Valeur_Compteur --
Valeur_Compteur = tostring(uservariables["Total_Téléphone_Célia"])
-- Envoi de la valeur dans le compteur "counter" --
commandArray['UpdateDevice'] = counter .. '|0|' .. tostring(Valeur_Compteur)
-- Envoi des informations dans le LOG si téléphone ON --
if (otherdevices[switch]=='On') then
print("")
print("Cumul du temps de fonctionnement du téléphone de Célia "..Valeur_Compteur.." Minutes".." // "..math.floor((Valeur_Compteur/60)).. " Heures")
print("")
end
return commandArrayCode : Tout sélectionner
type : TIME
--------------------------------
------ Variables à éditer ------
--------------------------------
local switch = 'Léo Playstation 4' -- Nom de l'interrupteur virtuel dans Domoticz
local counter = 59 -- Numéro idx du Counter Incremental dans Domoticz
local switch2 = 'Léo Téléphone' -- Nom de l'interrupteur virtuel dans Domoticz
local counter2 = 56 -- Numéro idx du Counter Incremental dans Domoticz
--------------------------------
-- Fin des variables à éditer --
--------------------------------
commandArray = {}
if (otherdevices[switch]=='On') then
-- incrémentation
local Valeur_Compteur_PS4Léo = tonumber(uservariables["Total_PS4_Léo"] +1)
-- log
print("Cumul du temps de fonctionnement de la PS4 de Léo "..os.date("!%X",60*Valeur_Compteur_PS4Léo))
-- maj variable
commandArray['Variable:Total_PS4_Léo']= tostring(Valeur_Compteur_PS4Léo)
-- maj compteur
commandArray[1] = {['UpdateDevice'] = counter..'|0|'..Valeur_Compteur_PS4Léo
end
if (otherdevices[switch2]=='On') then
-- incrémentation
local Valeur_Compteur_TéléphoneLéo = tonumber(uservariables["Total_Téléphone_Léo"] +1)
-- log
print("Cumul du temps de fonctionnement du téléphone de Léo "..os.date("!%X",60*Valeur_Compteur_TéléphoneLéo ))
-- maj variable
commandArray['Variable:Total_Téléphone_Léo']= tostring(Valeur_Compteur_TéléphoneLéo)
-- maj compteur
commandArray[2] = {['UpdateDevice'] = counter2..'|0|'..Valeur_Compteur_TéléphoneLéo
end
return commandArray