Worx Landroid - VD - w jaki sposób się autentykowac żeby uzyskać wynik json

  • 1 Odpowiedzi
  • 3694 Wyświetleń

0 użytkowników i 2 Gości przegląda ten wątek.

Witajcie,

W sumie zaczynam i mam taki oto problem.

Posiadam automatyczną kosiarkę Worx Landroid. Można z niej wyciągnąć ciekawe informacje poprzez proste zapytanie: http://192.168.1.220/jsondata.cgi - wpisując w przeglądarkę urządzenie pyta o użytkownika i PIN
kosiarki jako hasło. Domyślnie "admin" i hasło = PIN (np. 1234).

Wynik zaptania powyżej przez przeglądarkę to:

{"versione_fw":2.61,"lingua":0,"ore_funz":[50,50,50,50,50,50,50],"ora_on":[10,10,10,10,10,10,10],"min_on":[30,30,30,30,30,30,30],"allarmi":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"settaggi":[0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"mac":[0,35,167,166,34,223],"time_format":0,"date_format":0,"rit_pioggia":180,"area":0,"enab_bordo":1,"percent_programmatore":0,"indice_area":9,"tempo_frenatura":20,"perc_rallenta_max":70,"canale":0,"num_ricariche_batt":442,"num_aree_lavoro":1,"dist_area":[0,0,0,0],"perc_per_area":[0,0,0,0],"area_in_lavoro":1,"email":"xxx@xxx.com","perc_batt":"100","ver_proto":1,"state":"home","workReq":"landroid req manual homing","message":"none","batteryChargerState":"idle","distance":-4}

Powinno to działać jako admin:1234@192.168.1.220/jsondata.cgi ale nie mam pojęcia jak to zrobić w VD.

Zacząłem pisać takie oto VD próbując zczytać na początek poziom FW urządzenia - kod umieszczony w pętli głównej:

-- local variables
local selfId = fibaro:getSelfId();

-- Landroid variables
local apihost = "192.168.1.220";
local port = 80;
local user = admin;
local PIN = 1234;

-- Read data from Landroid
diag = Net.FHttp(apihost, port);
response = diag:GET("/jsondata.cgi");
result = json.decode(response);

-- Show the data
fibaro:call(selfId, "setProperty", "ui.Label1.value", result.versione_fw);
fibaro:debug(result.versione_fw);

-- wait for 10 minute
fibaro:sleep(10*60*1000);

Nie bardzo mam pomysł jak tu wbić autentykację...
Debug oczywiście pokazuje:

[ERROR] 17:36:13: line 12: Expected value but found invalid token at character 1

Pomocy, bo utknąłem.

Z góry wiekie dzięki! :-)
Nie ma tematu - pogrzebałem i znalazłem - przykład poniżej - może się komuś przyda:

local selfId = fibaro:getSelfId()
local LandroidIP = fibaro:get(selfId, "IPAddress")
local user = "admin"
local pass = "1234"
 
Landorid = Net.FHttp(LandroidIP);
Landorid:setBasicAuthentication(user, pass);
response  = Landorid:GET("/jsondata.cgi");
result = json.decode(response);

fibaro:call(selfId, "setProperty", "ui.Label1.value", result.versione_fw);
fibaro:debug(result.versione_fw);

fibaro:call(selfId, "setProperty", "ui.Label2.value", result.state);
fibaro:debug(result.state);

fibaro:call(selfId, "setProperty", "ui.Label3.value", result.message);
fibaro:debug(result.message);

fibaro:call(selfId, "setProperty", "ui.Label4.value", result.perc_batt);
fibaro:debug(result.perc_batt);

fibaro:call(selfId, "setProperty", "ui.Label5.value", result.batteryChargerState);
fibaro:debug(result.batteryChargerState);

fibaro:call(selfId, "setProperty", "ui.Label6.value", result.num_ricariche_batt);
fibaro:debug(result.num_ricariche_batt);

-- wait for 10 minutes
fibaro:sleep(10*60*1000);