[DzVents] DarkSky et probabilité de pluie
Re: DZVents : DarkSky et probabilité de pluie
maintenant que le script script_time_vigilance_meteofrance_V2.lua n'est plus dans le répertoire /home/pi/domoticz/scripts/dzVents/scripts/
ça fonctionne correctement?
ça fonctionne correctement?
Re: DZVents : DarkSky et probabilité de pluie
Oui! pour celui ci c'est tout bon!
Merci beaucoup!
Merci beaucoup!
Re: DZVents : DarkSky et probabilité de pluie
Bonjour,
Il est possible d'avoir la valeur en mm, comme sur cette page ? https://darksky.net/details/48.1109,-1. ... 11/si12/fr
A ce jour 0.12mm si je regarde sur le lien de l'api je retrouve bien 0.12 avec la même ligne soit precipProbability il y a donc surement qu'un petit truc à changer dans le script.
Merci
Il est possible d'avoir la valeur en mm, comme sur cette page ? https://darksky.net/details/48.1109,-1. ... 11/si12/fr
A ce jour 0.12mm si je regarde sur le lien de l'api je retrouve bien 0.12 avec la même ligne soit precipProbability il y a donc surement qu'un petit truc à changer dans le script.
Merci
Re: DZVents : DarkSky et probabilité de pluie
Salut le Rennaistitis14 a écrit : 11 févr. 2019, 20:39 Bonjour,
Il est possible d'avoir la valeur en mm, comme sur cette page ? https://darksky.net/details/48.1109,-1. ... 11/si12/fr
A ce jour 0.12mm si je regarde sur le lien de l'api je retrouve bien 0.12 avec la même ligne soit precipProbability il y a donc surement qu'un petit truc à changer dans le script.
Merci
Version: 2023.1 sur VM Synology, docker Zwave Js UI (Z-stick GEN5, Fibaro...), Zigbeefordomoticz. Nextion RGB Led Screen
Re: DZVents : DarkSky et probabilité de pluie
Bonjour J'ai mis en place le script suivant:
Mes devices ne se mettent pas a jour
Et dans les logs j'ai:
2019-03-06 16:58:35.010 Status: dzVents: Error (2.4.6): error loading module 'prevision pluie' from file '/home/pi/domoticz/scripts/dzVents/scripts/prevision pluie.lua':
2019-03-06 16:58:35.010 .../pi/domoticz/scripts/dzVents/scripts/prevision pluie.lua:128: '}' expected (to close '{' at line 52) near <eof>
Une piste ?
Code : Tout sélectionner
--[[ darksky.lua for [ domoticzVents >= 2.4 ]
author/auteur = papoo
update/mise à jour = 15/09/2018
creation = 15/09/2018
https://pon.fr/dzvents-darksky-et-probabilite-de-pluie/
This script requires prior registration to the DarkSky API
Ce script nécessite l'inscription préalable à l'API DarkSky
Enter the URL and request a free API key
Entrez l'URL et demandez une clé API gratuite
https://darksky.net/dev
]]--
local proba_pluie_h = {}
--[[
Add, modify or delete variables proba_pluie_h [] by changing the number (hour) between []
the name "in quotation marks" or the idx without quotes (avoid accents) of the device of percentage of rain at [x] associated time, nil if not used
This script can potentially retrieve the 48 available time forecasts. Create as many percent virtual sensors as you would expect from the hourly forecasts.
for my part, I only get the forecasts at 1 hour, 2 hours, 4 hours, 6 hours, 12 hours and 24 hours.
Only 48 possible forecasts
Ajoutez, modifiez ou supprimez les variables proba_pluie_h[] en changeant le nombre (heure) entre []
renseigner ensuite le nom "entre guillemets" ou l'idx sans guillemets (évitez les accents) du device pourcentage probabilité pluie à [x] heure associé, nil si non utilisé
Ce script peut potentiellement récupérer les 48 prévisions horaires disponible. Créez autant de capteurs virtuels pourcentage correspondant aux prévisions horaires que vous souhaitez.
pour ma part, je ne récupère que les prévisions à 1 heure, 2 heures, 4 heures, 6 heures, 12 heures et 24 heures.
Seulement 48 prévisions possible
My DarkSky secret key, the latitude and longitude of my home are contained in 3 user variables
Ma clé secrète DarkSky, la latitude et la longitude de mon domicile sont contenus dans 3 variables utilisateurs
local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value
local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value
If you want to enter this information directly into the script, comment on the two lines above, uncomment the following two lines
Si vous souhaitez inscrire ces informations dans le script, commentez les deux lignes ci-dessus, décommentez les deux lignes suivantes
--local DarkSkyAPIkey = "xxxxxx"
--local geolocalisation = "45.87,1.30" -- latitude,longitude
by personalizing them with your personal data
finally, you can choose the level of logs, only one level can be active; comment on others in the section
en les personnalisant avec vos données personnelles.
enfin vous pouvez choisir le niveau de "verbiage" des logs, seulement un niveau peut être actif; commenter les autres dans la section logging
]]--
proba_pluie_h[47]= "Proba Pluie 1h"
proba_pluie_h[2]= nil
proba_pluie_h[3]= nil
proba_pluie_h[48]= "Proba Pluie 4h"
proba_pluie_h[5]= nil
proba_pluie_h[6]= nil
proba_pluie_h[49]= "Proba Pluie 12h"
proba_pluie_h[50]= "Proba Pluie 24h"
proba_pluie_h[36]= nil
proba_pluie_h[48]= nil
return {
active = true,
on = { timer = { 'every 30 minutes' }, -- remember only 1000 requests by day, 30mn = 48 requests
httpResponses = { "trigger" } -- Trigger the handle Json part
},
logging = { -- 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_DEBUG,
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = "Darksky Rain Probability v1.0 " },
data = { rainForecast = {initial = {} }, -- Keep a copy of last json just in case
},
execute = function(domoticz, item)
local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value
local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value
local DarkSkyAPIkey = "41f2f3e8dddae7b83b495412c4f977e1"
local geolocalisation = "47.896976,0.034682" -- latitude,longitude
local Forecast_url = "https://api.darksky.net/forecast/" -- url
local extraData = "?units=ca&exclude=currently,minutely,daily,alerts,flags"
local function debugMessage(message)
domoticz.log(message,domoticz.LOG_DEBUG)
end
if (item.isTimer) then
domoticz.openURL({
url = Forecast_url..DarkSkyAPIkey.."/"..geolocalisation..extraData,
callback = 'trigger'
})
end
if (item.isHTTPResponse and item.ok) then
-- we know it is json but dzVents cannot detect this
-- convert to Lua
local json = domoticz.utils.fromJSON(item.data)
-- json is now a Lua table
if #item.data > 0 then
domoticz.data.rainForecast = domoticz.utils.fromJSON(item.data)
rt = domoticz.utils.fromJSON(item.data)
else
domoticz.log("Problem with response from DarkSky (no data) using data from earlier run",domoticz.LOG_ERROR)
rt = domoticz.data.rainForecast -- json empty. Get last valid from domoticz.data
if #rt < 1 then -- No valid data in domoticz.data either
domoticz.log("No previous data. are DarkSkyAPIkey and geolocalisation ok?",domoticz.LOG_ERROR)
return false
end
end
debugMessage("heure systeme")
debugMessage(os.date('%Y-%m-%d %H:%M:%S', time))
local now = tonumber(os.time(os.date("*t")))
j = 1
for i = 1,48 do
if now > tonumber(json.hourly.data[j].time) then
local h = domoticz.utils.round((now - tonumber(json.hourly.data[j].time)) / 3600,0)
j = j+h
debugMessage("j : "..j)
end
if proba_pluie_h[i] then
debugMessage("heure "..i)
debugMessage(os.date('%Y-%m-%d %H:%M:%S', json.hourly.data[j].time))
debugMessage(json.hourly.data[j].time)
debugMessage(json.hourly.data[j].precipProbability)
domoticz.devices(proba_pluie_h[i]).updatePercentage(json.hourly.data[j].precipProbability*100)
end
if j == 48 then break end
j = j +1
end
end
end Et dans les logs j'ai:
2019-03-06 16:58:35.010 Status: dzVents: Error (2.4.6): error loading module 'prevision pluie' from file '/home/pi/domoticz/scripts/dzVents/scripts/prevision pluie.lua':
2019-03-06 16:58:35.010 .../pi/domoticz/scripts/dzVents/scripts/prevision pluie.lua:128: '}' expected (to close '{' at line 52) near <eof>
Une piste ?
Re: DZVents : DarkSky et probabilité de pluie
Tu utilises ce script directement dans l’éditeur intégré ou sous forme de fichier dans le répertoire scripts/dzvents/scripts
Si c’est la deuxième solution quel éditeur de texte utilises tu ?
Le script est il bien au format UTF8 sans bom ?
Si c’est la deuxième solution quel éditeur de texte utilises tu ?
Le script est il bien au format UTF8 sans bom ?
Re: DZVents : DarkSky et probabilité de pluie
Le script est dans domoticz/scripts/dzvents/scripts
J'utilise nano
voila le script
J'utilise nano
voila le script
Code : Tout sélectionner
--[[ darksky.lua for [ domoticzVents >= 2.4 ]
author/auteur = papoo
update/mise à jour = 15/09/2018
creation = 15/09/2018
https://pon.fr/dzvents-darksky-et-probabilite-de-pluie/
This script requires prior registration to the DarkSky API
Ce script nécessite l'inscription préalable à l'API DarkSky
Enter the URL and request a free API key
Entrez l'URL et demandez une clé API gratuite
https://darksky.net/dev
]]--
local proba_pluie_h = {}
--[[
Add, modify or delete variables proba_pluie_h [] by changing the number (hour) between []
the name "in quotation marks" or the idx without quotes (avoid accents) of the device of percentage of rain at [x] associated time, nil if not used
This script can potentially retrieve the 48 available time forecasts. Create as many percent virtual sensors as you would expect from the hourly forecasts.
for my part, I only get the forecasts at 1 hour, 2 hours, 4 hours, 6 hours, 12 hours and 24 hours.
Only 48 possible forecasts
Ajoutez, modifiez ou supprimez les variables proba_pluie_h[] en changeant le nombre (heure) entre []
renseigner ensuite le nom "entre guillemets" ou l'idx sans guillemets (évitez les accents) du device pourcentage probabilité pluie à [x] heure associé, nil si non utilisé
Ce script peut potentiellement récupérer les 48 prévisions horaires disponible. Créez autant de capteurs virtuels pourcentage correspondant aux prévisions horaires que vous souhaitez.
pour ma part, je ne récupère que les prévisions à 1 heure, 2 heures, 4 heures, 6 heures, 12 heures et 24 heures.
Seulement 48 prévisions possible
My DarkSky secret key, the latitude and longitude of my home are contained in 3 user variables
Ma clé secrète DarkSky, la latitude et la longitude de mon domicile sont contenus dans 3 variables utilisateurs
local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value
local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value
If you want to enter this information directly into the script, comment on the two lines above, uncomment the following two lines
Si vous souhaitez inscrire ces informations dans le script, commentez les deux lignes ci-dessus, décommentez les deux lignes suivantes
--local DarkSkyAPIkey = "1a2bf34bf56c78901f2345f6d7890f12"
--local geolocalisation = "45.87,1.30" -- latitude,longitude
by personalizing them with your personal data
finally, you can choose the level of logs, only one level can be active; comment on others in the section
en les personnalisant avec vos données personnelles.
enfin vous pouvez choisir le niveau de "verbiage" des logs, seulement un niveau peut être actif; commenter les autres dans la section logging
]]--
proba_pluie_h[47]= "Proba Pluie 1h"
proba_pluie_h[2]= nil
proba_pluie_h[3]= nil
proba_pluie_h[48]= "Proba Pluie 4h"
proba_pluie_h[5]= nil
proba_pluie_h[6]= nil
proba_pluie_h[49]= "Proba Pluie 12h"
proba_pluie_h[50]= "Proba Pluie 24h"
proba_pluie_h[36]= nil
proba_pluie_h[48]= nil
return {
active = true,
on = { timer = { 'every 30 minutes' }, -- remember only 1000 requests by day, 30mn = 48 requests
httpResponses = { "trigger" } -- Trigger the handle Json part
},
logging = { -- 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_DEBUG,
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = "Darksky Rain Probability v1.0 " },
data = { rainForecast = {initial = {} }, -- Keep a copy of last json just in case
},
execute = function(domoticz, item)
local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value
local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value
local DarkSkyAPIkey = "xxxxxxx"
local geolocalisation = "47.896976,0.034682" -- latitude,longitude
local Forecast_url = "https://api.darksky.net/forecast/" -- url
local extraData = "?units=ca&exclude=currently,minutely,daily,alerts,flags"
local function debugMessage(message)
domoticz.log(message,domoticz.LOG_DEBUG)
end
if (item.isTimer) then
domoticz.openURL({
url = Forecast_url..DarkSkyAPIkey.."/"..geolocalisation..extraData,
callback = 'trigger'
})
end
if (item.isHTTPResponse and item.ok) then
-- we know it is json but dzVents cannot detect this
-- convert to Lua
local json = domoticz.utils.fromJSON(item.data)
-- json is now a Lua table
if #item.data > 0 then
domoticz.data.rainForecast = domoticz.utils.fromJSON(item.data)
rt = domoticz.utils.fromJSON(item.data)
else
domoticz.log("Problem with response from DarkSky (no data) using data from earlier run",domoticz.LOG_ERROR)
rt = domoticz.data.rainForecast -- json empty. Get last valid from domoticz.data
if #rt < 1 then -- No valid data in domoticz.data either
domoticz.log("No previous data. are DarkSkyAPIkey and geolocalisation ok?",domoticz.LOG_ERROR)
return false
end
end
debugMessage("heure systeme")
debugMessage(os.date('%Y-%m-%d %H:%M:%S', time))
local now = tonumber(os.time(os.date("*t")))
j = 1
for i = 1,48 do
if now > tonumber(json.hourly.data[j].time) then
local h = domoticz.utils.round((now - tonumber(json.hourly.data[j].time)) / 3600,0)
j = j+h
debugMessage("j : "..j)
end
if proba_pluie_h[i] then
debugMessage("heure "..i)
debugMessage(os.date('%Y-%m-%d %H:%M:%S', json.hourly.data[j].time))
debugMessage(json.hourly.data[j].time)
debugMessage(json.hourly.data[j].precipProbability)
domoticz.devices(proba_pluie_h[i]).updatePercentage(json.hourly.data[j].precipProbability*100)
end
if j == 48 then break end
j = j +1
end
end
end -
denis_brasseur
- Messages : 898
- Inscription : 24 déc. 2018, 17:05
- Localisation : (26)
Re: DZVents : DarkSky et probabilité de pluie
La réponse est dans le message d'erreur :vr6man a écrit : 06 mars 2019, 19:17 Le script est dans domoticz/scripts/dzvents/scripts
J'utilise nano
voila le script
Code : Tout sélectionner
--[[ darksky.lua for [ domoticzVents >= 2.4 ] author/auteur = papoo update/mise à jour = 15/09/2018 creation = 15/09/2018 https://pon.fr/dzvents-darksky-et-probabilite-de-pluie/ This script requires prior registration to the DarkSky API Ce script nécessite l'inscription préalable à l'API DarkSky Enter the URL and request a free API key Entrez l'URL et demandez une clé API gratuite https://darksky.net/dev ]]-- local proba_pluie_h = {} --[[ Add, modify or delete variables proba_pluie_h [] by changing the number (hour) between [] the name "in quotation marks" or the idx without quotes (avoid accents) of the device of percentage of rain at [x] associated time, nil if not used This script can potentially retrieve the 48 available time forecasts. Create as many percent virtual sensors as you would expect from the hourly forecasts. for my part, I only get the forecasts at 1 hour, 2 hours, 4 hours, 6 hours, 12 hours and 24 hours. Only 48 possible forecasts Ajoutez, modifiez ou supprimez les variables proba_pluie_h[] en changeant le nombre (heure) entre [] renseigner ensuite le nom "entre guillemets" ou l'idx sans guillemets (évitez les accents) du device pourcentage probabilité pluie à [x] heure associé, nil si non utilisé Ce script peut potentiellement récupérer les 48 prévisions horaires disponible. Créez autant de capteurs virtuels pourcentage correspondant aux prévisions horaires que vous souhaitez. pour ma part, je ne récupère que les prévisions à 1 heure, 2 heures, 4 heures, 6 heures, 12 heures et 24 heures. Seulement 48 prévisions possible My DarkSky secret key, the latitude and longitude of my home are contained in 3 user variables Ma clé secrète DarkSky, la latitude et la longitude de mon domicile sont contenus dans 3 variables utilisateurs local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value If you want to enter this information directly into the script, comment on the two lines above, uncomment the following two lines Si vous souhaitez inscrire ces informations dans le script, commentez les deux lignes ci-dessus, décommentez les deux lignes suivantes --local DarkSkyAPIkey = "1a2bf34bf56c78901f2345f6d7890f12" --local geolocalisation = "45.87,1.30" -- latitude,longitude by personalizing them with your personal data finally, you can choose the level of logs, only one level can be active; comment on others in the section en les personnalisant avec vos données personnelles. enfin vous pouvez choisir le niveau de "verbiage" des logs, seulement un niveau peut être actif; commenter les autres dans la section logging ]]-- proba_pluie_h[47]= "Proba Pluie 1h" proba_pluie_h[2]= nil proba_pluie_h[3]= nil proba_pluie_h[48]= "Proba Pluie 4h" proba_pluie_h[5]= nil proba_pluie_h[6]= nil proba_pluie_h[49]= "Proba Pluie 12h" proba_pluie_h[50]= "Proba Pluie 24h" proba_pluie_h[36]= nil proba_pluie_h[48]= nil return { active = true, on = { timer = { 'every 30 minutes' }, -- remember only 1000 requests by day, 30mn = 48 requests httpResponses = { "trigger" } -- Trigger the handle Json part }, logging = { -- 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_DEBUG, -- level = domoticz.LOG_MODULE_EXEC_INFO, marker = "Darksky Rain Probability v1.0 " }, data = { rainForecast = {initial = {} }, -- Keep a copy of last json just in case }, execute = function(domoticz, item) local DarkSkyAPIkey = domoticz.variables('api_forecast_io').value local geolocalisation = domoticz.variables('Latitude').value..","..domoticz.variables('Longitude').value local DarkSkyAPIkey = "xxxxxxx" local geolocalisation = "47.896976,0.034682" -- latitude,longitude local Forecast_url = "https://api.darksky.net/forecast/" -- url local extraData = "?units=ca&exclude=currently,minutely,daily,alerts,flags" local function debugMessage(message) domoticz.log(message,domoticz.LOG_DEBUG) end if (item.isTimer) then domoticz.openURL({ url = Forecast_url..DarkSkyAPIkey.."/"..geolocalisation..extraData, callback = 'trigger' }) end if (item.isHTTPResponse and item.ok) then -- we know it is json but dzVents cannot detect this -- convert to Lua local json = domoticz.utils.fromJSON(item.data) -- json is now a Lua table if #item.data > 0 then domoticz.data.rainForecast = domoticz.utils.fromJSON(item.data) rt = domoticz.utils.fromJSON(item.data) else domoticz.log("Problem with response from DarkSky (no data) using data from earlier run",domoticz.LOG_ERROR) rt = domoticz.data.rainForecast -- json empty. Get last valid from domoticz.data if #rt < 1 then -- No valid data in domoticz.data either domoticz.log("No previous data. are DarkSkyAPIkey and geolocalisation ok?",domoticz.LOG_ERROR) return false end end debugMessage("heure systeme") debugMessage(os.date('%Y-%m-%d %H:%M:%S', time)) local now = tonumber(os.time(os.date("*t"))) j = 1 for i = 1,48 do if now > tonumber(json.hourly.data[j].time) then local h = domoticz.utils.round((now - tonumber(json.hourly.data[j].time)) / 3600,0) j = j+h debugMessage("j : "..j) end if proba_pluie_h[i] then debugMessage("heure "..i) debugMessage(os.date('%Y-%m-%d %H:%M:%S', json.hourly.data[j].time)) debugMessage(json.hourly.data[j].time) debugMessage(json.hourly.data[j].precipProbability) domoticz.devices(proba_pluie_h[i]).updatePercentage(json.hourly.data[j].precipProbability*100) end if j == 48 then break end j = j +1 end end end }
Code : Tout sélectionner
2019-03-06 16:58:35.010 .../pi/domoticz/scripts/dzVents/scripts/prevision pluie.lua:128: '}' expected (to close '{' at line 52) near <eof> il manque l'accolade } en dernière ligne, après le dernier if.
Il s'agit de l'accolade qui à été ouverte en ligne 52.
Je l'ai ajouté dans le code ci dessus.
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Re: DZVents : DarkSky et probabilité de pluie
ok merci avec la modif plus de message d'erreur mais les devices ne se mettent pas a jour ?
-
denis_brasseur
- Messages : 898
- Inscription : 24 déc. 2018, 17:05
- Localisation : (26)
Re: DZVents : DarkSky et probabilité de pluie
Regarde bien le code d'origine, à l'origine il n'est bâti comme cela :vr6man a écrit : 06 mars 2019, 20:22 ok merci avec la modif plus de message d'erreur mais les devices ne se mettent pas a jour ?
Code : Tout sélectionner
proba_pluie_h[47]= "Proba Pluie 1h"
proba_pluie_h[2]= nil
proba_pluie_h[3]= nil
proba_pluie_h[48]= "Proba Pluie 4h"
proba_pluie_h[5]= nil
proba_pluie_h[6]= nil
proba_pluie_h[49]= "Proba Pluie 12h"
proba_pluie_h[50]= "Proba Pluie 24h"
proba_pluie_h[36]= nil
proba_pluie_h[48]= nil Code : Tout sélectionner
proba_pluie_h[1]= "Proba Pluie 1h"
proba_pluie_h[2]= nil
proba_pluie_h[3]= nil
proba_pluie_h[4]= "Proba Pluie 4h"
proba_pluie_h[5]= nil
proba_pluie_h[6]= nil
proba_pluie_h[12]= "Proba Pluie 12h"
proba_pluie_h[24]= "Proba Pluie 24h"
proba_pluie_h[36]= nil
proba_pluie_h[48]= nil Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090