Après avoir récupéré la couleur quoi de plus légitime que de vouloir connaitre le nombre de jours rouge restant.
Code : Tout sélectionner
--[[
Tous les matins,
Récupère le nombre de jours bleu, blanc et rouge, et envoie un mail
- quand les blanc et rouge s'activent
ou
- quand les blanc et rouge finissent
--]]
return {
on = { timer = { 'at 06:10' }
},
execute = function(domoticz, timer)
ancienBleu = domoticz.devices(412).counter
ancienBlanc = domoticz.devices(413).counter
ancienRouge = domoticz.devices(414).counter
-- import des fontions pour lire le JSON
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
-- specify the user Agent to avoid the "Access Denied" issue
command = "curl -A 'Wget/1.20.3 (linux-gnu)' " .. '"' .. "https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO" .. '"'
config=assert(io.popen(command))
blocjson = config:read('*all')
config:close()
jsonValeur = json:decode(blocjson)
bleu = jsonValeur.PARAM_NB_J_BLEU
blanc = jsonValeur.PARAM_NB_J_BLANC
rouge = jsonValeur.PARAM_NB_J_ROUGE
if ( ancienBlanc == 0 and blanc > 0)
or ( ancienRouge == 0 and rouge > 0)
then
domoticz.email('Notif Domoticz', 'Début Tempo !', 'youraddress@yourserver.com')
elseif ( (ancienBlanc > 0 or ancienRouge > 0 ) and blanc == 0 and rouge == 0)
then
domoticz.email('Notif Domoticz', 'Fin Tempo !', 'youraddress@yourserver.com')
end
domoticz.devices(412).updateCounter(bleu)
domoticz.devices(413).updateCounter(blanc)
domoticz.devices(414).updateCounter(rouge)
end -- execute function
}
The Datawolf