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
Question
riemers 20
Latest version of Lualibs =
Please login or register to see this attachment.
Changelog for v1.0.1 (thank to @petergebruers)
- fix HC user authentication (was: user:password in URL, is now: basic authentication).
- fix chunked responses (was: use only chunk 1, is now: concatenate chunks). Fixes "getDevicesId".
- add error checking and display in the HTTP part, to get sensible error messages.
Most of the information came from the french forum which can be found
Please login or register to see this link.
all credits go to Steven!ZeroBrane is an IDE for development in Lua code. It offers you auto completion and partial support to use the actual fibaro: option in your code too. To get started grab the latest version from
Please login or register to see this link.
(1.5.0 as of writing) grab your favorite flavor. It supports Mac, Windows and Linux.To use the Lua Library you have to install it, grab the lua libs (top of page) for fibaro. You need to install these files in your c:\<yourlocation>\ZeroBraneStudio\lualibs (for Mac this would be /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs) after that a restart of the app is a good thing to do.
Use this always in your code when you start testing your setup. For example:
Please login or register to see this code.
Do keep in mind this is your userid/password on the box itself, do NOT use a fibaro ID since that is only the login to your remote.
To change the Colors to be the same as on Fibaro (if you feel really cozy with those colors) edit your user settings at: Edit -> Preferences -> Settings: User
Please login or register to see this code.
And if you want to have auto completion you have to add
Please login or register to see this attachment.
to your ZeroBraneStudio/api/lua folder.Please note that this file is the english file and has some few additions which i didn't see or where incorrect. Looks like:
Please login or register to see this attachment.
To activate it, please make sure you add it. Go to Edit -> Preferences -> Settings: System
Add the following string to it:
Please login or register to see this code.
The fibaro:calculateDistance doesn't work and the sourcetrigger needs to be set manually. See below snippet for testing:
Please login or register to see this code.
FAQ:
Q: I get the following error message: lualibs/json/decode.lua:74: bad argument #1 to 'match' (string expected, got nil)
A: It cannot reach Fibaro system correctly. Please make sure you have the right userid/pwd and correct ip number.
Q: I don't see any completion on my fibaro:
A: Make sure you added the completion Edit -> Preferences -> Settings: System (lualib)
Q: Where do i get all my values from?
A: You can make use of the excellent tool from @Krikroff found
Please login or register to see this link.
to grab all the values.Q: Where is this data coming from?
A: Fibaro has an api interface, you can go there via http://192.16.x.x/docs where you can try it out.
Q: I click on play but it does not keep running?
A: Make sure you click the double green arrow. The other one stops untill you press forward. (F6 = Go, F5 = Waits on next itteration)
Q: I want to change the width of the tabs
A: Go to Edit -> Preferences -> Settings: User and add "editor.tabwidth = 3"
Q: Disable wordwrap for long lines
A: Go to Edit -> Preferences -> Settings: User and add "editor.usewrap = false"
Q: How to i debug line by line?
A: See below (credits go to
Please login or register to see this link.
for below screenshots & explanation)Open Zerobranstudio and display the following windows if you have not already done so
Please login or register to see this link.
insert the following code in a new blank window Zerobranstudio (we will revise multiplication
)
Please login or register to see this code.
To activate dynamic tag tracking, simply select the name of the variable you want to track, then right click on it to bring up a context menu.
You must then select the option Add watch expression as in the image below. In our case, it must be done for the 2 variables i & j.
Please login or register to see this link.
To switch to debug mode, press the F5 key once, the window should look like this.
The green cursor is positioned on the first instruction, and the Watch window displays the values of i and j (to nil at the moment which is logical)
Please login or register to see this link.
Now press the F10 key to execute the program step by step, until the first result of the multiplication is displayed, as shown below.
The result of the multiplication is consistent with the values of i and j.
Please login or register to see this link.
To test now the modification on the fly of a variable, we will re-run the loop a second time by pressing the F10 key several times but without executing the print instruction, as in the image below. The value of the 2 variables has been modified by programming.
Please login or register to see this link.
To modify dynamically the value of j, click on the Remote console tab, type the line i = 20 then press the Enter key to validate the command, as in the image below. We can then see that the value of ja has been modified in the Watch window.
Please login or register to see this link.
It is now enough to click on the tab Output (suspended), and to press the key F10 to resume the execution of the program.
It is now that the value of j set by hand has been dynamically taken into account by the program.
Please login or register to see this link.
Happy Coding! \o/
(feel free to make remarks so i can make it better)
Please login or register to see this attachment.
Edited by riemersChange to lualibs 1.0.1
Link to comment
Share on other sites
25 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.