[DzVents] Mise en cache des données de l’API prevision_meteo.ch

Vous avez créé un script LUA dont vous êtes fier, un .sh génial, un programme Python hors du commun, un Tuto, c'est ici que vous pouvez les partager.
Doudy
Messages : 457
Inscription : 07 mai 2016, 17:23

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Doudy »

Hello,
Personne pour m'éclairer ?

:(
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
papoo
Messages : 2029
Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par papoo »

Doudy a écrit : 09 déc. 2019, 08:47 Bonjour,

Avec Darksky j'ai le même message qu'avec previsions-meteo.ch :!:
Si vous avez une :idea:
ta connexion ne serait elle pas en cause? un éventuel manque de débit ou un dns trop long à résoudre l'ip? ou un blacklistage de ton ip sur ces API pour une éventuelle sur-utilisation? je ne peux faire que des suppositions n'ayant pas ce type de problèmes
domoticz beta/RaspBerry PI3 stretch
https://pon.fr github
Doudy
Messages : 457
Inscription : 07 mai 2016, 17:23

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Doudy »

papoo a écrit : 18 déc. 2019, 18:26 ta connexion ne serait elle pas en cause? un éventuel manque de débit ou un dns trop long à résoudre l'ip? ou un blacklistage de ton ip sur ces API pour une éventuelle sur-utilisation? je ne peux faire que des suppositions n'ayant pas ce type de problèmes
Dommage que tu n'as pas de solution.
Pourtant :
Lorsque je teste les liens dans un navigateur, j'ai une réponse immédiate.
Il n'y a que les liens "https" qui ne fonctionne pas dans le script !
Le lien "http" fonctionne et crée un fichier json.

;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Hellu2lo
Messages : 9
Inscription : 01 janv. 2020, 14:44

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Hellu2lo »

Bonjour,

Nouveau sur le forum et sur domoticz en général, j'ai fait mes premiers pas sans trop de difficultés avec les infos glanées un peu partout.

Tout allait bien jusqu'au moment où ma page météo n'affichait plus rien, c'est comme ça que je suis arrivé sur cette discussion.
J'ai fait et refait toutes les modifs et tous les essais comme Doudy l'a fait avec pour seul résultat que je tournais en rond.
Ce qui m'étonnait c'était de voir les données dans les logs mais pas dans le fichier "prevision-meteo.json" qui avait fini par se créer quand même.
J'ai donc pensé repartir de zéro, après avoir sauvegarde la config de domoticz et tous mes fichiers.
J'ai commencé par la réinstallation de raspbian, domoticz, et monitor puis j'ai restauré la config et rechargé toutes mes pages.
Pour terminer j'ai vérifié le fichier "prevision-meteo.json" et là, bonne surprise, il contient bien toutes les données météo du site en json :D
La seule différence entre avant et maintenant c'est que j'étais sous "buster" et j'ai remis "jessie lite".
Ce n'est peut être pas la cause (je n'y connais pas assez pour en être sûr) mais en tous cas c'est tout bon maintenant :D
papoo
Messages : 2029
Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par papoo »

merci pour ton retour d'experience
domoticz beta/RaspBerry PI3 stretch
https://pon.fr github
Patlazuli
Messages : 23
Inscription : 20 juin 2016, 08:58

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Patlazuli »

Bonjour,

Avez vous trouvé une solution, j'ai essayé tout ce qui est proposé sans succès :
weather-data.org = création de fichier (chmod ok) mais pas d'affichage
prevision-meteo.ch = dzVents: Error (2.4.19) et pas de création de fichier.

Merci de votre aide
Jmrios
Messages : 13
Inscription : 25 mars 2020, 17:50

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Jmrios »

Bonjour a tous
Cela fait des jours et des jours et encore des jours que je lis ce tuto de 6 pages qui va finir par me rendre fou pour essayer d'une part de générer puis de faire fonctionner le fichier prevision-meteo.json De plusj'ai exactement les mêmes probleme que Doudy se qui ma permis de faire tous les test qui ont été proposés avec un demi succès
Mon materiel, un raspberry PI3 connecter sur un SSD avec Raspbian Buster option bureau


Dans mon fichier previsionMeteo.lua Le seul scripts qui arrive sans défaut Error (2.4.19) a généré le fichier prevision-meteo.json

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 iconsPath     = 'http://192.168.x.xxx:8080/home/pi/domoticz/www/monitor/icons/prevision-meteo/' -- adresse local où sont stockés les icones    --Normal Adresse IP cachée

