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


VS code development and debugging Fibaro LUA code


10der

Recommended Posts

Hi!

 

I don't know if anybody will it be interesting...  but

 

1) install VS Code 

Please login or register to see this link.

2) download and install LUA plugin

Please login or register to see this image.

 

3) let's test

* new file

* save

main.lua (it's important) 

NzuYeFW1eV.png

 

4) 

Please login or register to see this code.

 

6) press F5

6) add config by default

cJsJ453Gtn.png

 

replace launch.json with

 

Please login or register to see this code.

7) press F5 again

 

yay!

 

mMCjOtvk2a.png

 

 

your first LUA script in VS code done!

 

integration with Fibaro

 

create inside your application dir (folder) "lib" 

unpack libs.zip (attached)

 

1) open launch.json 

2) modify: 

 

Please login or register to see this code.

add

 

Please login or register to see this code.

your config now looks like 


 

Please login or register to see this code.

 

let's coding

 

fibaro:debug("Hello fibaro!")

 

F5

 

yay!!

 

R6G2ebT70I.png

 

so., now you can debug any Fibaro scripts.

 

"arg0":["-lfibaro_emu"] - prelaod fibaro emulator

"arg0":["-lfibaro"] - prelaod real fibaro bridge

note: change ip address and basic auth for your HC2

lib\fibaro.lua 

 

Please login or register to see this code.

 

simple sample :)

 

Please login or register to see this code.

CC4LH4pWot.png

 

 

happy debugging :)

 

 

Please login or register to see this attachment.

  • Like 5
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
On 6/16/2018 at 1:14 AM, antonkristensen said:

Anyone that knows how to get this to work on macOS?

I can only get as far as modifying the config the 1st time.

Link to comment
Share on other sites

  • Topic Author
  • about macOS.

    I have old mac os device (mac mini 2012) and ok will do on this a weekend playing with it.

     

    I'll keep you in the loop!

    Link to comment
    Share on other sites

     

     

    2 minutes ago, 10der said:

    about macOS.

    I have old mac os device (mac mini 2012) and ok will do on this a weekend playing with it.

     

    I'll keep you in the loop!

    +1

    Edited by SYSMANFIBadb
    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this link.

     
    commented 

    Please login or register to see this link.

      

    edited 

    I'm sorry, the debugger doesn't support linux. I don't have a linux test environment, and debugger.dllsupport linux should be simple but debugger-inject.dll support linux I have no way, especially for the planned new features.

    My current plan is to support x64, support attach to process, support multiple versions of Lua (eg 5.3 and 5.4).

    Link to comment
    Share on other sites

  • Topic Author
  • i have installed 

     

    Please login or register to see this attachment.

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    • 3 months later...
    • 5 weeks later...
    • 3 months later...
  • Topic Author
  • 20 minutes ago, scheigl said:

    Can you please help me where exactly should I put the lib folder I unpacked?

    Create a folder with name Fibaro

    <enter>

    Create folder

    libs

    unpack into libs folders libs

    back to fibaro folder

    create a new file 

    "fibaro.lua"

     

    past to this file

     

    package.path = package.path .. ";./libs/?.lua";
    package.cpath = package.cpath .. ";./libs/?.dll";
    require("fibaro_emu")

     

    save

     

    create another one

     

    test.lua

     

    if require then
        require("fibaro")
    end
     

    fibaro:debug("I love Fibaro!");

     

    Link to comment
    Share on other sites

    • 2 weeks later...

    after I installed VSCode and created the main.lua file and I installed the Lua Debug and replaced the lunch.json it gives me "cannot find debug adapter for type 'Lua'" error 

     

    Any Help ?? 

    Link to comment
    Share on other sites

  • Topic Author
  • step 2 

    download and install LUA plugin

    Link to comment
    Share on other sites

  • Topic Author
  • can you look on screenshot the1st message?

    Edited by 10der
    Link to comment
    Share on other sites

    • 6 months later...

    Hi @10der,

     

    Thank for this job ! Have you updated since since this post other function in fibaro_emu.lua ? like fibaro:isSceneEnabled ?

     

    Have you a way to launch a scene with args in parameters ? 

     

    Please login or register to see this code.

    Thank in advance

     

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

     

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