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


Recommended Posts

Posted

Hi all!

I would like to use

Please login or register to see this link.

which requires HMAC-SHA256 hashing.
 

Please login or register to see this code.

Since Fibaro LUA doesn't allow the use of libraries, this function needs programming. Unfortunately I don't understand that mechanism so I'm not able to code this. I've tried ChatGPT to help me, but that didn't work out.
Ie here any LUA guru who could help me with this function? Any help is very much appreciated.

  • Like 1
Posted

There are some lua examples on GitHub, are they of any use?

 

Please login or register to see this link.

 

  • Thanks 1
  • Topic Author
  • Posted
    44 minutes ago, SmartHomeEddy said:

    There are some lua examples on GitHub, are they of any use?

     

    Please login or register to see this link.

     

    Thnx Eddy 🙏 I will investigate :-)

    Posted

    Don’t know if it works on the Fibaro version of Lua. 

    Posted
    On 2/15/2024 at 7:55 PM, SmartHomeEddy said:

    Don’t know if it works on the Fibaro version of Lua. 

     

    amen 

     

    • Like 1
    Posted

    HI using Tinmans libs i make this

    Please login or register to see this code.

    Unfortunately, I get a 401 error. The same data that I generate thanks to the libraries from Tinman work in Powershell.

    Please login or register to see this code.

     

    Posted (edited)
    16 hours ago, marczu_83 said:

    Unfortunately, I get a 401 error. The same data that I generate thanks to the libraries from Tinman work in Powershell.

    Please login or register to see this code.

     

     

    can you compare message and hmac from both?

     

    how the token and secretkey looks like?

     

    Edited by tinman
    Posted
    21 minut temu, tinman napisał:

     

    can you compare message and hmac from both?

     

    how the token and secretkey looks like?

     

    to test, I generated hmac, time and pasted this data together with secretkey and token into the query in Powershell and it worked, i.e. the data itself is created correctly, it seems to me that the http query from fibaro is somehow incorrect

     

    Please login or register to see this code.

     

    I changed one character so as not to paste the real on ;)

    More info about SwitchBot API

     

    Please login or register to see this link.

    Posted
    6 minutes ago, marczu_83 said:

    it seems to me that the http query from fibaro is somehow incorrect

     

    did you tried already checkCertificate = false ?

    Posted
    2 minuty temu, tinman napisał:

     

    did you tried already checkCertificate = false ?

    Yes i;ve alreade tried this.

    When i paste same time stamp, token, secret in lua and powershell and then made hmac i get the same result.

    So olny difference is web request.

    If you want to test something i can send you dm with token and secret

     

    Posted
    1 hour ago, marczu_83 said:

    If you want to test something i can send you dm with token and secret

     

    sure, i can take a look today evening

    • Like 1
    Posted (edited)
    6 hours ago, marczu_83 said:

    When i paste same time stamp

     

    it was actually timestamp

     

    Please login or register to see this code.

     

    gives me 200, so it works properly.

     

    Please login or register to see this attachment.

    Edited by tinman
    • Thanks 2
    • 8 months later...
    Posted

    would you be so kind to tell us how you installed the HMAC256 library in fibaro HC3 ? i am currently working on a project for a neato vacuum that uses a simular thing

    Posted

    my way of doing it: download QA from this post

     

     

    upload QA to your HC3, copy everything from sha2 tab (if you dont see it click on file icon - circle)

    Please login or register to see this attachment.

     

    open your QA click on file icon then click plus sign

    on the new file paste everything and save QA

    now you can use it like this

    Please login or register to see this code.

    Posted
    On 11/5/2024 at 2:37 PM, marczu_83 said:

    my way of doing it: download QA from this post

     

     

    upload QA to your HC3, copy everything from sha2 tab (if you dont see it click on file icon - circle)

    Please login or register to see this attachment.

     

    open your QA click on file icon then click plus sign

    on the new file paste everything and save QA

    now you can use it like this

    Please login or register to see this code.

    SO if i am correct i need all that data copied for example in a scene or quickapp i am designing ?

    Posted

    no, but I copy and paste everything to make it easier.

    you can only copy the functions you will use.

    Posted
    6 hours ago, marczu_83 said:

    no, but I copy and paste everything to make it easier.

    you can only copy the functions you will use.

    could you help me with the code and a button ? i am kind of stuck for the moment 😛

    Posted

    trying todo the same i am geting some errors in the quickapp script

     

     

    [07.11.2024] [19:53:43] [TRACE] [QUICKAPP53]: UIEvent: {"eventType":"onReleased","elementName":"button_ID_2_1","deviceId":53,"values":[]}[07.11.2024] [19:53:43] [DEBUG] [QUICKAPP53]: ./include/Neato_Robot_Info.lua:6: attempt to concatenate a nil value (global 'requestbody')[07.11.2024] [19:53:43] [ERROR] [QUICKAPP53]: QuickApp crashed[07.11.2024] [19:53:43] [ERROR] [QUICKAPP53]: Unknown error occurred: handleJsonRpc

     

     

    code used:

    function QuickApp:getrobotinfo()
        local robotserial = "XXXXXXXXX"
        local robotseriallow = string.lower(robotserial)
        local robotsecret = "XXXXXXXX"
        local date = tostring(os.date("!%a, %d %b %Y %X GMT"))
        local string_to_sign = robotseriallow .. "\n".. date .. "\n" .. requestbody
        local requestbody = '{"reqId": "77", "cmd": "getRobotState"}'
        local signature = sha.hmac(sha.sha256, robotsecret, string_to_sign)
        local binary_hash = sha.hex2bin(hmac)
        local base64_hash = sha.bin2base64(binary_hash)
        self.http = net.HTTPClient({timeout=5000})
       
     
        self.http:request("https://nucleo.neatocloud.com:4443/vendors/neato/robots/OPS02217-985DADC5A1BA/messages", {
              options = {
                  data = json.encode(requestbody),
                  method = "POST",
                  checkCertificate = false,
                  headers = {
                    ["Accept"] = "application/vnd.neato.nucleo.v1",
                    ["Content-Type"] = "application/json",
                    ["Date"] = os.date("!%a, %d %b %Y %X GMT"),
                    ["Authorization"] = "NEATOAPP" + " " + signature,
                  }
              },
              success = function(response)
                  self:debug(response.status)
                  self:debug(response.data)
              end,
              error = function(message)
                  self:debug("error:", message)
              end
          })
    end

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...