flacon030 Posté(e) le 25 octobre 2016 Signaler Posté(e) le 25 octobre 2016 Bonjour a tous J'ai mis en place une scène en LUA que j'ai récupérè sur le net pour le relevé du vent http://www.siio.com/energy-saving/integrating-the-netatmo-anemometer-into-the-fibaro-home-center-2-this-is-how-it-works-11973/ Mais de façon aléatoire elle se bloque et me met le code erreur suivant: [DEBUG] 07:19:33: [1;31m2016-10-25 07:19:33.662724 [ fatal] LUA error: /usr/share/lua/5.2/json/decode/util.lua:35: unexpected character @ character: 1 0:1 [<] line: voici le code de la scène il semble que le code LUA fibaro n'aime pas le symbole "@" mais malheureusement l'identifiant netatmo se fait avec le nom de user avec une adresse mail, donc avec un "@" Que faire? --[[ %% properties %% autostart %% globals --]] -- DIESE DATEN ANPASSEN local client_id = 'xxx' local client_secret = 'xxx' local username = 'xxx' local password = 'xxx' local refresh = 360 local vd_ID = 318 -- AB HIER NICHTS MEHR ANPASSEN local token = '' local request_body = '' fibaro:debug('netatmo-Windsensor Integration v.1.0 gestartet.') local sourceTrigger = fibaro:getSourceTrigger(); function oAuth(nextFunction) local request_body = 'grant_type=password&client_id=' .. client_id .. '&client_secret=' .. client_secret .. '&username=' .. username .. '&password=' .. password .. '&scope=read_station' getResponseData('https://api.netatmo.net/oauth2/token', request_body, function(data) token = data.access_token fibaro:debug('Netatmo Authentification OK...') getDevices() end ) setTimeout(oAuth, refresh*1000); end function getResponseData(url, body, func) local http = net.HTTPClient() http:request(url, { options = { method = 'POST', headers = { ['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' }, data = body }, success = function(response) func(json.decode(response.data)) end }) end function getDevices() getResponseData('https://api.netatmo.net/api/devicelist','access_token='..token, function(data) fibaro:debug('Recherche Windsensor...') for _, v in pairs(data.body.modules) do if (v.data_type[1] == 'Rain') then rain_id = v._id --fibaro:debug('Regensensor ' .. rain_id .. ' erkannt') --rain_bat = calcBat(v.battery_vp, true) elseif (v.data_type[1] == 'Temperature') then extern_id = v._id --fibaro:debug('Aussensensor ' .. extern_id .. ' erkannt') elseif (v.data_type[1] == 'Wind') then wind_id = v._id fibaro:debug('Windsensor N°' .. wind_id .. ' trouvé...') getmeasureWind() end int_id = data.body.devices[1]._id end end ) end function getmeasureWind() request_body_wind = 'access_token='..token..'&device_id='..int_id..'&module_id='..wind_id..'&scale=max&type=WindStrength,WindAngle,GustStrength,GustAngle&date_end=last' getResponseData('https://api.netatmo.net/api/getmeasure', request_body_wind, function(getData) fibaro:debug('Lecture des variables...') WindStrength = getData.body[1].value[1][1] WindAngle = getData.body[1].value[1][2] GustStrength = getData.body[1].value[1][3] GustAngle= getData.body[1].value[1][4] fibaro:debug('Vitesse du vent: ' .. WindStrength .. ' km/h') fibaro:setGlobal('windstaerke', WindStrength) fibaro:debug('Direction du vent: ' .. WindAngle .. ' °') fibaro:setGlobal('windrichtung', WindAngle) fibaro:debug('Rafales de vent: ' .. GustStrength .. ' km/h') fibaro:setGlobal('boenstaerke', GustStrength) fibaro:debug('Direction rafales de vent: ' .. GustAngle .. ' °') fibaro:setGlobal('boenrichtung', GustAngle) fibaro:call(vd_ID, "pressButton", "5"); fibaro:debug('Lecture des variables terminée. Attendre 5 minutes.') end ) end if (sourceTrigger["type"] == "autostart") then oAuth(); end Bien évidement les identifiants et mots de passe son bon dans mon code
flacon030 Posté(e) le 27 octobre 2016 Auteur Signaler Posté(e) le 27 octobre 2016 au vu de ce problème y a t'il un moyen de relancer la scène toutes les heures ou 24h? Merci
Messages recommandés