erreur dzVents dans mes logs

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Moulins58
Messages : 134
Inscription : 17 févr. 2019, 20:41

erreur dzVents dans mes logs

Message par Moulins58 »

Bonsoir,
J'ai une erreur dzVents dans mes log concernant les prévisions météo.
2020-04-26 19:12:03.398 Error: dzVents: Error: (3.0.1) Extraction prévisions météo v1.01: An error occurred when calling event handler previsionMeteo
2020-04-26 19:12:03.398 Error: dzVents: Error: (3.0.1) Extraction prévisions météo v1.01: ...e/pi/domoticz/scripts/dzVents/scripts/previsionMeteo.lua:131: attempt to index a nil value (global 'file')

Quelqu'un pourrait.il m'aider.
denis_brasseur
Messages : 898
Inscription : 24 déc. 2018, 17:05
Localisation : (26)

Re: erreur dzVents dans mes logs

Message par denis_brasseur »

Sans nous montrer ton script previsionMeteo.lua, difficile de t'aider.
Première utilisation du script ?
Si script déjà en place, depuis quand tes messages d'erreur ?
On veut bien t'aider, mais aide nous.
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Moulins58
Messages : 134
Inscription : 17 févr. 2019, 20:41

Re: erreur dzVents dans mes logs

Message par Moulins58 »

Merci de la réponse rapide. J'ai mis en place ce script hier, après avoir galéré une semaine.
Ci-dessous le script:

Code : Tout sélectionner

--[[
previsionMeteo.lua
author/auteur = papoo
update/mise à jour = 04/10/2019
création = 18/08/2019
https://pon.fr/dzvents-mise-en-cache-des-donnees-de-lapi-prevision_meteo-ch
https://github.com/papo-o/domoticz_scripts/blob/master/dzVents/scripts/previsionMeteo.lua
https://easydomoticz.com/forum/viewtopic.php?f=17&t=8865
https://easydomoticz.com/forum/
https://easydomoticz.com/forum/viewtopic.php?f=17&t=8865&p=75038#p75038


Principe : Le site prevision-meteo.ch subit de nombreux ralentissements, rendant aléatoire l'affichage des prévisions météo sur monitor
https://pon.fr/prevision-meteo-a-3-jours/
Ce script permet la récupération des données via l'API, la modification du chemin d'accès aux icones afin de les stocker en local.
Si les données sont inaccessibles lors de l'appel de l'API, les données précédentes ne sont pas écrasées, permettant le fonctionnement continue de la page météo
Téléchargez les 36 icones météo dans le dossier dédié de monitor /home/pi/domoticz/www/monitor/icons/prevision-meteo/
https://www.prevision-meteo.ch/style/images/icon/ensoleille.png
https://www.prevision-meteo.ch/style/images/icon/nuit-claire.png
https://www.prevision-meteo.ch/style/images/icon/ciel-voile.png
https://www.prevision-meteo.ch/style/images/icon/nuit-legerement-voilee.png
https://www.prevision-meteo.ch/style/images/icon/faibles-passages-nuageux.png
https://www.prevision-meteo.ch/style/images/icon/nuit-bien-degagee.png
https://www.prevision-meteo.ch/style/images/icon/brouillard.png
https://www.prevision-meteo.ch/style/images/icon/stratus.png
https://www.prevision-meteo.ch/style/images/icon/stratus-se-dissipant.png
https://www.prevision-meteo.ch/style/images/icon/nuit-claire-et-stratus.png
https://www.prevision-meteo.ch/style/images/icon/eclaircies.png
https://www.prevision-meteo.ch/style/images/icon/nuit-nuageuse.png
https://www.prevision-meteo.ch/style/images/icon/faiblement-nuageux.png
https://www.prevision-meteo.ch/style/images/icon/fortement-nuageux.png
https://www.prevision-meteo.ch/style/images/icon/averses-de-pluie-faible.png
https://www.prevision-meteo.ch/style/images/icon/nuit-avec-averses.png
https://www.prevision-meteo.ch/style/images/icon/averses-de-pluie-moderee.png
https://www.prevision-meteo.ch/style/images/icon/averses-de-pluie-forte.png
https://www.prevision-meteo.ch/style/images/icon/couvert-avec-averses.png
https://www.prevision-meteo.ch/style/images/icon/pluie-faible.png
https://www.prevision-meteo.ch/style/images/icon/pluie-forte.png
https://www.prevision-meteo.ch/style/images/icon/pluie-moderee.png
https://www.prevision-meteo.ch/style/images/icon/developpement-nuageux.png
https://www.prevision-meteo.ch/style/images/icon/nuit-avec-developpement-nuageux.png
https://www.prevision-meteo.ch/style/images/icon/faiblement-orageux.png
https://www.prevision-meteo.ch/style/images/icon/nuit-faiblement-orageuse.png
https://www.prevision-meteo.ch/style/images/icon/orage-modere.png
https://www.prevision-meteo.ch/style/images/icon/fortement-orageux.png
https://www.prevision-meteo.ch/style/images/icon/averses-de-neige-faible.png
https://www.prevision-meteo.ch/style/images/icon/nuit-avec-averses-de-neige-faible.png
https://www.prevision-meteo.ch/style/images/icon/neige-faible.png
https://www.prevision-meteo.ch/style/images/icon/neige-moderee.png
https://www.prevision-meteo.ch/style/images/icon/neige-forte.png
https://www.prevision-meteo.ch/style/images/icon/pluie-et-neige-melee-faible.png
https://www.prevision-meteo.ch/style/images/icon/pluie-et-neige-melee-moderee.png
https://www.prevision-meteo.ch/style/images/icon/pluie-et-neige-melee-forte.png



--]]
--------------------------------------------
------------ Variables à éditer ------------
--------------------------------------------

