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

Web page authentication using LUA


krzysztof.kowalczyk
 Share

Question

Hi,

I'm trying to access from Virtual Device web page which requires authentication. Unfortunately "setBasicAuthentication" does not work here.

Can you please advise how to authenticate the access.

Server IP: '138.91.51.153'

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi

 

Here is an example snippet from auth against a web cam...

 

function cameraAuth()
      tcpAXIS = Net.FHttp(IP, 80);
      if (not tcpAXIS) then
        if DEBUG >= 1 then fibaro:debug('ERROR setting up camera server!') end  
        if SYSLOG == 1 then syslogserver('ERROR setting up camera server!') end.   
      end
     tcpAXIS:setBasicAuthentication(USERID, PASSWORD); -- authentication for AXIS camera 
     if (not tcpAXIS) then
       if DEBUG >= 1 then fibaro:debug('ERROR setting up camera server auth!') end
       If SYSLOG == 1 then syslogserver('ERROR setting up camera server auth!') end
     end
end
 
function cameraVirtualPort(inputPort, value) -- enables or disables a virtual port on CAM
 
    cameraAuth()
 
   If tostring(value) == "activate" or tostring(value) == "deactivate" then
     local response ,status, err = tcpAXIS:GET("/axis-cgi/virtualinput/" .. value .. ".cgi?schemaversion=1&port=" .. tostring(inputPort));
     fibaro:call(LOCALDEVICEID, "setProperty", "ui.INPUTCODE.value", "NULL") -- Null is directly after executin to avoid problems
    If DEBUG >= 1 then fibaro:debug('As expected - code wiped out from memory after execution! ' ) end
    if SYSLOG == 1 then syslogserver('As expected - code wiped out from memory after execution! ') end

 

 

I call the cameraAuth() function to set up auth before getting data over http. If you do not succeed it could be so that the web does not support basic unencrypted password authentication. 

 

 

 

/Peo

  • Like 1
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Unfortunately it looks that basic authentication doe not work on the server. 

     

    Some more details on the project I'm trying to do:

     

    I'm owning Gree airconditioner which contains wifi control device. The Air Condition is controlled formally only by Android or iOS application and there is no other way described in the documentation. However Wifi controller is connecting with Gree Cloud service (http://eu.grih.gree.com) which is contolling my AC directly. 

    I'd like to have the possibility of controlling  the AC unit from Virtual Device but stucked with authentication :-(.

     

    Is anyone can help here?

    Link to comment
    Share on other sites

    • 0

    You could try to read the web page and fill the login form fields. That is easy in LUA, python etc. There you have libraries to import as help. But I have not looked into it with LUA in HC2. The HC2 lua implementation is limited. You probably have to do it all yourself as you cannot import any  libraries. And you are limitied with you code base size in HC2... So I cannot tell you it will work. Just a path to look into ant try.

     

    /Peo

    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.

     Share

    ×
    ×
    • Create New...