--------------------------------------------
----------- 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 1 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  = '43.2136116'
                logWrite('latitude : '..latitude)
                --local longitude = domoticz.settings.location.longitude
                local longitude = '2.9044440'
                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
}
Mais le resultat de l'extraction n'est pas au rendez-vous car cela extrais dans mon fichier prevision-meteo.json uniquement ses 4 lettres null

Code : Tout sélectionner

null
Et mon Log m'affiche null aussi

Code : Tout sélectionner

2020-03-25 18:46:00.249 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Start external script: previsionMeteo.lua:, trigger: every 1 minutes
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: latitude : 43.2136116
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: longitude : 2.9044440
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: url = https://www.prevision-meteo.ch/services/json/lat=43.2136116lng=2.9044440
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: method = GET
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: post data = nil
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: headers = nil
2020-03-25 18:46:00.249 Status: dzVents: Debug: Extraction prévisions météo v1.01: OpenURL: callback = prevision-meteo_response
2020-03-25 18:46:00.249 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Finished previsionMeteo.lua
2020-03-25 18:46:00.250 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-03-25 18:46:02.890 Status: dzVents: Info: Handling httpResponse-events for: "prevision-meteo_response
2020-03-25 18:46:02.890 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Start external script: previsionMeteo.lua: HTTPResponse: "prevision-meteo_response"
2020-03-25 18:46:02.894 Status: dzVents: Debug: Extraction prévisions météo v1.01: null
2020-03-25 18:46:02.895 Status: dzVents: Debug: Extraction prévisions météo v1.01: ecriture des données dans le fichier /home/pi/domoticz/www/monitor/prevision-meteo.json
2020-03-25 18:46:02.895 Status: dzVents: Info: Extraction prévisions météo v1.01: ------ Finished previsionMeteo.lua
Mon adresse https://www.prevision-meteo.ch/services ... =2.9044440 me renvoie bien toutes les données du site prévision météo

Quand je fait un copier coller de ses données méteo (ligne du dessus) dans le fichier 'prevision-meteo.json' mon tableau Monitor météo s'anime de toutes ses icones Chouet alors, Mais 1 minute apres (script lua reglé toutes les minutes, mode test) le script du fichier 'prevision-meteo.json' est écrasé pour afficher 'null'

J'ai fait le test proposer par papoo,
Test de l'url pour la réception des données meteo via la creation d'un fichier testsUrl.lua

Code : Tout sélectionner

local scriptName        = 'Test Urls'
local scriptVersion     = '0.1'

return {
	active = true,
	--active = false,
	on = {
		timer = {'every minute'},
		httpResponses = { 'testUrl*' },
	},
	
	logging =   {   level    =   domoticz.LOG_DEBUG,
				marker  =   scriptName..' v'..scriptVersion },
				
	execute = function(dz, item)
	
		if item.isHTTPResponse then
			--dz.utils.dumpTable(item)
			dz.log('Domoticz version: ' .. dz.settings.domoticzVersion .. ', and dzVents version : ' .. dz.settings.dzVentsVersion,dz.LOG_FORCE)

			dz.log(item.data,dz.LOG_FORCE)
		else
		    urls =
			{ 					
								
				["testUrl3"] = 'https://www.prevision-meteo.ch/services/json/lat=43.2136116lng=2.9044440"
			}

			for callback, url in pairs(urls) do 
				dz.openURL({ url = url , callback = callback })
			end
		end
	end
}

Dans mon Log tout est OK

Code : Tout sélectionner