local jsonFile      = '/home/pi/domoticz/www/monitor/prevision-meteo.json' -- nom du fichier (et son chemin complet) contenant les données de l'API
local jsonFile      = 'http://192.168.1.79:8080/home/pi/domoticz/www/monitor/prevision-meteo.json' -- nom du fichier (et son chemin complet) contenant les données de l'API
local iconsPath     = 'http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/' -- adresse local où sont stockés les icones

--------------------------------------------
----------- Fin variables à éditer ---------
--------------------------------------------
local scriptName        = 'Extraction prévisions météo'
local scriptVersion     = '1.01'
local response = "prevision-meteo_response"
return {
    active = true,
    on =        {       timer           =   { "every 6 minutes" },
                        httpResponses   =   {  response } },

    logging =   {    level    =   domoticz.LOG_DEBUG,
                    -- -- level    =   domoticz.LOG_INFO,             -- Seulement un niveau peut être actif; commenter les autres
                    -- -- level    =   domoticz.LOG_ERROR,            -- Only one level can be active; comment others
                    -- -- level    =   domoticz.LOG_MODULE_EXEC_INFO,
                    marker  =   scriptName..' v'..scriptVersion },

    execute = function(domoticz, item)

        local function logWrite ( str, level)  -- afficher le contenu d'un tableau
            local logTableWrite_cache = {}
            local function sub_logTableWrite(str, indent)
                if (logTableWrite_cache[tostring(str)]) then
                    domoticz.log(indent.."*"..tostring(str), level or domoticz.LOG_DEBUG)
                else
                    logTableWrite_cache[tostring(str)]=true
                    if (type(str)=="table") then
                        for pos,val in pairs(str) do
                            if (type(val)=="table") then
                                --domoticz.log(indent.."["..tostring(pos).."] - ["..tostring(str).."] => {", level or domoticz.LOG_DEBUG)
                                domoticz.log(indent.."["..tostring(pos).."] => {", level or domoticz.LOG_DEBUG)
                                sub_logTableWrite(val,indent..string.rep(" ",string.len(pos)+8))
                                domoticz.log(indent..string.rep(" ",string.len(pos)+6).."}", level or domoticz.LOG_DEBUG)
                            elseif (type(val)=="string") then
                                domoticz.log(indent.." "..pos..' = "'..val..'"', level or domoticz.LOG_DEBUG)
                                --domoticz.log(indent..pos..' => "'..val..'"', level or domoticz.LOG_DEBUG)
                            else
                                domoticz.log(indent.." "..pos.." = "..tostring(val), level or domoticz.LOG_DEBUG)
                                --domoticz.log(indent..pos.." = "..tostring(val), level or domoticz.LOG_DEBUG)
                            end
                        end
                    else
                        domoticz.log(indent..tostring(str), level or domoticz.LOG_DEBUG)
                    end
                end
            end
            if (type(str)=="table") then
                domoticz.log("["..tostring(str).."] => {", level or domoticz.LOG_DEBUG)
                sub_logTableWrite(str,"  ")
                domoticz.log("}", level or domoticz.LOG_DEBUG)
            else
                sub_logTableWrite(str,"  ")
            end
            print()
        end

        if (item.isHTTPResponse and item.trigger == response) then
            if (not item.isJSON) then
                logWrite('Last http response was not what expected. Trigger: '..item.trigger,domoticz.LOG_ERROR)
            else
                local contents = domoticz.utils.toJSON(item.json)
                contents = contents:gsub('https://www(.?)prevision(.?)meteo(.?)ch/style/images/icon/', iconsPath) 
                logWrite(contents)
                if contents then
                    file = io.open(jsonFile, "w+")
                    file:write( contents )
                    io.close( file )
                    --file:close()
                    logWrite('ecriture des données dans le fichier '..jsonFile)
                end
            end

        else
                --local latitude  = domoticz.settings.location.latitude
                local latitude  = '47.366285'
                logWrite('latitude : '..latitude)
                --local longitude = domoticz.settings.location.longitude
                local longitude = '-1.619198'
                logWrite('longitude : '..longitude)
                local url = "https://www.prevision-meteo.ch/services/json/lat="..latitude.."lng="..longitude

            domoticz.openURL({
                  url = url,
                        method = "GET",
                        callback = response})
        end
    end
}

