voici un script pour visual crossing, si cela peut t'aider. je ne l'utilise plus car il y a le plugin
Code : Tout sélectionner
-- Authors ----------------------------------------------------------------
-- gestion des angle/degré
-- http://www.toujourspret.com/techniques/orientation/topographie/rose_des_vents.php#:~:text=On%20divise%20le%20cercle%20en%20deux%20pour%20obtenir,180%C2%B0%20et%20l%27Ouest%20%C3%A0%20%28180%C2%B0%20%2B%2090%C2%B0%29%20270%C2%B0.
-- v1.0 meteo open wheater crossing
local scriptName = 'METEO OPEN WHEATER CROSSING'
local scriptVersion = '1.0'
local api = "XXXXXXXXXXXXXXXXXXXXXXXX" -- Entrer ici votre clé API
local latitude = 50.413428 -- Latitude. (Decimal number)
local longitude = 2.058115 -- Longitude. (Decimal number)
local server ='https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/'
local d_internet = "Internet" -- Nom du dispositif Interrupteur Internet, nil si non utilisé
local f_dry_run = 'N' -- (Y) pour tester le script de protection solaire sans activer réellement le store
local f_notification = "N" -- (Y) Active les f_notifications, (N) les désactive
local message = '.'
return {
active = false,
on = {
timer = { 'every 10 minutes' },
customEvents = { 't_wvc_meteo' },
httpResponses = { 'urloc' }
},
data = {
flag = { initial = 0, maxItems = 1 }
},
logging = {
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
-- level = domoticz.LOG_ERROR,
-- level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = scriptName..' v'..scriptVersion
},
execute = function(dz, item, trigger)
local latitude = dz.settings.location.latitude
local longitude = dz.settings.location.longitude
local url =
-- PROGRAM STARTS
dz.log('============== METEO PREVISIONNEL LOG ==================', dz.LOG_INFO)
if d_internet and dz.devices(d_internet).state == 'Off' then return end
dz.log('Home latitude = ' .. tostring(latitude), dz.LOG_DEBUG)
dz.log('Home longitude = ' .. tostring(longitude), dz.LOG_DEBUG)
if item.isTimer or item.isCustomEvent then
url = server..latitude..","..longitude.."/"..dz.time.rawDate.."?unitGroup=metric&key="..api.."&include=current"
dz.openURL(
{url = url, method = 'GET', callback = 'urloc'}
)
dz.log('Déclenchement', dz.LOG_DEBUG)
elseif item.isHTTPResponse then
if item.ok and item.isJSON then
local days = {}
days = item.json.days[1]
local liste = {}
liste = item.json.currentConditions
local nuage = liste.cloudcover
dz.log('nuage = '..nuage, dz.LOG_DEBUG)
dz.devices('wvc_nuage').update(0,nuage)
local temps = liste.conditions
dz.log('temps = '..temps, dz.LOG_DEBUG)
dz.devices('wvc_temps').updateText(temps)
local temp = liste.temp
dz.log('temp = '..temp, dz.LOG_DEBUG)
local humidity = liste.humidity
dz.log('humidity = '..humidity, dz.LOG_DEBUG)
local pression = liste.pressure
dz.log('pression = '..pression, dz.LOG_DEBUG)
local ressentie = liste.feelslike
dz.log('ressentie = '..ressentie, dz.LOG_DEBUG)
dz.devices('wvc_ressentie').updateTemperature(ressentie)
local dew = liste.dew
dz.log('point rosée = '..dew, dz.LOG_DEBUG)
local vitesse = liste.windspeed
dz.log('vitesse = '..vitesse, dz.LOG_DEBUG)
local uvi = liste.uvindex
dz.log('uvi = '..uvi, dz.LOG_DEBUG)
dz.devices('wvc_UVI').updateUV(uvi)
local visibilite = liste.visibility
dz.log('visibilite = '..visibilite, dz.LOG_DEBUG)
dz.devices('wvc_visibilite').updateVisibility(visibilite)
local pluie = liste.precip
dz.log('pluie = '..pluie, dz.LOG_DEBUG)
dz.devices('wvc_pluie').updateRain(100, pluie)
local alerte_pluie = liste.precipprob
dz.log('proba_pluie = '..alerte_pluie, dz.LOG_DEBUG)
if alerte_pluie < 100 then
dz.devices('wvc_alerte_pluie').switchOn()
else
dz.devices('wvc_alerte_pluie').switchOff()
end
local degre = liste.winddir
dz.log('vent = '..degre, dz.LOG_DEBUG)
-- status HUM_NORMAL, HUM_COMFORTABLE, HUM_DRY, HUM_WET, HUM_COMPUTE
-- forecast BARO_NOINFO, BARO_SUNNY, BARO_PARTLY_CLOUDY, BARO_CLOUDY, BARO_RAIN
if temps == 'Overcast' then
temps_status = 'HUM_WET'
else
temps_status = 'HUM_NORMAL'
end
dz.devices('wvc_THB').updateTempHumBaro(temp, humidity, temps_status, pression, 'BARO_NOINFO')
local gust = liste.windgust
dz.log('rafale = '..gust, dz.LOG_DEBUG)
if tonumber(degre) == 0 then
direction = "N"
elseif tonumber(degre) < 22.5 then
direction = "NNE"
elseif tonumber(degre) < 45 then
direction = "NE"
elseif tonumber(degre) < 67.5 then
direction = "ENE"
elseif tonumber(degre) < 90 then
direction = "E"
elseif tonumber(degre) < 112.5 then
direction = "ESE"
elseif tonumber(degre) < 135 then
direction = "SE"
elseif tonumber(degre) < 157.5 then
direction = "SSE"
elseif tonumber(degre) < 180 then
direction = "S"
elseif tonumber(degre) < 202.5 then
direction = "SSO"
elseif tonumber(degre) < 225 then
direction = "SO"
elseif tonumber(degre) < 247.5 then
direction = "OSO"
elseif tonumber(degre) < 270 then
direction = "O"
elseif tonumber(degre) < 292.5 then
direction = "ONO"
elseif tonumber(degre) < 315 then
direction = "NO"
elseif tonumber(degre) < 337.5 then
direction = "NNO"
end
dz.log('direction = '..direction, dz.LOG_DEBUG)
dz.devices('wvc_vent').updateWind(degre, direction, vitesse, gust, temp, ressentie)
if f_notification == "Y" then
message='*'..message
dz.helpers.generalNotify(dz, 'BUSINESS', scriptName, message, 'sms')
end
else
message = 'Données meteo non disponible'
dz.log(message, dz.LOG_INFO)
if f_notification == "Y" then
dz.helpers.generalNotify(dz, 'EXPLOIT', scriptName, message, 'telegram')
end
end
end
end -- execute
} -- return