2020-03-25 19:25:00.350 Status: dzVents: Debug: Test Urls v0.1: OpenURL: callback = testUrl4
2020-03-25 19:25:00.350 Status: dzVents: Info: Test Urls v0.1: ------ Finished testsUrl.lua
2020-03-25 19:25:00.350 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-03-25 19:25:02.629 Status: dzVents: Info: Handling httpResponse-events for: "testUrl4
2020-03-25 19:25:02.629 Status: dzVents: Info: Test Urls v0.1: ------ Start external script: testsUrl.lua: HTTPResponse: "testUrl4"
2020-03-25 19:25:02.629 Status: dzVents: !Info: Test Urls v0.1: Domoticz version: 4.10717, and dzVents version : 2.4.19
2020-03-25 19:25:02.630 Status: dzVents: !Info: Test Urls v0.1: {"city_info":{"name":"NA","country":"--","latitude":"43.2136116","longitude":"2.9044440","elevation":"NA","sunrise":"06:40","sunset":"19:08"},"forecast_info":{"latitude":"43.2136116","longitude":"2.9044440","elevation":"51.0"},"current_condition":{"date":"25.03.2020","hour":"20:00","tmp":9,"wnd_spd":9,"wnd_gust":23,"wnd_dir":"SE","pressure":1011.4,"humidity":65,"condition":"Nuit claire","condition_key":"nuit-claire","icon":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-claire.png","icon_big":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-claire-big.png"},"fcst_day_0":{"date":"25.03.2020","day_short":"Mer.","day_long":"Mercredi","tmin":5,"tmax":11,"condition":"Eclaircies","condition_key":"eclaircies","icon":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","icon_big":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies-big.png","hourly_data":{"0H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-nuageuse.png","CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","TMP2m":7.8,"DPT2m":0.1,"WNDCHILL2m":5.2,"HUMIDEX":null,"RH2m":58,"PRMSL":1018.6,"APCPsfc":0,"WNDSPD10m":15,"WNDGUST10m":24,"WNDDIR10m":130,"WNDDIRCARD10":"SE","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.80","HGT0C":1100,"KINDEX":16,"CAPE180_0":"0.000","CIN180_0":0},"1H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/fortement-nuageux.png","CONDITION":"Fortement nuageux","CONDITION_KEY":"fortement-nuageux","TMP2m":6.4,"DPT2m":0.1,"WNDCHILL2m":4.3,"HUMIDEX":null,"RH2m":64,"PRMSL":1018.3,"APCPsfc":0,"WNDSPD10m":10,"WNDGUST10m":22,"WNDDIR10m":132,"WNDDIRCARD10":"SE","ISSNOW":0,"HCDC":"0.00","MCDC":"88.90","LCDC":"1.50","HGT0C":1100,"KINDEX":27,"CAPE180_0":"3.000","CIN180_0":0},"2H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/fortement-nuageux.png","CONDITION":"Fortement nuageux","CONDITION_KEY":"fortement-nuageux","TMP2m":6.6,"DPT2m":0.9,"WNDCHILL2m":4.6,"HUMIDEX":null,"RH2m":67,"PRMSL":1017.5,"APCPsfc":0,"WNDSPD10m":10,"WNDGUST10m":19,"WNDDIR10m":141,"WNDDIRCARD10":"SE","ISSNOW":0,"HCDC":"0.00","MCDC":"66.70","LCDC":"0.00","HGT0C":1100,"KINDEX":24,"CAPE180_0":"2.000","CIN180_0":0},"3H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-nuageuse.png","CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","TMP2m":5.4,"DPT2m":0.3,"WNDCHILL2m":3.1,"HUMIDEX":null,"RH2m":70,"PRMSL":1016.4,"APCPsfc":0,"WNDSPD10m":10,"WNDGUST10m":16,"WNDDIR10m":169,"WNDDIRCARD10":"S","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"2.90","HGT0C":1100,"KINDEX":25,"CAPE180_0":"0.000","CIN180_0":0},"4H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-nuageuse.png","CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","TMP2m":6,"DPT2m":1,"WNDCHILL2m":4.6,"HUMIDEX":null,"RH2m":70,"PRMSL":1016,"APCPsfc":0,"WNDSPD10m":7,"WNDGUST10m":15,"WNDDIR10m":194,"WNDDIRCARD10":"S","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"2.10","HGT0C":1100,"KINDEX":27,"CAPE180_0":"0.000","CIN180_0":0},"5H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-nuageuse.png","CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","TMP2m":4.5,"DPT2m":0.5,"WNDCHILL2m":2.8,"HUMIDEX":null,"RH2m":75,"PRMSL":1016,"APCPsfc":0,"WNDSPD10m":7,"WNDGUST10m":12,"WNDDIR10m":203,"WNDDIRCARD10":"S","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1100,"KINDEX":29,"CAPE180_0":"0.000","CIN180_0":0},"6H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/nuit-nuageuse.png","CONDITION":"Nuit nuageuse","CONDITION_KEY":"nuit-nuageuse","TMP2m":4.8,"DPT2m":0.2,"WNDCHILL2m":4.8,"HUMIDEX":null,"RH2m":72,"PRMSL":1016.2,"APCPsfc":0,"WNDSPD10m":3,"WNDGUST10m":12,"WNDDIR10m":166,"WNDDIRCARD10":"S","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1100,"KINDEX":34,"CAPE180_0":"0.000","CIN180_0":0},"7H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2m":5.7,"DPT2m":1.4,"WNDCHILL2m":3.7,"HUMIDEX":null,"RH2m":74,"PRMSL":1016.2,"APCPsfc":0,"WNDSPD10m":9,"WNDGUST10m":15,"WNDDIR10m":59,"WNDDIRCARD10":"NE","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1000,"KINDEX":37,"CAPE180_0":"1.000","CIN180_0":-2},"8H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2m":5.4,"DPT2m":2.2,"WNDCHILL2m":2.2,"HUMIDEX":null,"RH2m":80,"PRMSL":1016.7,"APCPsfc":0,"WNDSPD10m":15,"WNDGUST10m":24,"WNDDIR10m":53,"WNDDIRCARD10":"NE","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1000,"KINDEX":40,"CAPE180_0":"0.000","CIN180_0":0},"9H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2m":6.2,"DPT2m":2.5,"WNDCHILL2m":3.4,"HUMIDEX":null,"RH2m":77,"PRMSL":1016.9,"APCPsfc":0,"WNDSPD10m":14,"WNDGUST10m":25,"WNDDIR10m":55,"WNDDIRCARD10":"NE","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1000,"KINDEX":45,"CAPE180_0":"0.000","CIN180_0":0},"10H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2m":7.5,"DPT2m":2.9,"WNDCHILL2m":5,"HUMIDEX":null,"RH2m":73,"PRMSL":1016.4,"APCPsfc":0,"WNDSPD10m":14,"WNDGUST10m":23,"WNDDIR10m":69,"WNDDIRCARD10":"E","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1000,"KINDEX":48,"CAPE180_0":"13.000","CIN180_0":0},"11H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2m":9.4,"DPT2m":3.2,"WNDCHILL2m":6.6,"HUMIDEX":null,"RH2m":66,"PRMSL":1016.1,"APCPsfc":0,"WNDSPD10m":20,"WNDGUST10m":31,"WNDDIR10m":105,"WNDDIRCARD10":"E","ISSNOW":0,"HCDC":"0.00","MCDC":"100.00","LCDC":"0.00","HGT0C":1000,"KINDEX":47,"CAPE180_0":"52.000","CIN180_0":0},"12H00":{"ICON":"https:\/\/www.prevision-meteo.ch\/style\/images\/icon\/eclaircies.png","CONDITION":"Eclaircies","CONDITION_KEY":"eclaircies","TMP2
2020-03-25 19:25:02.630 Status: dzVents: Info: Test Urls v0.1: ------ Finished testsUrl.lua
Beaucoup d'info d'un seul coup, mais si quelqu'un a déjà eu ce type de problème je suis a son écoute
Merci d'avance
Darkneo
Messages : 68
Inscription : 16 déc. 2018, 08:50

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Darkneo »

Hello à tous!

Alors perso j'ai aussi eu pas mal de soucis pour démarrer le script, mais plutôt lié à mon installation Domoticz.

Par contre, j'ai aussi dans les logs ce message d'erreur:

Code : Tout sélectionner

Status: dzVents: Info: Extraction pr?visions m?t?o v1.0: ------ Start external script: previsionMeteo.lua:, trigger: every 10 minutes
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: latitude : 46.259
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: longitude : 5.235
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: OpenURL: url = http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: OpenURL: method = GET
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: OpenURL: post data = nil
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: OpenURL: headers = nil
Status: dzVents: Debug: Extraction pr?visions m?t?o v1.0: OpenURL: callback = prevision-meteo_response
Status: dzVents: Info: Extraction pr?visions m?t?o v1.0: ------ Finished previsionMeteo.lua
Status: dzVents: Debug: Commands sent to Domoticz:
Status: dzVents: Debug: - OpenURL = {["_trigger"]="prevision-meteo_response", ["URL"]="http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235", ["method"]="GET"}
Status: dzVents: Debug: =====================================================
Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
Status: dzVents: Debug: Dumping domoticz data to /usr/local/domoticz/var/scripts/dzVents/domoticzData.lua
Status: dzVents: Debug: dzVents version: 2.4.6
Status: dzVents: Debug: Event triggers:
Status: dzVents: Debug: - HTTPResponse: prevision-meteo_response
Status: dzVents: Info: Handling httpResponse-events for: "prevision-meteo_response
Status: dzVents: Info: Extraction pr?visions m?t?o v1.0: ------ Start external script: previsionMeteo.lua: HTTPResponse: "prevision-meteo_response"
Status: dzVents: Error (2.4.6): Extraction pr?visions m?t?o v1.0: Last http response was not what expected. Trigger: prevision-meteo_response
Status: dzVents: Info: Extraction pr?visions m?t?o v1.0: ------ Finished previsionMeteo.lua
Error: Error opening url: http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235
Pourtant, quand je copie/colle l'url http dans un navigateur, cela s'affiche correctement....

Et aucun fichier généré dans le dossier monitor...
papoo
Messages : 2029
Inscription : 10 janv. 2016, 11:29
Localisation : Limoges (87)
Contact :

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par papoo »

est-ce que le script génère un fichier, même vide?
si ce n'est pas le cas c'est un problème de droits sur le répertoire dans lequel vous voulez créer ce fichier.
je vois joins un fichier zippé pour copié coller dans le répertoire ad hoc (attention à bien lui donner les droits, chmod +x et utilisateur PI) il sera remplacé lors de la prochaine exécution du script
Pièces jointes
prevision-meteo.zip
(4.72 Kio) Téléchargé 298 fois
domoticz beta/RaspBerry PI3 stretch
https://pon.fr github
Darkneo
Messages : 68
Inscription : 16 déc. 2018, 08:50

Re: DZVents : mise en cache des données de l’API prevision_meteo.ch

Message par Darkneo »

Hello et merci pour le fichier et la réponse!

En fait j'avais déjà anticipé en faisant un touch prevision_meteo.json. j'attends le prochaine passage (dans 2 minutes :D )

En attendant je me lance aussi dans le debug de darksky :lol:

Edit: Erf, pas mieux, le fichier est toujours vide...

Code : Tout sélectionner

Status: dzVents: Info:  Extraction prévisions météo v1.0: ------ Start external script: previsionMeteo.lua:, trigger: every 10 minutes
Status: dzVents: Debug: Extraction prévisions météo v1.0:   latitude : 46.259
Status: dzVents: Debug: Extraction prévisions météo v1.0:   longitude : 5.235
Status: dzVents: Debug: Extraction prévisions météo v1.0: OpenURL: url = http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235
Status: dzVents: Debug: Extraction prévisions météo v1.0: OpenURL: method = GET
Status: dzVents: Debug: Extraction prévisions météo v1.0: OpenURL: post data = nil
Status: dzVents: Debug: Extraction prévisions météo v1.0: OpenURL: headers = nil
Status: dzVents: Debug: Extraction prévisions météo v1.0: OpenURL: callback = prevision-meteo_response
Status: dzVents: Info:  Extraction prévisions météo v1.0: ------ Finished previsionMeteo.lua
Status: dzVents: Debug: Commands sent to Domoticz: 
Status: dzVents: Debug: - OpenURL = {["URL"]="http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235", ["method"]="GET", ["_trigger"]="prevision-meteo_response"}
Status: dzVents: Debug: =====================================================
Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
[1;31mError: Error opening url: http://www.prevision-meteo.ch/services/json/lat=46.259lng=5.235[0;0m
Status: dzVents: Debug: Dumping domoticz data to /usr/local/domoticz/var/scripts/dzVents/domoticzData.lua
Status: dzVents: Debug: dzVents version: 2.4.6
Status: dzVents: Debug: Event triggers:
Status: dzVents: Debug: - HTTPResponse: prevision-meteo_response
Status: dzVents: Info:  Handling httpResponse-events for: "prevision-meteo_response
Status: dzVents: Info:  Extraction prévisions météo v1.0: ------ Start external script: previsionMeteo.lua: HTTPResponse: "prevision-meteo_response"
Status: dzVents: Error (2.4.6): Extraction prévisions météo v1.0:   Last http response was not what expected. Trigger: prevision-meteo_response
Status: dzVents: Info:  Extraction prévisions météo v1.0: ------ Finished previsionMeteo.lua
Edit#2:
Je ne sais pas si ça peut avoir un lien avec la choucroute... mais en débugguant monitor (en fait je debug un peu tout à chaque fois j'ai l'impression!) je me suite rendu compté d'un truc bizarre sur la page météo:
En gros, la requête executé par la page météo (en jquery) était en cancel. Résultat: aucune information affichée sur les prévision à J+3.
Ce soir, pour une raison inconnue, la commande jquery est passée (alors que je n'ai rein changé sur la page meteo.html). Par contre je vois une étape intermédiaire 307 Internal redirect, qui me donne ensuite une nouvelle jquery:

Code : Tout sélectionner

Request URL: https://www.prevision-meteo.ch/services/json/Toulouse?_=1585252562131
Question certainement stupide mais je vais la poser quand même... Pourquoi on laisse le serveur faire la redirection http => https? car si on claque la requête en https elle pourrait passer directement, nan? Est ce que ca peut être la même erreur dans le script (vu que la requête http balancée est en http)?
Dernière modification par Darkneo le 26 mars 2020, 21:03, modifié 1 fois.
Répondre