Bonsoir Vbill, Je début en Domoticz j'ai du mal à comprendre le langage lua et du mal a décrypter les erreurs.
2020-01-24 20:24:01.843 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-01-24 20:24:01.961 Status: dzVents: Error (2.4.19): error loading module 'Infos_EJP' from file '/home/pi/domoticz/scripts/dzVents/scripts/Infos_EJP.lua':
2020-01-24 20:24:01.961 /home/pi/domoticz/scripts/dzVents/scripts/Infos_EJP.lua:114: unfinished long comment near <eof>
2020-01-24 20:24:21.105 Status: dzVents: Error (2.4.19): error loading module 'Infos_EJP' from file '/home/pi/domoticz/scripts/dzVents/scripts/Infos_EJP.lua':
2020-01-24 20:24:21.105 /home/pi/domoticz/scripts/dzVents/scripts/Infos_EJP.lua:114: unfinished long comment near <eof>
une petite question sur la page 1 après le code du fichier EJP.sh tu mes le code suivant
Code : Tout sélectionner
-----------------------------------------------------------------------
------------------ Variables utilisateur ------------------------------
-----------------------------------------------------------------------
local dzJourJ ='EJP Aujourdhui' -- Alert sensor indiquant l'ejp du jour
local dzJourJ1 ='EJP Demain' -- Alert sensor indiquant l'ejp de demain
local dzNb ='EJP Nbre Jours' -- Custom sensor indiquant le nombre de jours ejp
local dzEJP ='EJP' -- Entrée contact physique relais EJP
local dzDebugLog='Log' -- Entrée avec sans Log
local dzEJPS ='EJP Switch' -- Sortie etat EJP du jour
local Mois = os.date("%m",d)
local Minute = os.date('%M')
-----------------------------------------------------------------------
------------------ DzVents --------------------------------------------
-----------------------------------------------------------------------
return {
on = {
timer = { 'every minute' }
},
execute = function(dz)
if ( Minute == '00' or Minute == '30' ) then
os.execute('bash /home/pi/domoticz/EJP.sh')
end
local StatusLog = dz.devices(dzDebugLog).state
if ( tonumber(Mois) < 4 or tonumber(Mois) > 10 ) then
local StatusEjpJ = dz.devices(dzJourJ).state
local StatusEjpJ1 = dz.devices(dzJourJ1).state
local StatusEjpRestant = dz.devices(dzNb).state
local StatusEJP = dz.devices(dzEJP).state
if ( StatusEJP == 'Open' ) then --Etat Open ou Closed
dz.devices(dzEJPS).switchOff().silent()
else
dz.devices(dzEJPS).switchOn().silent()
end
--debug
if ( StatusLog == 'On' ) then
dz.log('EJP du Jour :', dz.PRIORITY_LOW)
dz.log(StatusEjpJ, dz.PRIORITY_LOW)
dz.log('EJP de Demain :', dz.PRIORITY_LOW)
dz.log(StatusEjpJ1, dz.PRIORITY_LOW)
dz.log('EJP Jours écoulés :', dz.PRIORITY_LOW)
dz.log(StatusEjpRestant, dz.PRIORITY_LOW)
dz.log('EJP contact EDF :', dz.PRIORITY_LOW)
dz.log(StatusEJP, dz.PRIORITY_LOW)
dz.log('Mois :', dz.PRIORITY_LOW)
dz.log(Mois, dz.PRIORITY_LOW)
dz.log('Minute :', dz.PRIORITY_LOW)
dz.log(Minute, dz.PRIORITY_LOW)
end
else
dz.devices(dzJourJ).updateAlertSensor(dz.ALERTLEVEL_GREEN,"NON_EJP")
dz.devices(dzJourJ1).updateAlertSensor(dz.ALERTLEVEL_GREEN,"Hors_période")
dz.devices(dzNb).updateCustomSensor(0)
--debug
if ( StatusLog == 'On' ) then
dz.log('Hors période EJP', dz.PRIORITY_LOW)
dz.log('EJP du 1er Novembre au 31 Mars', dz.PRIORITY_LOW)
end
end
end
}
Mais faut il juste remplacer les variables utilisateur et les lignes DzVents ?
voila le code comme je l'ai compris
Code : Tout sélectionner
--[[
-- Ce script dzVents récupère les infos EJP
-- adresse ou j'ai pris le code RV https://easydomoticz.com/forum/viewtopic.php?f=10&t=9093
-- infos site EDF:
-- Période ejp : 1er novembre au 31 mars
-- Journée ejp: de 7h à 1h le lendemain
-- Le jour ejp de demain : Cette information est actualisée tous les jours à partir de 16h.
-- Liste des status : "EST_EJP" "NON_EJP" "ND"
--
-----------------------------------------------------------------------
------------------ Variables utilisateur ------------------------------
-----------------------------------------------------------------------
local zone ='Nord' -- Zone ejp concernée
local dzJourJ ='EJP Aujourdhui' -- 889 dz Text sensor : Nom exact du "Alert sensor" indiquant l'ejp du jour
local dzJourJ1 ='EJP Demain' -- 890 dz Text sensor : Nom exact du "Alert sensor" indiquant l'ejp de demain
local dzEJPS ='EJP Switch' -- 940 Switch etat EJP du jour
local dzNb ='EJP J_Restant' -- 888 dz Custom sensor : Nom exact du "Custom sensor" indiquant le nombre de jours ejp restants
local dzEJP ='EJP' -- Entrée contact physique relais EJP
local dzDebugLog='true' -- Nil Entrée avec sans Log
local Mois = os.date("%m",d)
local Minute = os.date('%M')
-----------------------------------------------------------------------
------------------ Constantes -----------------------------------------
-----------------------------------------------------------------------
local URLhisto ="https://particulier.edf.fr/services/rest/referentiel/historicEJPStore?searchType=ejp"
local URLparams ="https://particulier.edf.fr/services/rest/referentiel/getConfigProperty?PARAM_CONFIG_PROPERTY="
local URLetat ="https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?TypeAlerte=EJP&Date_a_remonter="
local EJPok ="EST_EJP"
-----------------------------------------------------------------------
------------------ Chargement du fichier JSON.lua ---------------------
-----------------------------------------------------------------------
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
-----------------------------------------------------------------------
------------------ Traitement de chaine -------------------------------
-----------------------------------------------------------------------
--formatage zone
local MinZone = string.lower(zone)
local MajZone = string.upper(zone)
local KeyZone = MinZone:gsub("^%l", string.upper)
--date du jour
local dateJ = os.date("%F",d)
local mois = os.date("%m",d)
--url/json du nombre de jours total
local KeyNbj = 'param.total.days.' .. MinZone
--Commandes url:
local cmdHisto = 'curl -s \"' .. URLetat .. dateJ .. '\"'
local cmdParams = 'curl -s \"' .. URLparams .. KeyNbj .. '\"'
local cmdEtat = 'curl -s \"' .. URLhisto .. '\"'
-----------------------------------------------------------------------
------------------ Fonction pour récupérer le retour d'une commande ---
-----------------------------------------------------------------------
function os.capture(cmd)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
return s
end
-----------------------------------------------------------------------
------------------ DzVents --------------------------------------------
-----------------------------------------------------------------------
return {
on = {
timer = { 'every minute' }
},
execute = function(dz)
if ( Minute == '00' or Minute == '30' ) then
os.execute('bash /home/pi/domoticz/EJP.sh')
end
local StatusLog = dz.devices(dzDebugLog).state
if ( tonumber(Mois) < 4 or tonumber(Mois) > 10 ) then
local StatusEjpJ = dz.devices(dzJourJ).state
local StatusEjpJ1 = dz.devices(dzJourJ1).state
local StatusEjpRestant = dz.devices(dzNb).state
local StatusEJP = dz.devices(dzEJP).state
if ( StatusEJP == 'Open' ) then --Etat Open ou Closed
dz.devices(dzEJPS).switchOff().silent()
else
dz.devices(dzEJPS).switchOn().silent()
end
--debug
if ( StatusLog == 'On' ) then
dz.log('EJP du Jour :', dz.PRIORITY_LOW)
dz.log(StatusEjpJ, dz.PRIORITY_LOW)
dz.log('EJP de Demain :', dz.PRIORITY_LOW)
dz.log(StatusEjpJ1, dz.PRIORITY_LOW)
dz.log('EJP Jours écoulés :', dz.PRIORITY_LOW)
dz.log(StatusEjpRestant, dz.PRIORITY_LOW)
dz.log('EJP contact EDF :', dz.PRIORITY_LOW)
dz.log(StatusEJP, dz.PRIORITY_LOW)
dz.log('Mois :', dz.PRIORITY_LOW)
dz.log(Mois, dz.PRIORITY_LOW)
dz.log('Minute :', dz.PRIORITY_LOW)
dz.log(Minute, dz.PRIORITY_LOW)
end
else
dz.devices(dzJourJ).updateAlertSensor(dz.ALERTLEVEL_GREEN,"NON_EJP")
dz.devices(dzJourJ1).updateAlertSensor(dz.ALERTLEVEL_GREEN,"Hors_période")
dz.devices(dzNb).updateCustomSensor(0)
--debug
if ( StatusLog == 'On' ) then
dz.log('Hors période EJP', dz.PRIORITY_LOW)
dz.log('EJP du 1er Novembre au 31 Mars', dz.PRIORITY_LOW)
end
end
end
}