Aller au contenu

Kana-chan

Membres confirmés
  • Compteur de contenus

    322
  • Inscription

  • Dernière visite

  • Jours gagnés

    6

Tout ce qui a été posté par Kana-chan

  1. Bonjour jojo, Impossible de vous envoyer un message, mais je me suis dit que cela serait pas trop grave de mettre le code ici. Je rappelle que je n'ai pas la paternité du VD, il fut d'abord créé par fdp2. Voici le code pour les différents boutons du VD NAS Synology : Redémarrer : -------------------------------------------------- -- Synology DSM -- Reboot the disk station -- janvier 2015 -------------------------------------------------- -- User configurable variables local login = "aa"; local password = "bb"; -- System variables local selfID = fibaro:getSelfId(); local ip = fibaro:get(selfID, 'IPAddress'); local port = fibaro:get(selfID, 'TCPPort'); local Synology = Net.FHttp(ip, tonumber(port)); local API_AUTH_ERROR_CODE = { [0] = "Sans erreur.", [100] = "Erreur inconnue.", [101] = "Compte non spécifié.", [400] = "Mot de passe invalide.", [401] = "Compte désactivé.", [402] = "Permission refusée.", [403] = "Unique mot de passe non spécifié.", [404] = "Autentification erronée." }; local API_RECORD_ERROR_CODE = { [400] = "Exécution ratée.", }; -- Discover available APIs and corresponding information payload = "/webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.API.Auth"; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); local version = jsonTable.data["SYNO.API.Auth"].maxVersion; if version >= 2 then fibaro:debug("Version API Synology OK"); pathAuth = jsonTable.data["SYNO.API.Auth"].path; fibaro:debug("Chemin API Synology = "..pathAuth); cgiUsed="/entry.cgi"; apiUsed="SYNO.Core.System"; if version < 6 then cgiUsed="/dsm/system.cgi"; apiUsed="SYNO.DSM.System"; end -- Create new login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=2&account="..login.."&passwd="..password.."&session=DSM&format=sid"; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then SID = jsonTable.data.sid; fibaro:debug("SID API Synology = ["..SID.."]"); -- Reboot the disk station payload = "/webapi"..cgiUsed.."?api="..apiUsed.."&version=1&method=reboot&_sid="..SID; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then fibaro:debug("Response ["..response.."]"); jsonTable = json.decode(response); if jsonTable.success == true then fibaro:log("Redémarrage OK"); fibaro:debug('<span style="color:green;">Redémarrage Disk Station Synology OK</span>'); else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Disk Station Synology n\'a pas redémarré</span>'); end -- else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(errorCode)]..'</span>'); --fibaro:debug('<span style="color:red;">Erreur : '..errorCode..'</span>'); end -- Destroy current login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Logout&version=2&session=DSM&_sid="..SID; response, status, errorCode = Synology:GET(payload); fibaro:debug(status); else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(jsonTable.error.code)]..'</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Authentification API ratée</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Version API Synology trop vieille : <b>DSM 4.0-2251</b> est requise</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Impossible de se connecter au Disk Station Synology</span>'); end Arrêter : -------------------------------------------------- -- Synology DSM -- Shutdown the disk station -- janvier 2015 -------------------------------------------------- -- User configurable variables local login = "aa"; local password = "bb"; -- System variables local selfID = fibaro:getSelfId(); local ip = fibaro:get(selfID, 'IPAddress'); local port = fibaro:get(selfID, 'TCPPort'); local Synology = Net.FHttp(ip, tonumber(port)); local API_AUTH_ERROR_CODE = { [100] = "Erreur inconnue.", [101] = "Compte non spécifié.", [400] = "Mot de passe invalide.", [401] = "Compte désactivé.", [402] = "Permission refusée.", [403] = "Unique mot de passe non spécifié.", [404] = "Autentification erronée." }; local API_RECORD_ERROR_CODE = { [400] = "Exécution ratée.", }; -- Discover available APIs and corresponding information payload = "/webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.API.Auth"; response, status, errorCode = Synology:GET(payload); --fibaro:debug("response [" .. response .. "] status [" .. status .."] error [" .. errorCode .. "]") if tonumber(status) == 200 then jsonTable = json.decode(response); local version = jsonTable.data["SYNO.API.Auth"].maxVersion; if version >= 2 then fibaro:debug("Version API Synology OK"); pathAuth = jsonTable.data["SYNO.API.Auth"].path; fibaro:debug("Chemin API Synology = "..pathAuth); cgiUsed="/entry.cgi"; apiUsed="SYNO.Core.System"; if version < 6 then cgiUsed="/dsm/system.cgi"; apiUsed="SYNO.DSM.System"; end -- Create new login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=2&account="..login.."&passwd="..password.."&session=DSM&format=sid"; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then SID = jsonTable.data.sid; fibaro:debug("SID API Synology = "..SID); -- ShutDown the disk station payload = "/webapi"..cgiUsed.."?api="..apiUsed.."&version=1&method=shutdown&_sid="..SID; response, status, errorCode = Synology:GET(payload); fibaro:debug("response [" .. response .. "] status [" .. status .."] error [" .. errorCode .. "]") jsonTable = json.decode(response); if jsonTable.success == true then fibaro:log("Arrêt OK"); fibaro:debug('<span style="color:green;">Arrêt du Disk Station Synology OK</span>'); else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Le Disk Station ne s\'est pas arrêté</span>'); end -- -- Destroy current login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Logout&version=2&session=DSM&_sid="..SID; response, status, errorCode = Synology:GET(payload); fibaro:debug(status); else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(jsonTable.error.code)]..'</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Authentification API ratée</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Version API Synology trop vieille : <b>DSM 4.0-2251</b> est requise</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Impossible de se connecter au Disk Station Synology</span>'); end État : -------------------------------------------------- -- Synology DSM -- Reboot the disk station -- janvier 2015 -------------------------------------------------- -- User configurable variables local login = "aa"; local password = "bb"; -- System variables local selfID = fibaro:getSelfId(); local ip = fibaro:get(selfID, 'IPAddress'); local port = fibaro:get(selfID, 'TCPPort'); local nameNAS = fibaro:getName(selfID); local Synology = Net.FHttp(ip, tonumber(port)); local API_AUTH_ERROR_CODE = { [0] = "Sans erreur.", [100] = "Erreur inconnue.", [101] = "Compte non spécifié.", [400] = "Mot de passe invalide.", [401] = "Compte désactivé.", [402] = "Permission refusée.", [403] = "Unique mot de passe non spécifié.", [404] = "Autentification erronée." }; local API_RECORD_ERROR_CODE = { [400] = "Exécution ratée.", }; local OK_connected = false; -- Test connection tcpSocket = Net.FTcpSocket(ip, tonumber(port)); bytes, errorCode = tcpSocket:write("Test"); fibaro:log("Détection"); if errorCode == 0 then OK_connected = true; fibaro:log(nameNAS.." ON"); fibaro:call(selfID, "setProperty", "currentIcon", "52"); --fibaro:call(175, "sendDefinedPushNotification", "Ping ReseauHome OK"); else fibaro:log(nameNAS.." OFF"); fibaro:call(selfID, "setProperty", "currentIcon", "53"); --fibaro:call(175, "sendDefinedPushNotification", "Ping ReseauHome OFF"); end tcpSocket:disconnect(); -- Round function to display percentages round = function(num) local a = math.floor(num*100 + 0.5)/ 100; return a,string.format("%.2f",a); end if OK_connected then -- Discover available APIs and corresponding information payload = "/webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.API.Auth"; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); version = jsonTable.data["SYNO.API.Auth"].maxVersion; if version >= 2 then fibaro:debug("Version API Synology OK"); pathAuth = jsonTable.data["SYNO.API.Auth"].path; fibaro:debug("Chemin API Synology = "..pathAuth); cgiUsed_cpu_mem = "/entry.cgi"; cgiUsed_temp = cgiUsed_cpu_mem; cgiUsed_vols = cgiUsed_cpu_mem; apiUsed_cpu_mem = "SYNO.Core.System.Utilization"; apiUsed_temp_system = "SYNO.Core.System"; apiUsed_temp_disk = apiUsed_temp_system; apiUsed_vols = apiUsed_temp_system; apiMethod_cpu_mem="get"; apiMethod_temp = "info"; apiMethod_vols = apiMethod_temp; if version < 6 then cgiUsed_cpu_mem = "/dsm/system_loading.cgi"; cgiUsed_temp = "/dsm/info.cgi"; cgiUsed_vols = "/dsm/volume.cgi"; apiUsed_cpu_mem = "SYNO.DSM.SystemLoading"; apiUsed_temp_system = "SYNO.DSM.Info"; apiUsed_temp_disk = ""; apiUsed_vols = "SYNO.DSM.Volume"; apiMethod_cpu_mem = "getinfo"; apiMethod_temp = apiMethod_cpu_mem; apiMethod_vols = "list"; end -- Create new login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=2&account="..login.."&passwd="..password.."&session=DSM&format=sid"; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then SID = jsonTable.data.sid; fibaro:debug("SID API Synology = ["..SID.."]"); -- Prepare string local info_cpu_memory = ""; -- CPU info from the disk station payload = "/webapi"..cgiUsed_cpu_mem.."?api="..apiUsed_cpu_mem.."&version=1&method="..apiMethod_cpu_mem.."&type=current&_sid="..SID; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then info_cpu = jsonTable.data.cpu; load_mem = jsonTable.data.memory.real_usage; fibaro:debug("Memory: "..load_mem.."%"); info_cpu_memory = "Memory: "..load_mem.."% "; load_cpu = 0; if (version < 6) then load_cpu = info_cpu.user*100; else load_cpu = info_cpu.other_load+info_cpu.system_load+info_cpu.user_load; end fibaro:debug("CPU: "..load_cpu.."%"); info_cpu_memory = info_cpu_memory.."CPU: "..load_cpu.."%"; fibaro:call(selfID, "setProperty", "ui.CPULoad.value", info_cpu_memory); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(errorCode)]..'</span>'); end -- Temp info from the disk station payload = "/webapi"..cgiUsed_temp.."?api="..apiUsed_temp_system.."&version=1&method="..apiMethod_temp.."&_sid="..SID; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then if jsonTable.data.sys_temp ~= nil then temp_system = "System: "..jsonTable.data.sys_temp.."°C"; else temp_system = "System: N/A"; end fibaro:debug("Temperature "..temp_system); fibaro:call(selfID, "setProperty", "ui.SYSTEMTemp.value", temp_system); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(errorCode)]..'</span>'); end -- Prepare string local temp_disks = ""; -- Temp info from the disk station payload = "/webapi"..cgiUsed_temp.."?api="..apiUsed_temp_disk.."&version=1&method="..apiMethod_temp.."&type=storage&_sid="..SID; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then local disk_tab = jsonTable.data.hdd_info; for nb = 1, #disk_tab do temp_disks = temp_disks..disk_tab[nb].diskno..": "..disk_tab[nb].temp.."°C "; end fibaro:debug("Disks temperature: "..temp_disks); fibaro:call(selfID, "setProperty", "ui.DISKSTemp.value", temp_disks); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(errorCode)]..'</span>'); end -- Prepare string local vols_load = ""; -- Temp info from the disk station payload = "/webapi"..cgiUsed_vols.."?api="..apiUsed_vols.."&version=1&method="..apiMethod_vols.."&type=storage&_sid="..SID; response, status, errorCode = Synology:GET(payload); if tonumber(status) == 200 then jsonTable = json.decode(response); if jsonTable.success == true then local vols_tab = jsonTable.data.vol_info; for nb = #vols_tab, 1, -1 do used_size_vol = vols_tab[nb].used_size; total_size_vol = vols_tab[nb].total_size; occupied_size = round(used_size_vol / total_size_vol * 100); vols_load = vols_load..vols_tab[nb].name..": "..occupied_size.."% "; end fibaro:debug("Volumes Load: "..vols_load); fibaro:call(selfID, "setProperty", "ui.VOLSLoad.value", vols_load); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(errorCode)]..'</span>'); end -- Destroy current login session payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Logout&version=2&session=DSM&_sid="..SID; response, status, errorCode = Synology:GET(payload); fibaro:debug("Déconnexion: "..status); else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : '..API_AUTH_ERROR_CODE[tonumber(jsonTable.error.code)]..'</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Authentification API ratée</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Version API Synology trop vieille : <b>DSM 4.0-2251</b> est requise</span>'); end else fibaro:log("Erreur"); fibaro:debug('<span style="color:red;">Erreur : Impossible de se connecter au Disk Station Synology</span>'); end else fibaro:call(selfID, "setProperty", "ui.CPULoad.value", "Memory: N/A % CPU: N/A %"); fibaro:call(selfID, "setProperty", "ui.SYSTEMTemp.value", "System: N/A °C"); fibaro:call(selfID, "setProperty", "ui.DISKSTemp.value", "Disk: N/A °C"); end Réveiller : -- convert MAC adress, every 2 Chars (7-bit ASCII), to one Byte Char (8-bits) function convertMacAddress(address) local s = string.gsub(address, ":", ""); local x = ""; -- will contain converted MAC for i=1, 12, 2 do x = x .. string.char(tonumber(string.sub(s, i, i+1), 16)); end return x; end fibaro:log("Réveiller"); -- MAC adress local _macAddress = convertMacAddress("AA:BB:CC:DD:EE:FF"); -- Create Magic Packet 6 x FF local _magicPacket = string.char(0xff, 0xff, 0xff, 0xff, 0xff, 0xff); -- Broadcast Address local _broadcastAddress = "192.168.X.255"; -- Default port used local _wakeOnLanPort = 9; fibaro:sleep(750); for i = 1, 16 do _magicPacket = _magicPacket .. _macAddress; end fibaro:log("Magic packet créé"); fibaro:sleep(1000); socket = Net.FUdpSocket(); socket:setBroadcast(true); local bytes, errorCode = socket:write(_magicPacket, _broadcastAddress, _wakeOnLanPort); --check for error if errorCode == 0 then fibaro:log("Envoyé"); else fibaro:log("Envoi raté"); end -- clean up memory socket = nil; fibaro:log("Attendre le réveil."); Et le lien vers la page qui m'a servie à faire cela : api documentation for homebridge-synology (v0.2.2) Voilà ...
  2. En fait j'ai rajouté une zone de texte donc il n'y a pas que le code qui a changé. Mais j'y penserai pour la prochaine fois !
  3. Bonjour, Une dernière version qui comprend le pourcentage d'occupation des volumes dans le NAS. Voilà ... NAS_Synology.vfib
  4. Bonjour, Voici une version qui affiche en plus la charge CPU en %, la mémoire occupée en %, la température du système et la température de chaque disques quand on appuie sur le bouton "Etat" ou quand il se met à jour tout seul. Voilà ... NAS_Synology.vfib
  5. Bonjour, J'ai mis à jour le VD de fdp2 ici : Dans le code, il y a la méthode pour se connecter indifféremment en DSM 5.x et 6.x (pas pu tester en 5.x mais je pense que c'est bon). Voilà ... P.S. : Un bon site que j'ai trouvé pour les json des API Synology en DSM 5 et 6 ici : Exploiter API Synology. Cela peut t'aider et c'est pasplus compliquer qu'avant, regarde comment j'ai fait.
  6. Bonjour, Voici la mise à jour de ce VD pour rebooter et arrêter les NAS Synology. Voilà ... Synology_NAS.vfib
  7. Pouvez-vous essayer celui-ci ? Livebox_4_Fibre_Mob-flamalex.vfib
  8. Salut flamalex. Pouvez-vous essayez ce VD? Merci.
  9. OK, je vais voir alors !! C'est spécial votre réseau !! Je vais avoir besoin d'aide dans ce cas.
  10. Salut, Voici le nouveau VD pour flamalex. Il faudra que vous me dites si dans le DEBUG du bouton vous voyez bien apparaître vos adresses MAC de vos mobiles. Il faut que l'adresse soit en MAJUSCULE bien sûr. Sinon, pour limiter à seulement le CPL, non je ne pense pas, car le DHCP doit être celui de votre box tout de même. Voilà ...
  11. Bonjour flamalex, c'est normal car j'ai limité aux interfaces Wifi 2.4G et 5G la recherche de mobile. Je vais te le faire sans cette limitation.
  12. Salut, J'ai fait une truc, tu me diras. Dans le code suivant du bouton rafraîchir : Livebox.setPresence = (function(isDetected) local isOK_Mobile1_Name = false; local isOK_Mobile2_Name = false; for mac, isActive in pairs(isDetected) do if (string.find(mac, fibaro:getGlobalValue("Mobile1_Name"))) then isOK_Mobile1_Name = isActive; end if (string.find(mac, fibaro:getGlobalValue("Mobile2_Name"))) then isOK_Mobile2_Name = isActive; end end fibaro:setGlobal("PresencePersonne1", isOK_Mobile1_Name); fibaro:setGlobal("PresencePersonne2", isOK_Mobile2_Name); end) Il faudra créer une variable prédéfinie Mobile1_Name avec l'adresse MAC Wifi du mobile (ex : 00:00:00:00:00:00), donc une seule valeur (créer puis éditer à nouveau pour enlever la deuxième valeur ajoutée). Il faudra créer une variable PresencePersonne1 aussi. Idem avec Mobile2_Name et PresencePersonne2. La livebox 4 détecte si le mobile est connecté ou pas en temps presque réel. Après, je n'ai pas fait comme Monsieur Laser car je ne sais pas comment transformer la date de dernière connexion de chaîne de caractère à valeur entière de manière simple. Voilà.
  13. Bonjour flamalex, Je ne sais pas. Il faudrait voir si on peux avoir la liste des équipements comme dans l'interface. Sinon, ce n'est pas mon VD, mais une adaptation du VD de Ofwood. Voilà !!
  14. Bonjour MAM78, Tu fais la réponse à ta question tout seul ... En fait oui, j'ai dû supprimer car indisponible pour le lien FIBRE. Mais le code est resté je crois dans le VD. Sinon, peut-être faire le test depuis un des nombreux sites Internet qui existe ? Je ne sais pas, faire un truc comme fait la grenouille par exemple ... Je vais y réfléchir à moins que cela ne soit déjà fait ailleurs !! Voilà ...
  15. Bonjour Puni et flamalex, J'ai intégré un bouton "Redémarrer" dans cette version du VD (en pièce jointe). Elle fonctionne pour Livebox 4 ADSL et FIBRE avec le nouveau firmware 2.19.2. Voilà ... Livebox_4_Fibre.zip
  16. Bonjour, Il faut autoriser le sous-réseau où se trouve la hc2 d'aller voir sur le sous-réseau où se trouve la livebox. Comment faites-vous les mises-à-jour de la hc2 si elle n'accède pas à la livebox pour aller sur Internet ? Sinon, ça doit fonctionner en y mettant bien l'adresse IP de la livebox au bon endroit du VD. Voilà ...
  17. Kana-chan

    Jour Chômé

    Bonjour, Personnellement j'ai rien dans le main loop car c'est GEA qui fait l'appel : -------------JOUR CHOME-------------- GEA.add({"Global", "", ""}, 30, "", { {"VirtualDevice", id["JOUR_CHOME"], 3}, {"Time", "00:00", "00:01"} }) Donc, si cela ne fonctionne pas, c'est peut-être GEA qui a un souci ? Avez-vous essayé en redémarrant la HC2 ? Voilà ...
  18. Kana-chan

    Jour Chômé

    Bonjour, Le "283" correspond au numéro du VD. Avez-vous regardé si le VD a toujours ce numéro ? C'est dans l'url du VD une fois dans ces paramètres. Voilà ...
  19. Bonjour, Vraiment, il n'y a personne pour m'aider ? Merci !! EDIT: Plus la peine, c'est bon, j'ai trouvé. VD_Livebox_4_F‫ibre.zip
  20. Kana-chan

    Jour Chômé

    Bonjour domo, Ici, il fonctionne et ce met à jour comme demandé dans GEA. Par contre, peut-être que vous pourriez donner la version de GEA utilisée et le morceau de code qui couvre le VD Jour Chomé pour voir ? Voilà...
  21. Bonjour, Personne pour m'aider ?
  22. Bonjour, Bon, j'ai réparé mon VD Livebox pour la Livebox 4 avec le firmware 2.19.2. Donc, je peux allumé et éteindre le Wifi et je peux rafraîchir pour avoir le SSID et si la connexion est OK. Par contre, je voudrais savoir comment mettre le contenu d'une variable lorsque c'est encadré par "[[" et "]]", en gros, USER et PASSWORD ici : params = [[ {"service":"sah.Device.Information","method":"createContext","parameters":{"applicationName":"so_sdkut","username":USER,"password":PASSWORD}} ]]; Car là, il ne fait pas le remplacement. Savez-vous comment le faire ? Merci d'avance !
  23. Bonsoir, En remplaçant USER par "admin" et PASSWORD par mon mot de passe admin, ca fonctionne très bien. Par contre, j'aurais aimé que ce soit mieux configurable ... comment mettre une variable entre les "[[" et "]]" ? Pour le getWANStatus, il faut faire comme cela : local uri = "/ws" local params = [[ {"service":"NMC","method":"getWANStatus","parameters":{}} ]]; Je n'ai fait que le bouton rafraîchir qui indique si la connexion est up, l'adresse IP et si le Wifi est actif ou pas. Merci ...
  24. Bonjour et merci pour le lien. Malheureusement je ne vois pas comment modifier le login du VD existant pour que cela fonctionne : Livebox.login = (function() -- create new client object local httpClient = Toolkit.Net.HttpRequest(Livebox.ip, Livebox.port); -- set timeout httpClient:setReadTimeout(Livebox.commandTimeOut); -- Password en clair, ben voyons Orange... local uri = string.format("/authenticate?username=%s&password=%s", USER, PASSWORD) local response, status, errorCode, cookie = httpClient:request("POST",uri, {"User-Agent: FibaroHC2/1.0", "Content-Type: application/json"}, "" ); -- disconnect socket and release memory... httpClient:disconnect(); httpClient:dispose(); -- check for error if errorCode == 0 then --if Livebox.debug then Tk:trace("Response: "..response) end -- if no error and if status is ok... if tonumber(status) == 200 then -- decode json with builtin fibaro method. local jsonTable = json.decode(response); -- store contextID and Cookie in Livebox object Livebox._ContextID = jsonTable.data.contextID; Livebox._Cookie = cookie; return true; else showError("status: "..status); end else showError("Communication Error ("..errorCode..")"); end return false ; end); J'ai essayé avec cela : Livebox.login = (function() -- create new client object local httpClient = Toolkit.Net.HttpRequest(Livebox.ip, Livebox.port); -- set timeout httpClient:setReadTimeout(Livebox.commandTimeOut); -- set PARAMS params = [[ {"service":"sah.Device.Information","method":"createContext","parameters":{"applicationName":"so_sdkut","username":USER,"password":PASSWORD}} ]]; -- Password en clair, ben voyons Orange... local uri = "/ws" local response, status, errorCode, cookie = httpClient:request("POST",uri, {"User-Agent: FibaroHC2/1.0", "Content-Type: application/x-sah-ws-4-call+json", "Authorization: X-Sah-Login"}, params ); -- disconnect socket and release memory... httpClient:disconnect(); httpClient:dispose(); -- check for error if errorCode == 0 then if Livebox.debug then Tk:trace("url: %s", uri) Tk:traceEx("grey", response or "empty" ) --Tk:traceEx("purple", "Cookie: %s", cookie ) end -- if no error and if status is ok... if tonumber(status) == 200 then -- decode json with builtin fibaro method. local jsonTable = json.decode(response); -- store contextID and Cookie in Livebox object Livebox._ContextID = jsonTable.data.contextID; Livebox._Cookie = cookie; return true; else showError("status: "..status); end else showError("Communication Error ("..errorCode..")"); end return false ; end); Mais j'ai une erreur de connexion 1. Je ne suis pas à l'aise avec ces choses. Si quelqu'un pouvait me dire comment faire, j'en serai heureux !! Merci pour votre aide !!
  25. Bonjour Silfried, Je ne sais pas si c'est le protocole qui a changé, mais lorsqu'on utilise http://192.168.1.1/authenticate il demande bien les informations d'utilisateur et mot de passe (sur le service sah-webdav). Par contre, ce ne sont pas les habituelles admin/mdpadmin. Voilà.
×
×
  • Créer...