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

Need help with LUA script


Deivydas

Question

Hello,

I'm writing an Quick App for controlling device using UDP protocol. It's seems to be working, but I have some additional questions.

 

1. I'm using @tinman QA lib for aes128. When I decrypt response from device I received json formated string with additionals spaces at the end:

{"t":"dev","cid":"111111","bc":"000000000000000000000000000000","brand":"gree","catalog":"gree","mac":"111111","mid":"10001","model":"gree","name":"12312312312","series":"gree","vender":"1","ver":"V1.2.1","lock":0}

OR

{"t":"bindok","mac":"111111","key":"12312312312","r":200}

 

And here is the problem, that if the spaces are at the end, I cannot do json.decode to get exactly value, any solution?

 

2. Can't understand why result return in function return nil value. When I debug it it have value, but how to return this value for other function? 

 

Thanks

 

Please login or register to see this code.

 

Edited by Deivydas
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
1 hour ago, Deivydas said:

And here is the problem, that if the spaces are at the end, I cannot do json.decode to get exactly value, any solution?

You can trim the string with: 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Ok, the problem was that I cannot use json.decode because that I was using AES library wrong way.

     

    I made changes from code below:

    Please login or register to see this code.

     
     
    To this code:

    Please login or register to see this code.

     

    After that - json.decode(response) is working

    Edited by Deivydas
    Post updated
    Link to comment
    Share on other sites

    • 0

    Thank you for replying the correct code so people can learn from it.

    And good to hear your integration works now.

    • Thanks 1
    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...