Re: Meteoconcept
Publié : 11 janv. 2023, 19:36
Les limitations sont sur les commandes shell. Logique en soit.
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Code : Tout sélectionner
return
{
on =
{
timer = {
'every 1 minutes' -- just an example to trigger the request
},
httpResponses = {
'trigger' -- must match with the callback passed to the openURL command
}
},
logging =
{
level = domoticz.LOG_INFO,
marker = 'template',
},
execute = function(domoticz, item)
if item.isTimer then
domoticz.openURL(
{
url = 'https://api.meteo-concept.com/api/forecast/daily/0?token=XXX&insee=XXX',
method = 'GET',
callback = 'trigger', -- see httpResponses above.
})
elseif item.ok then -- statusCode == 2xx
local rt = domoticz.utils.fromXML(item.data)
domoticz.utils.dumpTable(rt)
local dsl = rt.rsp.dsl._attr
-- get one value
domoticz.log('line-status: ' .. dsl.line_status,domoticz.LOG_DEBUG)
-- get all values
for key, value in pairs(dsl) do
domoticz.log(key .. ': '.. value,domoticz.LOG_DEBUG)
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
}
Code : Tout sélectionner
2023-01-19 18:57:00.226 Error: dzVents: Error: (3.1.8) template: Error parsing xml to LUA table: (invalid xml string) {"city":{"insee":"83126","cp":83500,"name":"La Seyne-sur-Mer","latitude":43.088,"longitude":5.8709,"altitude":45},"update":"2023-01-19T11:07:09+01:00","forecast":{"insee":"83126","cp":83500,"latitude":43.088,"longitude":5.8709,"day":0,"datetime":"2023-01-19T01:00:00+0100","wind10m":40,"gust10m":102,"dirwind10m":314,"rr10":0,"rr1":0,"probarain":10,"weather":1,"tmin":4,"tmax":8,"sun_hours":6,"etp":2,"probafrost":10,"probafog":0,"probawind70":70,"probawind100":10,"gustx":102}}
2023-01-19 18:57:00.226 Error: dzVents: Error: (3.1.8) template: An error occurred when calling event handler essais meteo
2023-01-19 18:57:00.226 Error: dzVents: Error: (3.1.8) template: ...oticz\scripts\dzVents\generated_scripts/essais meteo.lua:31: attempt to index a nil value (local 'rt')Code : Tout sélectionner
<response>
<city>
<insee>83126</insee>
<cp>83500</cp>
<name>La Seyne-sur-Mer</name>
<latitude>43.088</latitude>
<longitude>5.8709</longitude>
<altitude>45</altitude>
</city>
<update>2023-01-19T11:07:09+01:00</update>
<forecast>
<insee>83126</insee>
<cp>83500</cp>
<latitude>43.088</latitude>
<longitude>5.8709</longitude>
<day>0</day>
<datetime>2023-01-19T01:00:00+0100</datetime>
<wind10m>40</wind10m>
<gust10m>102</gust10m>
<dirwind10m>314</dirwind10m>
<rr10>0</rr10>
<rr1>0</rr1>
<probarain>10</probarain>
<weather>1</weather>
<tmin>4</tmin>
<tmax>8</tmax>
<sun_hours>6</sun_hours>
<etp>2</etp>
<probafrost>10</probafrost>
<probafog>0</probafog>
<probawind70>70</probawind70>
<probawind100>10</probawind100>
<gustx>102</gustx>
</forecast>
</response>Code : Tout sélectionner
return {
on = {
timer = {
'every 1 minutes' -- just an example to trigger the request
},
httpResponses = {
'trigger' -- must match with the callback passed to the openURL command
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'template',
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://api.meteo-concept.com/api/forecast/daily/0?token=xxx&insee=83126',
method = 'GET',
callback = 'trigger', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.ok) then
if (item.isJSON) then
local tempmini = item.json.forecast.tmin -- temp mini de la journée
-- update some device in Domoticz
domoticz.devices('tempmini').updateText(tempmini)
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
Code : Tout sélectionner
return {
on = {
timer = {
'every 1 minutes' -- just an example to trigger the request
},
httpResponses = {
'trigger' -- must match with the callback passed to the openURL command
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'template',
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://api.meteo-concept.com/api/forecast/daily/1?token=xxx&insee=83126',
method = 'GET',
callback = 'trigger', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.ok) then
if (item.isJSON) then
--Température
local tempmini = item.json.forecast.tmin
local tempmaxi = item.json.forecast.tmax
--Temps sensible
local temps = item.json.forecast.weather
--Vent
local vitvent = item.json.forecast.wind10m --km/h
local vitventms = (vitvent * 1000)/3600 --m/s
local vitrafale = item.json.forecast.gust10m --km/h
local vitrafalems = (vitrafale * 1000)/3600 --m/s
local dirvent = item.json.forecast.dirwind10m
--Cumul de pluie
local cumulmm = item.json.forecast.rr10
local cumulmaxi = item.json.forecast.rr1
local Probapluie = item.json.forecast.probarain
--Ensoleillement
local Hsoleil = item.json.forecast.sunHours
--Probabilité de gel entre 0 et 100%
local probagel = item.json.forecast.probafrost
--Probabilité de gel entre 0 et 100%
local probabrouill = item.json.forecast.probafog
--Probabilité de vent
local probaventsup70 = item.json.forecast.probawind70
local probaventsup100 = item.json.forecast.probawind100
--Rafale de vent potentielle sous orage ou grain en km/h
local probaventsouspluie = item.json.forecast.gustx
-- update some device in Domoticz
domoticz.devices('Prévision temp mini pour demain').updateTemperature(tempmini)
domoticz.devices('Prévision vent pour demain').updateWind(dirvent,'',vitventms,vitrafalems)
domoticz.devices('Prévision cumul pluie pour demain').updateRain(cumulmm,cumulmaxi)
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}Code : Tout sélectionner
2023-01-22 10:59:54.310 Error: EventSystem: in C:\Program Files\Domoticz\scripts\dzVents\runtime\dzVents.lua: ...m Files\Domoticz\scripts\dzVents\runtime/persistence.lua:24: C:\Program Files\Domoticz\scripts\dzVents\/domoticzData.lua: Permission deniedCode : Tout sélectionner
2023-01-22 11:28:00.375 Error: dzVents: Error: template: An error occured when calling event handler Prevision meteo demain
2023-01-22 11:28:00.375 Error: dzVents: Error: template: ...oticz\scripts\dzVents\scripts/Prevision meteo demain.lua:16: attempt to index local 'item' (a nil value)