Giter Site home page Giter Site logo

jangabrielsson / fibemu Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 13.7 MB

Fibaro HC3 QuickApp emulator for vscode

Home Page: https://forum.fibaro.com/topic/66394-visual-studio-code-vscode-for-quickapp-development/

License: MIT License

Lua 100.00%
fibaro fibaro-hc3 fibaro-home-center quickapp

fibemu's Introduction

fibemu

More doc here

Steps to run

  • Have python3 installed on your machine.
  • pip install the needed python libraries from requirements.txt

pip install -r requirements.txt

  • Create a config.json file with the credentials to access the HC3. See config.json.example
  • Install the vscode extension "Local Lua Debugger" by Tom Blind
  • Create a QA file in the directory, select launcher "Fibenv QA file (remote)" and run debug F5
  • See files in the examples/ directory

It's tested on MacOS and Windows 11.

All the emulator files lives in .vscode/emufiles/.

The trick here is that we have a python wrapper for the lua runtime so we solve dependencies on luasocket etc. and we don't need any special headers in the QA lua file to invoke/include the emulator/apis to make the QA being able to execute.

To give some hints to the emulator what type of QA we have etc. we can give directives similar to TQAE (but a bit different) Ex.

        --%%name=MyQA
        --%%type=com.fibaro.binarySwitch
        --%%file=qa3_1.lua,extra;
        --%%remote=devices:788,790
        --%%remote=globalVariables:myVar,anotherVar
        --%%debug=libraryfiles:false,userfilefiles:false

        function QuickApp:onInit()
          self:debug(self.name,self.type,self.id)
          fibaro.call(788,"turnOn")
        end
  • --%%name sets the name of the QA
  • --%%type sets the type of the QA
  • --%%file includes extra QA files in the QA, libraries etc. In this example, 'qa3_1.lua' and the QA file will be named 'extra'
  • --%%debug set some of the many debug flags
  • --%%remote directive that instructs the emulator that it's ok to call device 788,789 on the HC3. As a default, the emulator treats all resources as local and we enable resources we want to interact with on the HC3 as 'remote'. This goes for other resources also like 'globalVariables'.

It integrates with the lua debugger so we can set breakpoints etc. Still work in progress but it's already really useful...

fibemu's People

Contributors

fabioz23 avatar jangabrielsson avatar peterv989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fibemu's Issues

Frontend doesn't reload/refresh?

I notice that if I perform a reload/refresh of the frontend web ui I get a blank screen with the following in the top left of the page:

{"detail":"Not Found"}

It works when the page loads and the address bar shows

http://localhost:5004/frontend/index.html

but when I navigate away using the navbar, a refresh no longer works. It seems to me that the router in the server isn't responding when there is an endpoint. I tried poking around in the MenuBar.vue code but I'm not familiar with Python or Vue enough to know what I'm doing. You are familiar enough with your code that you will probably know immediately what I'm seeing and why.

I am running the latest update of Chrome on Windows 11. I haven't tried it in Edge but I can if you would like. The reason I found this (and maybe it's related?) is that when I restart my QA in Fibemu, I want to refresh the web page to get a fresh screen.

missing setup step in README.md and PDF

Hi,

after repo checkout and git fetch you cannot launch fibemu since the frontend hasn't dist folder.

For creating them launch: cd .vscode/emufiles/frontend && npm run build

If you don't do that you'll receive this error on launch:

Traceback (most recent call last):
  File "~/Documents/fibemu/.vscode/emufiles/__init__.py", line 5, in <module>
    import fibapi
  File "~/Documents/fibemu/.vscode/emufiles/fibapi.py", line 94, in <module>
    app.mount("/frontend", StaticFiles(directory=".vscode/emufiles/frontend/dist"), name="frontend")
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/starlette/staticfiles.py", line 57, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory '.vscode/emufiles/frontend/dist' does not exist

cannot create QuickAppChild device

when on the main QA self:createChildDevice is called an exception is thrown.

self:createChildDevice({name = "test name",type = "com.fibaro.binarySwitch"}, MyQAChild)

exception:

Screenshot 2023-08-09 alle 18 09 54

the program was launched selecting the 1st and the 2nd launch profile (screenshot below) obtaining the same result.

Screenshot 2023-08-09 alle 18 18 07

Problems encountered with v0.36

I like the new "frontend". However, I discovered a few issues on my first look.

  1. I still don't see the stock UI elements. I added the directive "--%%nostock=false" with no apparent effect.

  2. I clicked across the Navbar elements. At some point the emulator died again with the stack overflow crash. I tried to recreate what I did to cause the stack overflow but got nothing.

  3. There is nothing displayed on the frontend config page. Just the Navbar and your ©Copyleft footer.

  4. On the QA UI elements, when I open the drop down, there is a nice "swirl" animation at the right side of the page, but the "+" turns into a "+" again. I like being able to expand more than one element at a time. Please don't "fix" that. 😁

  5. One last annoyance. This is merely a typo but it offends my OCD-ness. In the About text, please fix "pyton3" to "python3". My eye always snaps to that everywhere I see it.

Hope this helps. You have probably addressed these already but I wanted to help.

Unable to install requirements

Have to admit, I can't get past pip installing the requirements on Windows 11

PS D:\fibaro\fibemu> pip install -r .\requirements.txt
Collecting fastapi==0.100.0 (from -r .\requirements.txt (line 1))
  Using cached fastapi-0.100.0-py3-none-any.whl.metadata (23 kB)
Collecting lupa==2.0 (from -r .\requirements.txt (line 2))
  Using cached lupa-2.0.tar.gz (6.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [61 lines of output]

<blah>
    warnings.warn(msg)
  Using bundled Lua in lua52
  Using bundled Lua in lua53
  Using bundled Lua in lua54
  generated sources not available, need Cython to build
  WARNING: trying to build with Cython, but it is not installed

Even if you force install cython, no change. Rebooted enough times too.
Tried on two independent installs of Windows 11.

python3 - 3.12.0
pip - 23.3.1
windows 11 pro 23H2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.