Monitor Affichage page METEO -

Forum dédié aux interfaces personnalisables : Custom Pages, Reacticz, Domoboard...
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Salut,
Je vais vous demander à l'aide pour la partie prévision.
Le script "previsionMeteo.lua" est en place sur "/home/pi/domoticz/scripts/dzVents/scripts"
Le fichier "prevision-meteo.json" est bien sur "/home/pi/domoticz/www/monitor/"
Je n'ai aucun icone météo qui s'affiche dans ce qui ressemble à un tableau avec les jours de la semaine en ordonné.

Avez vous une idée de ce qui peut poser problème ?
Merci
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Hello, je reviens sur mon précédent message afin d'optenir de l'aide mais avec un peu plus de précision
Capture d’écran 2021-03-22 081153.jpg
Capture d’écran 2021-03-22 081153.jpg (59.06 Kio) Consulté 9992 fois
Mon "tableau" de prévision est désespérément vide, avez-vous une solution ?
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Moulins58
Messages : 134
Inscription : 17 févr. 2019, 20:41

Re: Monitor Affichage page METEO -

Message par Moulins58 »

Pour moi, c'est pareil. La semaine dernière en interrogeant le site directement depuis le navigateur, on avait comme réponse "Le site est en maintenance" et aujourd'hui le message est :"502 Bad Gateway" ( mauvaise passerelle) .
Apparemment le site a un problème.
Autre chose, sur ta page météo, je vois que tu as un beau soleil, je n'ai pas réussi à mettre cette icone vignette. Comment as tu fais?
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Moi le souci c'est que je n'ai jamais eu le moindre affichage d'icone... Et pourtant le fichier "prevision-meteo.json" se met correctement à jour. :x

Pour les icones, ils sont normalement dans
- Pour le jour : /monitor/icons/meteo/day
- Pour la nuit : /monitor/icons/meteo/night
- Pour les phases de lune : /monitor/icons/meteo/moon
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Est ce que ca refonctionne pour vous ?
Parce que pour moi c'est toujours en rade....
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Moulins58
Messages : 134
Inscription : 17 févr. 2019, 20:41

Re: Monitor Affichage page METEO -

Message par Moulins58 »

Oui, ça fonctionne de nouveau.
Par contre, je n'ai toujours pas compris comment remplir la ligne de la cellule 25 pour avoir l'icone au dessus du lever et coucher du soleil.
Bonne journée.
Pièces jointes
Screenshot_20210401-082457.png
Screenshot_20210401-082457.png (2.4 Mio) Consulté 9503 fois
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Chez moi ca ne fonctionne pas, je dois donc avoir un problème de config..... Mais je ne vois pas où !!!
Je vais avoir besoin d'aide, peux tu m'indiquer la marche à suivre ?

Pour ton Icone "meteo25"
Dans le frontpage.setting.js
//météo
['Température Extérieure','ForecastStr', 'meteo25', '','4'], // Icone météo
['','SunBoth','desc_meteo25', '','','','color:#F2DDB3;font-size:19px;font-weight:bold'], // heures levé / couché soleil

Si tu as la même chose c'est que c'est la légende "soleil" que tu as mis qui bloque l'affichage de l'icône
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

J'ai repris tout le tuto à zéro "viewtopic.php?f=25&t=331", j'ai repéré quelques coquilles que j'ai corrigé.
Dans mon log j'ai une erreur qui apparait :

Code : Tout sélectionner

2021-04-03 09:06:07.084 Error: dzVents: Error: (3.0.2) Extraction prévisions météo v1.01: An error occurred when calling event handler previsionMeteo
2021-04-03 09:06:07.084 Error: dzVents: Error: (3.0.2) Extraction prévisions météo v1.01: ...e/pi/domoticz/scripts/dzVents/scripts/previsionMeteo.lua:135: attempt to index a nil value (global 'file')
et impossible de voir ce qui pêche.

Please help !!!
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Keros
Messages : 6638
Inscription : 23 juil. 2019, 20:57

Re: Monitor Affichage page METEO -

Message par Keros »

Pour t'aider, nous avons besoin de voir ce qui te pose problème et en particulier le fichier previsionMeteo.lua dans lequel la ligne 135 génère le problème. Mais ce problème peut provenir d'une erreur quelques lignes plus haut.
Mets-nous tout ton script.
Comment bien utiliser le forum : Poser une question, Mettre un script, un fichier, une image ou des logs
Mes petits guides : Débuter en programmation, Le débogage, Le choix de matériel, Les sauvegardes
Ma présentation - Mes Tutos
Gardaux
Messages : 109
Inscription : 05 oct. 2017, 13:42
Localisation : Bouches du Rhône

Re: Monitor Affichage page METEO -

Message par Gardaux »

Bonjour,
Voici mon code, sachant que les "x" remplace mon ip réelle ainsi que ma ville réelle
Les droits de ce fichier, qui est dans "/home/pi/domoticz/scripts/dzVents/scripts" sont en 0644 (rw-r--r--)

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://xxx.xxx.x.xxx:xxxx/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://xxx.xxx.x.xxx:xxxx/home/pi/domoticz/www/monitor/icons/prevision-meteo/' -- adresse local où sont stockés les icones

--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://xxx.xxx.x.xxx:xxxx/monitor/icons/prevision-meteo/' -- adresse local où sont stockés les icones
--local city          = 'MaVille'  -- nil si vous souhaitez utiliser les coordonnées de latitude/longitude 

--------------------------------------------
----------- 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  = 'x.xxxxxxxx'
                logWrite('latitude : '..latitude)
                --local longitude = domoticz.settings.location.longitude
                local longitude = 'x.xxxxxxxx'
                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
}
Merci pour l'aide
Dernière modification par Keros le 04 avr. 2021, 10:39, modifié 1 fois.
Raison : Masquage des coordonnées GPS
---------------------------------------------------------------------------------------------------
Domoticz + Raspberry Pi3 x2 + RFXCOM (IFTTT)
Domoticz + Synology + RFLink
Répondre