Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Zczytywanie danych z strony www przez VD


Samael774

Question

Witam.

 

Już w kilku miejscach prosiłem o pomoc, niestety nie otrzymałem odpowiedzi.

 

Proszę o pomoc jak zaczytać informację ze strony inwertera po wewnętrznym IP. Chodzi mi o wartość aktualnej produkcji prądu. Zależy mi aby utworzyć takie VD do użytku w późniejszym sterowaniu przez inne urządzenia. Próbowałem się kierować poniższym kodem, modyfikując go pod siebie ale nic z tego nie wyszło.

 

Please login or register to see this code.

 

Proszę o pomoc.

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Mało informacji ??? jaki inverter ???

 

Poszukaj ja opisałem jak zrobić VD do odczytu danych s invertera SMA inne też były opisane. 

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • STECA 5kW. Po podpieciu do rutera przewodem mam dostep do informacji po wewnetrznym IP. Pytanie jak wskazac Fibaro VD konkretny fragment informacji ze strony z wewnetrznego IP.

     

    :(

    Edited by Samael774
    Link to comment
    Share on other sites

    • 0

    1. Tak na doby początek przeczytajmy pozycje od 99 do 102 stringu z 192.168.5.22/home.cgi

     

    local diag = Net.FHttp("192.168.5.22"); -- wpisz swój adres IP
    local response = diag:GET("/home.cgi");
    local pacW = string.sub(response, 99, 102); -- znajdzie znaki od pozycji 99 do 102 w stringu z home.cgi
    fibaro:debug("pac(W) = "..pacW.."[W]")
      

    -oczywiście będzie poprawne gdy mamy aktualną produkcję czteroznakową xxxx[W] ;) 

     

    2. potem pobawmy się w wyszukanie spacji oddzielającej Pac(W) i będziemy mieć E-Total(KWh)

    3. pewnie trzeba też uwzględnić fakt, że konwerter pracuje tylko jak jest jasno- potem jest nieosiągalny w sieci

    4. vd, zmienne globalne, powiadomienia push, mail i co tam kto chce...

     

    -może ktoś chętny?

    Link to comment
    Share on other sites

    • 0

    2. Poniżej pierwsza wersja kodu dla Fibaro VD, odczytująca dane falownika z ZeverSolar (w moim przypadku 4000) po sieci lokalnej: adresIP/home.cgi. Zapewne można napisać lepiej, ale działa ;) i spełnia moje oczekiwania. Pozdrawiam

     

     

    --[[
    ZeverSolar VD BBv1 08-010-2020 by Mieszko64
    1. Zadeklaruj w panelu zmiennych fibaro: pacW, etodayKWh -z dowolnymi wartościami
    2. Utworz VirtDev i zadeklaruj jeden przyciek "Update" i trzy etykiety: 
        -przycisk pomiaru na żądanie  "Update"
        -Aktualizacja (label1)
        -pacW -(label2)
        -E-todayKWh -(label3)
    3. skoryguj adres IP na swój
    4. umieść/skopiuj kody w sekcji 1 button i w pętli głównej.
    5. dla pętli głównej dodaj:  fibaro:sleep(60*1000) -odpytywanie co minutę
    6. rób co chcesz ;)
    --]]

    -- wpisz własny adres IP:
    local diag = Net.FHttp("192.168.1.95"); --  adres IP Zeversolar
    -- 

    local znak1 = string.char(10); -- znak rozdzielajacz po wartości pacW w stringu cgi
    local znak2 = string.char(46); -- znak rozdzielajacz po wartości E-todayKWh w stringu cgi
    local vdID = tonumber(fibaro:getSelfId());  -- ID  virtual devices
    local response, status, errorCode = diag:GET("/home.cgi");

    --warunek uwzględniający wyłączenie się Zeversolar nocą
    if tonumber(errorCode) == 0 and tonumber(status) == 200 and response ~= nil and response ~= "" then 
      local odczyt = os.date("%d-%m-%Y  %H:%M:%S" );
      fibaro:call(vdID, "setProperty", "ui.Label1.value", odczyt); -- zapisze date i czas na etykiecie "Odczyt"
      fibaro:debug("Odczyt: "..odczyt);
      local pacW1 = string.sub(response, 99, 99);
      local pacW2 = string.sub(response, 100, 100);
      local pacW3 = string.sub(response, 101, 101);
      local pacW4 = string.sub(response, 102, 102);
      local pacW5 = string.sub(response, 103, 103);
      
        if pacW2 == znak1 then
              pacW = pacW1;  
              fibaro:call(vdID, "setProperty", "ui.Label2.value", tostring(pacW).." W");
              fibaro:setGlobal("pacW", pacW);
            fibaro:debug("1_pac(W) = "..pacW.." W");
               
            local etoday1 = string.sub(response, 101, 101);
             local etoday2 = string.sub(response, 102, 102);
              local etoday3 = string.sub(response, 103, 103);
             local etoday4 = string.sub(response, 104, 104);
              
              if etoday2 == znak2 then
                etoday = etoday1  + etoday3 / 10;
                  fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              elseif etoday3 == znak2 then
                etoday = etoday1 * 10 + etoday2 + etoday4 / 10;
                  fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                  fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              end
          
        elseif pacW3 == znak1 then
              pacW = pacW1 *10 + pacW2;
            fibaro:call(vdID, "setProperty", "ui.Label2.value", tostring(pacW).." W");
              fibaro:setGlobal("pacW", pacW);
            fibaro:debug("2_pac(W) = "..pacW.." W");
        
            local etoday1 = string.sub(response, 102, 102);
               local etoday2 = string.sub(response, 103, 103);    
               local etoday3 = string.sub(response, 104, 104);
             local etoday4 = string.sub(response, 105, 105);
                 
              if etoday2 == znak2 then
                etoday = etoday1 + etoday3 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              elseif etoday3 == znak2 then
                etoday = etoday1 * 10 + etoday2 + etoday4 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                  fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              end
         
        elseif pacW4 == znak1 then
              pacW = pacW1*100 + pacW2*10 + pacW3;
               fibaro:call(vdID, "setProperty", "ui.Label2.value", tostring(pacW).." W");
              fibaro:setGlobal("pacW", pacW);
            fibaro:debug("3_pac(W) = "..pacW.." W");
       
              local etoday1 = string.sub(response, 103, 103);
              local etoday2 = string.sub(response, 104, 104);
            local etoday3 = string.sub(response, 105, 105);
             local etoday4 = string.sub(response, 106, 106);
                 
              if etoday2 == znak2 then
                etoday = etoday1 + etoday3 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              elseif etoday3 == znak2 then
                etoday = etoday1 * 10 + etoday2 +etoday4 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                  fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              end
          
        elseif pacW5 == znak1 then      
              pacW = pacW1*1000 + pacW2*100 + pacW3*10 + pacW4;
              fibaro:debug("4_pac(W) = "..pacW.." W");
               fibaro:call(vdID, "setProperty", "ui.Label2.value", tostring(pacW).." W");
              fibaro:setGlobal("pacW", pacW);
            
              local etoday1 = string.sub(response, 104, 104);
              local etoday2 = string.sub(response, 105, 105);
            local etoday3 = string.sub(response, 106, 106);
             local etoday4 = string.sub(response, 107, 107);
                 
            if etoday2 == znak2 then
                etoday = etoday1 + etoday3 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                fibaro:setGlobal("etodayKWh", etoday);
                  fibaro:debug("E-today= "..etoday.." KWh");
              elseif etoday3 == znak2 then
                etoday = etoday1 * 10 + etoday2 +etoday4 / 10;
                fibaro:call(vdID, "setProperty", "ui.Label3.value", tostring(etoday).." KWh");
                  fibaro:setGlobal("etodayKWh", etoday);
                 fibaro:debug("E-today= "..etoday.." KWh");
              end
        
        else
              fibaro:debug("cos nie tak");
          end
    fibaro:sleep(60*1000);  -- 60 sekund w pętli głównej
    else
        fibaro:debug("Brak połączenia");    
    end

    Edited by Mieszko64
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...