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


Tiny QuickApp Emulator (TQAE)


jgab

Recommended Posts

Jan,

ZeroBrane is open and two tabs I have TQAE  and TQAE_QA the last one is active and on screen

http://192.168.11.36:8976/web/main>>> error can't open server does't respond

 

Link to comment
Share on other sites

  • Topic Author
  • 11 minutes ago, Sjakie said:

    Jan,

    ZeroBrane is open and two tabs I have TQAE  and TQAE_QA the last one is active and on screen

    http://192.168.11.36:8976/web/main>>> error can't open server does't respond

     

    They have to run, not just open in the editor. F5->Run

    2 minutes ago, jgab said:

    They have to run, not just open in the editor. F5->Run

    Or it have to run. Can only run one file at the time.

    When you see something like below you can open the web browser.

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Ex. copy EventRunner4.lua from jgabs_QAs/EventRunner/EventRunner4.lua to your test directory, so you have your own copy. Open it there and run it.

    You could then play with adding rules etc.

    Edited by jgab
    Link to comment
    Share on other sites

    in log after clicking  Fn>5 (run)

    Please login or register to see this code.

    It still does't open web

     

    Will try ER4

     

    Edited by Sjakie
    will try
    Link to comment
    Share on other sites

  • Topic Author
  • 7 minutes ago, Sjakie said:

    in log after clicking  Fn>5 (run)

    Please login or register to see this code.

    It still does't open web

     

    Will try ER4

     

    Please show me the whole log when you try to open the web.

    You need to see something like

    Please login or register to see this code.

    Have you included the header in the QA file?

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Jan,

    This log from your JGabs....lua

    in that herder is already the above sentence you typed

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • "

    Please login or register to see this code.

    tells us that you haven't setup the credentials as described.

    Create a file TQAE/TQAEconfigs.lua and add the code

    Please login or register to see this code.

    with your HC3 host, user and password.

    The try to start your QA again.

     

    (Thanks, you discovered a bug, it shouldn't try to start the refreshState loop if there are no credentials)

    My God! you have a really old TQAE v0.39(!)

    (the no creds and refreshState bug is not in the recent versions)

    Download the latest, v0.57

    Link to comment
    Share on other sites

  • Topic Author
  • Ok, so you used the link to the tar archive. It of course gave you an old version. I have fixed the link so it will always point to the lastest.

    However, I strongly encourage you to use the git approach outlined in the first post to download and setup your development directories. It makes it much easier to update TQAE whenever I push a fix.

    Link to comment
    Share on other sites

    Yes and no!

    As mentioned earlier I use GitHub repository.

    You advised me to take lua file from folder JGab's...... that I did and forgot to save as, I messed up the file and could't install GitHub repository again so I open my earlier version from .tar

    let me update(to try)>>stuck as Windows user

    Jan, what is handy where to place fa your TQAE folder?

    When launch get 

    fatal: destination path 'TQAE' already exists and is not an empty directory.

    sjaakkoppejan@sjaakkoppejan tqae %

    jastb delete the folder?

     

    Edited by Sjakie
    Done with error
    Link to comment
    Share on other sites

    • 2 weeks later...

    I got a new mac m1 max and reinstalled everything - including ZBS

    I followed the great installation guide from @Joep .

    No firewall in enabled on the MACos

    TQAE templated is found in ZBS

     

    trying the simple example

    Please login or register to see this code.

     

    Gives me this error - any idea why.

    Could it be the M1 Mac or would you bet on an human error ?

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    4 minutes ago, ChristianSogaard said:

    I got a new mac m1 max and reinstalled everything - including ZBS

    I followed the great installation guide from @Joep .

    No firewall in enabled on the MACos

    TQAE templated is found in ZBS

     

    trying the simple example

    Please login or register to see this code.

     

    Gives me this error - any idea why.

    Could it be the M1 Mac or would you bet on an human error ?

     

    Please login or register to see this code.

     

    Found the Error - My VPN Connection was blocking ... and i need that for connecting to HC3 

    Link to comment
    Share on other sites

  • Topic Author
  • Yep, Christians-MBP:8172 tells that ZBS tries to connect to port 8172 on your Mac and that was blocked. 

    The way ZBS works is that it starts a shell process in the background where it runs the Lua interpreter with your program. (it puts your code in a temporary file, /var/folders/....)

    Please login or register to see this code.

    It also adds a small library to your app that is an remote debugger (the debugger is called 'mobdebug'). mobdebug starts a server in your app that can receive  debug commands on port 8172. The ZBS editor then sends commands to that port to set breakpoints, step, run stop etc.

     

    If Fibaro would include the mobdebug lib on the HC3 we could use ZBS to remote debug QAs running on the HC3. There are many other embedded systems out there that allows it.

     

    I also run a VPN on my Mac (work Mac) and if I restart ZBS after the VPN is up it works for me. 

    • Thanks 1
    Link to comment
    Share on other sites

    • 3 months later...
  • Topic Author
  • New version of the emulator uploaded.

    I've added a new version of copas - it will improve if you need asynchronous I/O. set copas=true in header,

     

    Also added support to embed images.

    Please login or register to see this code.

    --IMAGE points to a png in your folder and a name for the image.

    All images will be base64 encoded and included as a QA file named "IMAGES64B".

    In that QA file, images will be added to a global Lua table named "_IMAGES"

    In our case

    Please login or register to see this code.

     

    In this example I created a helper function QuickApp:setImage(...) that updates a label with the image. Here you can give width and height to override the images original height, width.

     

    It should work in the emulated UI too. When it looks ok it's just to press a button to upload to the HC3 with images embedded and all... :-) 

    Edited by jgab
    • Thanks 2
    Link to comment
    Share on other sites

    • 1 month later...

    WOW, you sir @jgab are an absolute genius! This is GOLD!

     

    I do have a question; I'm probably missing something, but how do I open a fqa file with TQAE? 

    Link to comment
    Share on other sites

  • Topic Author
  • Well, you can do something like this
     

    Please login or register to see this code.

    It will install the "Test QA.fqa" file that are in the TQAE directory, using the deviceID 88 and "break on init"...

    When TQAE unpacks the fqa into lua files to run it will do that in the temp directory. If you set breakOnInit=true the 

    debugger will open the file from the temp directory in the editor and break on the first line.

    At least it works in ZeroBrane Studio - unsure about VCS (needs mobdebug, but don't think the editor loads the file)

     

    The main use for this is to load an additional QA in the emulator, besides the one you are developing to let them talk to each other. (See the ping/pong example in the examples dir).

     

    I guess what could be added is a function that reads in an .fqa and split it up into lua files and saves it locally in a directory for easier editing.

    Edited by jgab
    Link to comment
    Share on other sites

    • 1 month later...
  • Topic Author
  • I have made some changes to TQAE so it works better in vscode.

    (the repository comes with a .vscode directory with some setups...)

    Still requires that you have luasocket and luafilesystem installed.

    Link to comment
    Share on other sites

    • 2 months later...

    ---------------- Tiny QuickAppEmulator (TQAE) v0.59 -------------
    [27.09.2023] [21:14:59] [WARN | No connection to HC3
    [27.09.2023] [21:14:59] [SYS  |Running offline
    [27.09.2023] [21:14:59] [SYS  |Created WebAPI at http://192.168.1.39:8976/web
    [27.09.2023] [21:14:59] [SYS  |sunrise 06:59, sunset 18:54
    [27.09.2023] [21:15:00] [DEBUG] [QUICKAPP1001]: Test QA 1001
    [27.09.2023] [21:15:00] [DEBUG] [QUICKAPP1001]: This is a simple QA that does nothing besides logging "PING"
    [27.09.2023] [21:15:01] [DEBUG] [QUICKAPP1001]: PING
    [27.09.2023] [21:15:02] [DEBUG] [QUICKAPP1001]: PING
    [27.09.2023] [21:15:03] [DEBUG] [QUICKAPP1001]: PING
    [27.09.2023] [21:15:04] [DEBUG] QUICKAPP1001]: PING

     

    The IP adress above is not the one I have declared in the file TQAEconfigs.lua in main directory  /TQA-main

    Below my config file :

     

    -- Save as TQAEconfigs.lua
    return {
    NOVERIFY=true,
    host="192.168.1.65",
    user="bruviere\@orange.fr",
    pwd="\@2357Bccv7677\@",
    configFile="TQAEconfigs.lua",
     
     
     
     
     fibColors = { ["DEBUG"] = 'red', ["TRACE"] = 'blue', ["WARNING"] = 'orange', ["ERROR"] = 'red' },
     logColors = { ["SYS"] = 'yellow', ["ERROR"]='red', ["WARN"] = 'orange', ["TRACE"] = 'blue' },
    }

     

    I have not find any file in which is declared 192.168.1.39 as a host IP address..
    In directory verify, I have found in file api_verifier.lua a variable local [hc3 = "192.168.1.57] and I changed it to my IP adress but no change , the WebAPI IP address is still wrong.

     

    What I have done wrong?

    my version of ZBS : ZeroBrane Studio (1.90; MobDebug 0.706)

    Link to comment
    Share on other sites

  • Topic Author
  • 31 minutes ago, Christb said:

    ---------------- Tiny QuickAppEmulator (TQAE) v0.59 -------------
    [27.09.2023] [21:14:59] [WARN | No connection to HC3
    [27.09.2023] [21:14:59] [SYS  |Running offline
    [27.09.2023] [21:14:59] [SYS  |Created WebAPI at http://192.168.1.39:8976/web
    [27.09.2023] [21:14:59] [SYS  |sunrise 06:59, sunset 18:54
    [27.09.2023] [21:15:00] [DEBUG] [QUICKAPP1001]: Test QA 1001
    [27.09.2023] [21:15:00] [DEBUG] [QUICKAPP1001]: This is a simple QA that does nothing besides logging "PING"
     

    The IP adress above is not the one I have declared in the file TQAEconfigs.lua in main directory  /TQA-main

    Below my config file :

     

    -- Save as TQAEconfigs.lua
    return {
    NOVERIFY=true,
    host="192.168.1.65",
    user="bruviere\@orange.fr",
    pwd="\@2357Bccv7677\@",
    configFile="TQAEconfigs.lua",
     

    I have not find any file in which is declared 192.168.1.39 as a host IP address..
    In directory verify, I have found in file api_verifier.lua a variable local [hc3 = "192.168.1.57] and I changed it to my IP adress but no change , the WebAPI IP address is still wrong.

     

    What I have done wrong?

    my version of ZBS : ZeroBrane Studio (1.90; MobDebug 0.706)

    The host="192.168.1.65" is the ip of the HC3. 

    The 192.168.1.39 is the address from where you run Zerobrane. TQAE figures that out itself - thus not in the code...

    It's in reality 127.0.0.1 but  TQAE runs a web server on that address so the emulator and HC3 can communicate back and forth... and it also shows an emulator UI on from that address http://192.168.1.39:8976/web

     

    However, the log says

    [27.09.2023] [21:14:59] [WARN | No connection to HC3
    [27.09.2023] [21:14:59] [SYS  |Running offline

     

    that means that you either that you have set offline=true in the QA header or that it failed to connect to the HC3 given the credentials you gave. However, if credentials were wrong you should have gotten another log warning message that it was the case.

    Link to comment
    Share on other sites

    Sorry, since my previous message I have find the the 192.168.1.39 was IP address of the PC itself.

    I have made progress as nos TQAE is using my config file but credential is not OK:

    [28.09.2023] [09:36:01] |ERROR| Bad credential when logging in to HC3, exiting to avoid account lockout

     

    I have tried to encode the @ in name an password with %@ with the same error

    I am now using

    -- Save as TQAEconfigs.lua
    return {
    NOVERIFY=true,
    host="192.168.1.65",
    user="[email protected]",
    pwd="@2357Bccv7677@",
    configFile="TQAEconfigs.lua",

     

    and it is working as shown below:

    ---------------- Tiny QuickAppEmulator (TQAE) v0.59 -------------
    [28.09.2023] [09:44:09] |SYS  | Using config file TQAEconfigs.lua
    [28.09.2023] [09:44:09] |SYS  | Created WebAPI at http://192.168.1.39:8976/web
    [28.09.2023] [09:44:09] |SYS  | sunrise 07:54, sunset 19:47
    [28.09.2023] [09:44:10] [DEBUG] [QUICKAPP1001]: Test QA 1001
    [28.09.2023] [09:44:10] [DEBUG] [QUICKAPP1001]: This is a simple QA that does nothing besides logging "PING"
    [28.09.2023] [09:44:14] [DEBUG] [QUICKAPP1001]: PING

    Sorry, my mistake..

    Now I need to learn how to use TQAE

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Christb said:

    Sorry, since my previous message I have find the the 192.168.1.39 was IP address of the PC itself.

    I have made progress as nos TQAE is using my config file but credential is not OK:

    [28.09.2023] [09:36:01] |ERROR| Bad credential when logging in to HC3, exiting to avoid account lockout

     

    I have tried to encode the @ in name an password with %@ with the same error

    I am now using

    -- Save as TQAEconfigs.lua
    return {
    NOVERIFY=true,
    host="192.168.1.65",
    user="[email protected]",
    pwd="@2357Bccv7677@",
    configFile="TQAEconfigs.lua",

     

    and it is working as shown below:

    ---------------- Tiny QuickAppEmulator (TQAE) v0.59 -------------
    [28.09.2023] [09:44:09] |SYS  | Using config file TQAEconfigs.lua
    [28.09.2023] [09:44:09] |SYS  | Created WebAPI at http://192.168.1.39:8976/web
    [28.09.2023] [09:44:09] |SYS  | sunrise 07:54, sunset 19:47
    [28.09.2023] [09:44:10] [DEBUG] [QUICKAPP1001]: Test QA 1001
    [28.09.2023] [09:44:10] [DEBUG] [QUICKAPP1001]: This is a simple QA that does nothing besides logging "PING"
    [28.09.2023] [09:44:14] [DEBUG] [QUICKAPP1001]: PING

    Sorry, my mistake..

    Now I need to learn how to use TQAE

     

    Ok, so it's working now?

    Please ask, there are a million features that are not documented :-) 

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