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

  • Topic Author
  • Posted (edited)

    Because the emulator allows for the option to use asynchronous I/O it's easy to run "servers" in the background that the emulated QA can talk to.

    In particular it's useful for developing QAs that talk to external devices using TCPSocket.

    The emulator now contains a simple socketServer that can be started together with the QA in test and the socket server can easily be modified with more or less predefined responses to different commands. This is way easier than trying to develop/debug a similar QA on the HC3...

    Here is an example.

     

    Please login or register to see this code.

     

    The log gives (using the built-in Web UI to call the "turnOn" command)

    Please login or register to see this code.

    The TCP test QA is part of the examples provided in the TQAEexamples subdirectory.

    Edited by jgab
    Posted

    Tried implementing the TQAE - followed the 

    Please login or register to see this link.

     

    but is stuck here. Is using ZBS 1.90 (newest)

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    10 hours ago, ChristianSogaard said:

    Tried implementing the TQAE - followed the 

    Please login or register to see this link.

     

    but is stuck here. Is using ZBS 1.90 (newest)

    Please login or register to see this code.

     

    Thanks, that was a bug. wsLua was in my path so I didn't notice it was missing in the source I distributed. I uploaded the new version (you only need to update net.lua in TQAEmodule/)

    • Like 1
    Posted (edited)
    9 hours ago, jgab said:

    Thanks, that was a bug. wsLua was in my path so I didn't notice it was missing in the source I distributed. I uploaded the new version (you only need to update net.lua in TQAEmodule/)

    I'm still missing some files, I have a MQTT library, init.lua is there and not found but not the MQTT.lua

     

     

    Program starting as '"/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua53" -e "io.stdout:setvbuf('no')" "/var/folders/nr/kj3y7bl10sj55ylrgdc7xw000000gn/T/.dTu9mo"'.
    Program 'lua53' started in '/Users/christian_nielsen/Downloads/TQAE' (pid: 6345).
    Debugging session started in '/Users/christian_nielsen/Downloads/TQAE/'.
    Program completed in 2.26 seconds (pid: 6345).
    TQAE.lua:281: Loading module TQAEmodules/net.lua:162: module 'mqtt' not found:
        no field package.preload['mqtt']
        no file '/usr/local/share/lua/5.3/mqtt.lua'
        no file '/usr/local/share/lua/5.3/mqtt/init.lua'
        no file '/usr/local/lib/lua/5.3/mqtt.lua'
        no file '/usr/local/lib/lua/5.3/mqtt/init.lua'
        no file './mqtt.lua'
        no file './mqtt/init.lua'
        no file './mqtt.lua'
        no file './mqtt/init.lua'
        no file './lua/mqtt.lua'
        no file './lua/mqtt/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/mqtt.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/mqtt/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/mqtt.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt.dylib'
        no file '/usr/local/lib/lua/5.3/mqtt.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './mqtt.so'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt.dylib'
    stack traceback:
        [C]: in function 'error'
        TQAE.lua:281: in local 'loadModules'
        TQAE.lua:496: in main chunk
        TQAE_QA.lua:1: in main chunk

    Please login or register to see this attachment.

    Edited by ChristianSogaard
    P
  • Topic Author
  • Posted

    Sorry again. Need to include mqtt the proper way. I think I went through all the code so there should be no missing files anymore.

    Pushed new version to GitHub (only net.lua needed change)

    • Thanks 1
    Posted
    10 hours ago, jgab said:

    Sorry again. Need to include mqtt the proper way. I think I went through all the code so there should be no missing files anymore.

    Pushed new version to GitHub (only net.lua needed change)

    Thank you Jan

     

    But that didnt work for me

    tried updating the

    Please login or register to see this link.

     and that didnt work i started all over with  

    Please login or register to see this link.

    -- Every file in one archive 

     

     

    Program starting as '"/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua53" -e "io.stdout:setvbuf('no')" "/var/folders/nr/kj3y7bl10sj55ylrgdc7xw000000gn/T/.T3Kvur"'.
    Program 'lua53' started in '/Users/christian_nielsen/Downloads/TQAE' (pid: 13977).
    Debugging session started in '/Users/christian_nielsen/Downloads/TQAE/'.
    Program completed in 1.69 seconds (pid: 13977).
    TQAE.lua:281: Loading module TQAEmodules/mqtt/init.lua:34: module 'mqtt.client' not found:
        no field package.preload['mqtt.client']
        no file '/usr/local/share/lua/5.3/mqtt/client.lua'
        no file '/usr/local/share/lua/5.3/mqtt/client/init.lua'
        no file '/usr/local/lib/lua/5.3/mqtt/client.lua'
        no file '/usr/local/lib/lua/5.3/mqtt/client/init.lua'
        no file './mqtt/client.lua'
        no file './mqtt/client/init.lua'
        no file './mqtt/client.lua'
        no file './mqtt/client/init.lua'
        no file './lua/mqtt/client.lua'
        no file './lua/mqtt/client/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client/mqtt/client.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client/mqtt/client/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client/mqtt/client.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/lualibs/mqtt/client/init.lua'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt/client.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt/client.dylib'
        no file '/usr/local/lib/lua/5.3/mqtt/client.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './mqtt/client.so'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt/client.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt/client.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt.dylib'
        no file '/usr/local/lib/lua/5.3/mqtt.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './mqtt.so'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/mqtt.dylib'
        no file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/libmqtt.dylib'
    stack traceback:
        [C]: in function 'error'
        TQAE.lua:281: in local 'loadModules'
        TQAE.lua:496: in main chunk
        TQAE_QA.lua:1: in main chunk
    Debugging session completed (traced 0 instructions).
     

    Posted
    On 10/11/2021 at 9:29 AM, jgab said:

    New version, v0.30.

    Lot's of bug fixes and a better web UI.

    Here is a short installation tutorial:

     

    Installation

    The source for the emulator is available at the Fibaro forum link or directly from my GitHub <

    Please login or register to see this link.

    > (It's a bit messy...)

    First time download the archive, 

    Please login or register to see this link.

     and unpack it in a suitable directory on your PC/Mac/Linux.
    On Linux:

    Please login or register to see this code.


    On PC/Mac use suitable archive program to unpack the archive.

    Please login or register to see this code.

    Download ZeroBrane studio <

    Please login or register to see this link.

    >
    Open ZBS and open the TQAE_QA.lua file
    Set project directory in ZBS to the current file, TQAE_QA.lua (Project->Project Directory->Set From Current File)

    Also set Lua interpreter to Lua 5.3 (Project->Lua Interpreter->Lua 5.3)

    Now, run TQAE_QA.lua (F5 in ZBS).

    The output will look something like:

    Please login or register to see this code.

    Note first that there is no connection to the HC3 - we are missing user,  password, and IP for the HC3.
    Secondly, note the WebAPI address. 192.168.1.18 is my machine, your IP address may be different. The port is 8976.
    Open http://192.168.1.18:8976/web/main in your browser.

     

    Please login or register to see this attachment.

     

    Goto [Settings] in the web page menu (upper right)

     

    Please login or register to see this attachment.


    In the right hand column "Settings file", fill in User ID, Password, and IP address for the HC3.
    Scroll down to the bottom of the page and click "Save"

    Hopefully there is now a TQAEconfigs.lua file with the HC3 credentials that the emulator can use.

    Go back to ZBS and stop the program (Shift-F5) and run it again:

    Please login or register to see this code.

    It loads the config file and doesn't complain that there is no connection to the HC3 anymore.

    Great we are up and running!

    Hello Jan,

    will follow your instructions to install the emulator.
    Unfortunely i fail on the first steps: My output on ZEROBRAIN is this:

    Please login or register to see this attachment.

     

    What do i wrong?

  • Topic Author
  • Posted

    You just need to press run again. The debugger stops at the first line of the code. See that little red arrow up to the left on the first line?

    Posted
    3 hours ago, jgab said:

    You just need to press run again. The debugger stops at the first line of the code. See that little red arrow up to the left on the first line?

    First click

    Please login or register to see this attachment.

     

    Second Click

    Please login or register to see this attachment.

     

    third Click

    Please login or register to see this attachment.

     

     

     

    Posted (edited)
    20 minutes ago, ChristianSogaard said:

    First click

    Please login or register to see this attachment.

     

    Second Click

    Please login or register to see this attachment.

     

    third Click

    Please login or register to see this attachment.

     

     

     

    I copied the MQTT lib into ZBS- and now it works.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

    Edited by ChristianSogaard
  • Topic Author
  • Posted
    8 hours ago, ChristianSogaard said:

    I copied the MQTT lib into ZBS- and now it works.

     

    Please login or register to see this attachment.

     

     

    Oh, this was really difficult. I've uploaded a new version that hopefully makes it work.

    It may be an issue on windows machines due to different path separator in directory paths - let me know if you have issues on windows machines and I will try to fix it.

    Posted (edited)
    9 minutes ago, jgab said:

     

    Oh, this was really difficult. I've uploaded a new version that hopefully makes it work.

    It may be an issue on windows machines due to different path separator in directory paths - let me know if you have issues on windows machines and I will try to fix it.

    i'm on MAC ;-) so a cant test on Windows, Sorry.

    I deleted the MQTT in ZBS and downloaded the package again. It works

    Thank you for all you assistance

     

    Edited by ChristianSogaard
    P
    Posted (edited)
    On 10/11/2021 at 9:29 AM, jgab said:

    New version, v0.30.

    Lot's of bug fixes and a better web UI.

    Here is a short installation tutorial:

     

    Installation

    The source for the emulator is available at the Fibaro forum link or directly from my GitHub <

    Please login or register to see this link.

    > (It's a bit messy...)

    First time download the archive, 

    Please login or register to see this link.

     and unpack it in a suitable directory on your PC/Mac/Linux.
    On Linux:

    Please login or register to see this code.


    On PC/Mac use suitable archive program to unpack the archive.

    Please login or register to see this code.

    Download ZeroBrane studio <

    Please login or register to see this link.

    >
    Open ZBS and open the TQAE_QA.lua file
    Set project directory in ZBS to the current file, TQAE_QA.lua (Project->Project Directory->Set From Current File)

    Also set Lua interpreter to Lua 5.3 (Project->Lua Interpreter->Lua 5.3)

    Now, run TQAE_QA.lua (F5 in ZBS).

    The output will look something like:

    Please login or register to see this code.

    Note first that there is no connection to the HC3 - we are missing user,  password, and IP for the HC3.
    Secondly, note the WebAPI address. 192.168.1.18 is my machine, your IP address may be different. The port is 8976.
    Open http://192.168.1.18:8976/web/main in your browser.

     

    Please login or register to see this attachment.

     

    Goto [Settings] in the web page menu (upper right)

     

    Please login or register to see this attachment.


    In the right hand column "Settings file", fill in User ID, Password, and IP address for the HC3.
    Scroll down to the bottom of the page and click "Save"

    Hopefully there is now a TQAEconfigs.lua file with the HC3 credentials that the emulator can use.

    Go back to ZBS and stop the program (Shift-F5) and run it again:

    Please login or register to see this code.

    It loads the config file and doesn't complain that there is no connection to the HC3 anymore.

    Great we are up and running!

    Hi Jan

    Would you mind upload a version of iOSLocator.lua with TQAE integrated and fibaroExtra.lua for ZBS so i can start the trace why my iOSLocator.lua is not working? -I am so confused with TQAE, ZBS and the "old" fibaroapiHC3.lua...

     

    i ended up with this - but no luck

     

    _=loadfile and loadfile("TQAE.lua"){ user="xxxx", pwd="xxxx", host="192.168.xxx.xxx" }

    --%%name='Test'
    --%%id=99
    --%%quickVars={x=88,y=99}

    function QuickApp:onInit()

    end

    _=loadfile and loadfile("TQAE.lua"){
    --  modPath = "TQAEmodules/",
    }
    _=loadfile and loadfile("fibaroExtra.lua"){
    --  modPath = "TQAEmodules/",
    }
    --%%name="Test QA"


    function QuickApp:onInit()
      self:debug(self.name,self.id)
      self:debug([[This is a simple QA that does nothing besides logging "PING"]])
      setInterval(function() self:debug("PING") end,1000)
      self:debug("y=",self:getVariable("y"))
      local n = 5
      setInterval(function() 
          n=n-1
          if n <= 0 then os.exit() end
          self:debug("PING") 
          end,1000)
    end 


    ---------------------- Setup users -----------------------------


    local version = "V0.2"
    local USERS = {      -- Fill in with iOS credentials
     {name='admin', id = 2,  device='Dr. S iPhoneX', home=true, icloud={user='xxxx', pws='xxxx'}},
     -- {name='ad

    Edited by ChristianSogaard
    P
  • Topic Author
  • Posted
    1 hour ago, ChristianSogaard said:

    Hi Jan

    Would you mind upload a version of iOSLocator.lua with TQAE integrated and fibaroExtra.lua for ZBS so i can start the trace why my iOSLocator.lua is not working? -I am so confused with TQAE, ZBS and the "old" fibaroapiHC3.lua...

    This  one  I use

    Please login or register to see this attachment.

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

    This  one  I use

    Please login or register to see this attachment.

    Thank you @jgab

     

     

     

     

    Edited by ChristianSogaard
    P
    Posted (edited)
    1 hour ago, ChristianSogaard said:

    Thank you @jgab

     

     

     

     

    Hi Jan

    i'm up running - thank you for all you help ?

     

    I found the error - you wrote.

    Please login or register to see this code.

    But its pwd and not pws :-) 

     

    and in 

    Please login or register to see this code.

    its - quickApp and not quickApp2

    Edited by ChristianSogaard
    P
    • Thanks 1
  • Topic Author
  • Posted

    A new Updater QA that helps in updating QAs on the HC3. At the moment it only supports my own QAs but the mechanism is there to allow people to add their own QAs. The pre-requisite is that QAs are stored in GitHub and version are tagged. It blends well with the TQAE development environment. 

     

  • Topic Author
  • Posted

    Great intro to the TQAE emulator <

    Please login or register to see this link.

    > by @Joep 

    - thanks @Joep!

     

    • Thanks 2
    Posted (edited)
    On 10/29/2021 at 10:36 AM, jgab said:

    This  one  I use

    Please login or register to see this attachment.

    Hi

     

    I have used the IOSLocator for some time, or it has been installed, and i started to look more into it, because i want to use it as GEOFensing.

    A minor Observation

    If the device='iPhone' name is 'silje :)' it dont work, and if I with same credentials uses 'Siljes iPad Pro' it works - so the parsing of the iphone name, can't handle the semicolon or the parentheses.

     -- {name='Ann',   device='iPhone', home=true, icloud="XXXX2"},
     -- {name='Tim',   device='iPhone', home=true, icloud="XXXX3"},

    Please login or register to see this attachment.

     

    Please login or register to see this image.

    /monthly_2022_01/2022-01-09_15-56-34.png.192c7edc724b8c824c16ce2dcccb27f0.png" />

    Edited by ChristianSogaard
    P
  • Topic Author
  • Posted

    Yes, it's a bit tricky how to match

    Think about the device name you configure iosLocator to be a pattern that should match the real device name.

    "iPhone Jan"

    matches

    "iPhone Jan" and "iPhone Jan (2)"

     

    Because it's a pattern it needs to conform to pattern rules. A pattern with just a ")" like in ";)" is malformed because "()" is used for pattern captures.

    You could specify your device as "Siljes %:%)" and it would match "Siljes :)". That is because % escapes pattern directives like the ")"

    It's the same rules as for

    Please login or register to see this link.

     

    Would that work for you?

    • Thanks 1

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