et dans mes logs :

Code : Tout sélectionner

2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: latitude : 47.366285
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: longitude : -1.619198
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: url = https://www.prevision-meteo.ch/services/json/lat=47.366285lng=-1.619198
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: method = GET
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: post data = nil
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: headers = nil
2020-04-27 06:36:00.579 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: callback = prevision-meteo_response
2020-04-27 06:36:00.579 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Finished previsionMeteo.lua
2020-04-27 06:36:00.580 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-04-27 06:36:02.925 Status: dzVents: Info: Handling httpResponse-events for: "prevision-meteo_response"
2020-04-27 06:36:02.925 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Start external script: previsionMeteo.lua: HTTPResponse: "prevision-meteo_response"
2020-04-27 06:36:03.082 Status: dzVents: Debug: Extraction prévisions météo v1.01: {"city_info":{"country":"--","elevation":"NA","latitude":"47.366285","longitude":"-1.619198","name":"NA","sunrise":"06:53","sunset":"21:14"},"current_condition":{"condition":"Stratus","condition_key":"stratus","date":"27.04.2020","hour":"07:00","humidity":97,"icon":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/stratus.png","icon_big":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/stratus-big.png","pressure":1004.5,"tmp":7,"wnd_dir":"E","wnd_gust":11,"wnd_spd":7},"fcst_day_0":{"condition":"Averses de pluie faible","condition_key":"averses-de-pluie-faible","date":"27.04.2020","day_long":"Lundi","day_short":"Lun.","hourly_data":{"0H00":{"APCPsfc":0,"CAPE180_0":"0.000","CIN180_0":0,"CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","DPT2m":8.8,"HCDC":"0.00","HGT0C":2600,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/nuit-nuageuse.png","ISSNOW":0,"KINDEX":36,"LCDC":"0.00","MCDC":"0.00","PRMSL":1007.2,"RH2m":93,"TMP2m":9.9,"WNDCHILL2m":8.3,"WNDDIR10m":298,"WNDDIRCARD10":"NO","WNDGUST10m":18,"WNDSPD10m":11},"10H00":{"APCPsfc":0,"CAPE180_0":"0.000","CIN180_0":-4,"CONDITION":"Ensoleillé","CONDITION_KEY":"ensoleille","DPT2m":10.4,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/ensoleille.png","ISSNOW":0,"KINDEX":39,"LCDC":"0.00","MCDC":"0.00","PRMSL":1004.9,"RH2m":88,"TMP2m":12.5,"WNDDIR10m":321,"WNDDIRCARD10":"NO","WNDGUST10m":4,"WNDSPD10m":2},"11H00":{"APCPsfc":0,"CAPE180_0":"0.000","CIN180_0":0,"CONDITION":"Ensoleillé","CONDITION_KEY":"ensoleille","DPT2m":10.7,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/ensoleille.png","ISSNOW":0,"KINDEX":38,"LCDC":"0.00","MCDC":"0.00","PRMSL":1004.7,"RH2m":87,"TMP2m":12.8,"WNDDIR10m":267,"WNDDIRCARD10":"O","WNDGUST10m":10,"WNDSPD10m":6},"12H00":{"APCPsfc":0.1,"CAPE180_0":"0.000","CIN180_0":-8,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":11.4,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":35,"LCDC":"0.00","MCDC":"0.00","PRMSL":1004.4,"RH2m":83,"TMP2m":14.3,"WNDDIR10m":297,"WNDDIRCARD10":"NO","WNDGUST10m":13,"WNDSPD10m":8},"13H00":{"APCPsfc":0.1,"CAPE180_0":"48.000","CIN180_0":-6,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":12,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":37,"LCDC":"0.00","MCDC":"0.00","PRMSL":1003.9,"RH2m":76,"TMP2m":16.2,"WNDDIR10m":340,"WNDDIRCARD10":"N","WNDGUST10m":16,"WNDSPD10m":10},"14H00":{"APCPsfc":0.1,"CAPE180_0":"134.000","CIN180_0":-10,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":12.1,"HCDC":"55.60","HGT0C":2300,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":37,"LCDC":"0.00","MCDC":"0.00","PRMSL":1003.6,"RH2m":75,"TMP2m":16.5,"WNDDIR10m":345,"WNDDIRCARD10":"N","WNDGUST10m":16,"WNDSPD10m":7},"15H00":{"APCPsfc":1.7,"CAPE180_0":"96.000","CIN180_0":0,"CONDITION":"Faiblement orageux","CONDITION_KEY":"faiblement-orageux","DPT2m":13.5,"HCDC":"0.00","HGT0C":2500,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/faiblement-orageux.png","ISSNOW":0,"KINDEX":34,"LCDC":"0.00","MCDC":"0.00","PRMSL":1002.5,"RH2m":89,"TMP2m":15.3,"WNDDIR10m":308,"WNDDIRCARD10":"NO","WNDGUST10m":29,"WNDSPD10m":18},"16H00":{"APCPsfc":2.4,"CAPE180_0":"68.000","CIN180_0":0,"CONDITION":"Faiblement orageux","CONDITION_KEY":"faiblement-orageux","DPT2m":13.7,"HCDC":"0.00","HGT0C":2500,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/faiblement-orageux.png","ISSNOW":0,"KINDEX":34,"LCDC":"0.00","MCDC":"0.00","PRMSL":1002.3,"RH2m":95,"TMP2m":14.5,"WNDDIR10m":292,"WNDDIRCARD10":"O","WNDGUST10m":32,"WNDSPD10m":19},"17H00":{"APCPsfc":1.6,"CAPE180_0":"22.000","CIN180_0":0,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":13,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":34,"LCDC":"0.00","MCDC":"0.00","PRMSL":1002.2,"RH2m":95,"TMP2m":13.9,"WNDDIR10m":289,"WNDDIRCARD10":"O","WNDGUST10m":30,"WNDSPD10m":15},"18H00":{"APCPsfc":0.2,"CAPE180_0":"7.000","CIN180_0":0,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":12.4,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":34,"LCDC":"0.00","MCDC":"0.00","PRMSL":1002.1,"RH2m":94,"TMP2m":13.4,"WNDDIR10m":308,"WNDDIRCARD10":"NO","WNDGUST10m":25,"WNDSPD10m":16},"19H00":{"APCPsfc":0.6,"CAPE180_0":"3.000","CIN180_0":0,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":11.8,"HCDC":"0.00","HGT0C":2400,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/averses-de-pluie-faible.png","ISSNOW":0,"KINDEX":35,"LCDC":"0.00","MCDC":"0.00","PRMSL":1001.9,"RH2m":97,"TMP2m":12.3,"WNDDIR10m":297,"WNDDIRCARD10":"NO","WNDGUST10m":26,"WNDSPD10m":16},"1H00":{"APCPsfc":0,"CAPE180_0":"0.000","CIN180_0":0,"CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","DPT2m":8.2,"HCDC":"0.00","HGT0C":2600,"ICON":"http://192.168.1.79:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/nuit-nuageuse.png","ISSNOW":0,"KINDEX":35,"LCDC":"0.00","MCDC":"0.00","PRMSL":1006.8,"RH2m":95,"TMP2m":9.1,"WNDCHILL2m":7.6,"WNDDIR10m":315,"WNDDIRCARD10":"NO","WNDGUST10m":17,"WNDSPD10m":10},"20H00":{"APCPsfc":0.7,"CAPE180_0":"3.000","CIN180_0":0,"CONDITION":"Averses de pluie faible","CONDITION_KEY":"averses-de-pluie-faible","DPT2m":11.7,"HCDC":"33.30","HGT0C":2400,"ICON":"htt
2020-04-27 06:36:03.083 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Finished previsionMeteo.lua
2020-04-27 06:36:03.082 Error: dzVents: Error: (3.0.1) Extraction prévisions météo v1.01: An error occurred when calling event handler previsionMeteo
2020-04-27 06:36:03.083 Error: dzVents: Error: (3.0.1) Extraction prévisions météo v1.01: ...e/pi/domoticz/scripts/dzVents/scripts/previsionMeteo.lua:131: attempt to index a nil value (global 'file')
Bonne semaine.
denis_brasseur
Messages : 898
Inscription : 24 déc. 2018, 17:05
Localisation : (26)

Re: erreur dzVents dans mes logs

Message par denis_brasseur »

S'agissant du script previsionMeteo.lua de papoo, tu devrais poster dans la bonne rubrique
DZVents : mise en cache des données de l’API prevision_meteo.ch
A noter qu'il existe une version 1.02, et 9 pages sur le post d'origine, à lire de bout en bout.
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Moulins58
Messages : 134
Inscription : 17 févr. 2019, 20:41

Re: erreur dzVents dans mes logs

Message par Moulins58 »

Merci, et milles excuses, je change.
Bonne journée
Répondre