Voila l'erreur que j'ai sur le script EJP :
2019-11-02 15:29:00.761 Error: dzVents: Error: (2.4.29) An error occurred when calling event handler dzVents Script_time_ejp
2019-11-02 15:29:00.761 Error: dzVents: Error: (2.4.29) /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode(): <HTML><HEAD>
2019-11-02 15:29:00.761 <TITLE>Access Denied</TITLE>
2019-11-02 15:29:00.761 </HEAD><BODY>
2019-11-02 15:29:00.761 <H1>Access Denied</H1>
2019-11-02 15:29:00.761
2019-11-02 15:29:00.761 You don't have permission to access "http://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?" on this server.<P>
2019-11-02 15:29:00.761 Reference #18.40281102.1572704940.80f2d056
2019-11-02 15:29:00.761 </BODY>
2019-11-02 15:29:00.761 </HTML>
Pourtant dans un navigateur le lien : https://particulier.edf.fr/bin/edf_rc/s ... 2019-11-02 fonctionne bien.
Ci dessous le script que j'utilise :
Code : Tout sélectionner
--Ce script dzVents récupère les infos EJP
--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' -- dz Text sensor : Nom exact du "Alert sensor" indiquant l'ejp du jour
local dzJourJ1 ='EJP Demain' -- dz Text sensor : Nom exact du "Alert sensor" indiquant l'ejp de demain
local dzEJPS ='EJP Switch' -- Switch etat EJP du jour
local dzNb ='EJP J_Restant' -- dz Custom sensor : Nom exact du "Custom sensor" indiquant le nombre de jours ejp restants
local dzDebugLog='Log' --Entrée avec sans Log
-----------------------------------------------------------------------
------------------ 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)
local StatusLog = dz.devices(dzDebugLog).state
if ( tonumber(mois) < 4 or tonumber(mois) > 10 ) then
--Extraction des EJP du jour et du lendemain
local jsonHisto = json:decode(os.capture(cmdHisto))
local EjpJ = jsonHisto['JourJ']['Ejp' .. KeyZone]
local EjpJ1 = jsonHisto['JourJ1']['Ejp' .. KeyZone]
--Extraction du nombre de jours total
local jsonParams = json:decode(os.capture(cmdParams))
local NbTotal = jsonParams[KeyNbj]
--Extraction du nombre de jours passés
local jsonEtat = json:decode(os.capture(cmdEtat))
local NbPass = jsonEtat[MajZone]['Total']
--Nombre de jours restants
local NbRestant = tostring(tonumber(NbPass) - tonumber(NbTotal))
--Recup des valeurs dz
local StatusEjpJ = dz.devices(dzJourJ).state
local StatusEjpJ1 = dz.devices(dzJourJ1).state
local StatusEjpRestant = dz.devices(dzNb).state
if ( StatusEjpRestant ~= NbRestant ) then
dz.devices(dzNb).updateCustomSensor(NbRestant)
end
if ( StatusEjpJ ~= EjpJ ) then
if (EjpJ =='NON_EJP' ) then
dz.devices(dzJourJ).updateAlertSensor(dz.ALERTLEVEL_GREEN,EjpJ) else
dz.devices(dzJourJ).updateAlertSensor(dz.ALERTLEVEL_RED,EjpJ)
end
end
if (EjpJ =='NON_EJP' ) then
dz.devices(dzEJPS).switchOff().silent() else
dz.devices(dzEJPS).switchOn().silent()
end
if ( StatusEjpJ1 ~= EjpJ1 ) then
if (EjpJ1 =='NON_EJP' ) then
dz.devices(dzJourJ1).updateAlertSensor(dz.ALERTLEVEL_GREEN,EjpJ1) else
if (EjpJ1 =='ND' ) then
dz.devices(dzJourJ1).updateAlertSensor(dz.ALERTLEVEL_GREY,EjpJ1) else
dz.devices(dzJourJ1).updateAlertSensor(dz.ALERTLEVEL_RED,EjpJ1)
end
end
end
--debug
if ( StatusLog == 'On' ) then
dz.log('EJP du Jour :', dz.PRIORITY_LOW)
dz.log(EjpJ, dz.PRIORITY_LOW)
dz.log('EJP de Demain :', dz.PRIORITY_LOW)
dz.log(EjpJ1, dz.PRIORITY_LOW)
dz.log('EJP Jours écoulés :', dz.PRIORITY_LOW)
dz.log(NbRestant, dz.PRIORITY_LOW)
--dz.log(cmdHisto, dz.PRIORITY_LOW)
--dz.log(cmdParams, dz.PRIORITY_LOW)
--dz.log(cmdEtat, 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(dzEJPS).switchOff().silent()
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
}J'ai essayé de remplacer :
local cmdHisto = 'curl -s \"' .. URLetat .. dateJ .. '\"'
par
local cmdHisto = 'curl -s \"https://particulier.edf.fr/bin/edf_rc/s ... 2019-11-02"'
et j'ai la même erreur
2019-11-02 15:55:00.978 Error: dzVents: Error: (2.4.29) An error occurred when calling event handler dzVents Script_time_ejp
2019-11-02 15:55:00.978 Error: dzVents: Error: (2.4.29) /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode(): <HTML><HEAD>
2019-11-02 15:55:00.978 <TITLE>Access Denied</TITLE>
2019-11-02 15:55:00.978 </HEAD><BODY>
2019-11-02 15:55:00.978 <H1>Access Denied</H1>
2019-11-02 15:55:00.978
2019-11-02 15:55:00.978 You don't have permission to access "http://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?" on this server.<P>
2019-11-02 15:55:00.978 Reference #18.2f281102.1572706500.5d45b36f
2019-11-02 15:55:00.978 </BODY>
2019-11-02 15:55:00.978 </HTML>