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
    13 minutes ago, Christb said:

    In fact this not an updateView issue but the refresh of the html view (my code is in fact OK).

    As in fibemu, is it possible to add a directive to refresh automatically the html view? or inside a setting file?

    Ins't that what the Live Server extension does?

    Please login or register to see this link.

     

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

    ns't that what the Live Server extension does?

    Please login or register to see this link.

     

    Sorry, I missed this point: YES it does, now the web UI is almost updated immediatly. Many thanks 😚

     

    I may not need anymore fibemu but I am still interested to know why it is not working with exception for any of fibaro request...like:

    [error] .

    Please login or register to see this link.

    : attempt to index a nil value (global 'api')

     

     

     

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

    Sorry, I missed this point: YES it does, now the web UI is almost updated immediatly. Many thanks 😚

     

    I may not need anymore fibemu but I am still interested to know why it is not working with exception for any of fibaro request...like:

    [error] .

    Please login or register to see this link.

    : attempt to index a nil value (global 'api')

     

     

     

    Because you need a different launch.json task to run fibemu ? Could that be the problem? You have the one for hc3emu selected in the F5 run menu...

    Posted
    10 minutes ago, jgab said:

    You have the one for hc3emu selected in the F5 run menu..

    Yes, when, I run in menu Run/Open Configuration I am getting the hc3emu launch.json file.

    In fibemu\.vscode I have a launch.json file which seems to be ok and also a settings.json

    So how I can select the good launch.json file when using fibemu is needed?

    Posted (edited)
    7 hours ago, Christb said:

    So how I can select the good launch.json file when using fibemu is needed?

    Sorry, my knowledge of vscode is limited but I think I have found, using the help of Windows Visual Studio, how to have working one of my QA developped with fibemu: ctrl+shif+d and selecting Fibenv QA file (remote,HC3 access)(fibemu). 👍
    I will try now the same for EventRunner5.

    Edited by Christb
    Posted
    10 minutes ago, Christb said:

    will try now the same for EventRunner5.

    F5 with EventRunner5.lua is giving the good starting log but got 3 system  errors:

    [11.04.2025] [19:17:19] [SYS   ] [boot   ]: QA emulator started
    [11.04.2025] [19:17:19] [SYS   ] [install]: QA '..\EventRunner5\EventRunner5\EventRunner5.lua'
    [11.04.2025] [19:17:19] [SYSERR] [install]: ..\EventRunner5\EventRunner5\EventRunner5.lua - Unknown header variable 'uid'
    [11.04.2025] [19:17:19] [SYSERR] [install]: ..\EventRunner5\EventRunner5\EventRunner5.lua - Unknown header variable 'save'
    [11.04.2025] [19:17:29] [SYSERR] [QUICKAPP5000]: ..\EventRunner5\EventRunner5\EventRunner5.lua - [string "C:\Users\ASUS\Documents\EventRunner5\EventRun..."]:60: unexpected symbol near '<<'

     

    The first 2, I think, are related to 2 of the directives I have in the EventRunner5.lua:

    --%%uid=UPD896846032517892
    --%%save=EventRunner5.fqa

    So I have suppressed this 2 lines and now I think it is working (need to dig more into rules but I am confident)

    Have you a different directive to do the same or they are now useless?

    Also the last error have been cleared automatocally by a merge proposed by vscode.

     

    Again thank you very much for your efficient support.

     

    At the end:

    • hc3emu can be installed on Windows10 even it is not straightforward...
    • Fibemu can be used also fo testing old QA, event it not so difficult to transfert a fibemu QA to hc3emu format.
    • EventRunner also but with fibemu.

     

    Just for fun, I will try to install hc3emu on ZeroBrane!

    Posted
    15 minutes ago, Christb said:

    EventRunner also but with fibemu.

    Thinking about the above I am sure that EventRunner5 is working with hc3emu.

    Now that I know how to select the right json, I will test EV5 with this configuration and may be the 2 errors about directives will disapear.

     

    BTW: How are you setting the value of --%%uid (in your file it is --%%uid=UPD896846032517892) ?

     

  • Topic Author
  • Posted

    Well, EventRunner has changed it's --%% directives a bit now that I have moved over to hc3emu.

    The ER5 that I develop on these days are at 

    Please login or register to see this link.

    and it should work with hc3emu if you use the launch task that use Lua MobDebug: Current File....

     

    When you get

    Please login or register to see this code.

    It's because you are running the new ER5 in fibemu that doesn't understand uid or save directives...

     

     

    Note that I  have set 

    _DEVELOP=../hc3emu

    in the beginning of the file. The is so that the hc3emu files are fetched from that directory instead of the installed rock. I do that because developing ER5 makes me discover bugs in hc3emu... If you are running from the hc3emu rock you can comment out that line.

     

    The uid is just a random string that should uniquely identify your QA. It's not necessary to use. It sets the 'quickAppUuid' property of a QA that is saved or uploaded from the emulator.

     

    I use that in an QA under development that downloads and installs QAs from GitHub to my HC3....

     

    In vscode, each workspace can have a .vscode directory with workspace/project specific settings.

    fibemu used that to sore the fibemu emulator code, to hide it from the regular files in the workspace. I'm not sure that was a brilliant decisions as the fibemu code needed to be in each workspace you had where you used fibemu...

     

    Anyway, in .vscode there are 3 vscode specific files

    Please login or register to see this code.

    They are local to the workspace you are in and you need to be created new for each workspace.

     

    In the past when I used fibemu, I tended to develop all my QAs in the fibemu directory (not having to replicate the fibemu code in .vscode for every new workspace).

    However, that is general not a good idea, because it clashes with Git where you would like to have a separate repository for each QA. Then all QAs was checked in under the main fibemu repository (Git is not so happy about having nested repositories). Then, ER5, was code that lived in fibemu/QAs/ER5...

     

    Now I have broken out all QAs to separate Git repositories.

     

    Also, you can make some of the local .vscode settings files global for vscode.
    Ctrl-shift-p Edit user tasks, wil open a "global" tasks.json file. There I put the tasks.json commands so I don't have to have a local .vscode/task.json in each workspace.
    Ctrl-shift-P Edit user settings, opens a global user settings file where I can put some of the local .vscode/settings.json stuff. 

    Also in that file, there is a section where you can add launch.json commands. SO there I put the "Lua Mobdebug: Current File" command.

     

    That means that when I create a new workspace (development directory on my computer), the launch and tasks stuff are there, and I don't need to install some extra stuff in .vscode. Also the "Hc3Emu" vscode extension that is available now will install the code completion and list of global lua variables automatically when I open a new workspace.

     

    So, a big rationale why I moved from fibemu to hc3emu was the ease of setup (if you have installed luarocks hat is :-) ) Just open a new directory and start coding your QA. Also, it could be used both with vscode and with zerobrane.

    Another rationale was that when hc3emu now is a luarocks "rock". It's easy to upgrade to the newest version

    Please login or register to see this code.

    but also to downgrade if a new version have some issues

    Please login or register to see this code.

    ...and lastly, the emulator code is much simpler structured (I've learned a lot), and thus it's easier for me to maintain

    • Like 2
    Posted
    6 hours ago, jgab said:

    and lastly, the emulator code is much simpler structured (I've learned a lot), and thus it's easier for me to maintain

    Very good.

    This in fact means that keeping fibemu is not required as you wil maintain hc3emu and keep fibemu as is.

  • Topic Author
  • Posted
    Just now, Christb said:

    Very good.

    This in fact means that keeping fibemu is not required as you wil maintain hc3emu and keep fibemu as is.

    Yes, I've stopped developing fibemu - it's in maintenance mode - no new features, and I will only fix serious bugs.

    • Like 2
    Posted

    When finishing to develop my QA about Climate Zone management, I have found a problem unsing the select button in hc3emu:

     

    • The function: self:updateview(<select_button_name>,"selectedItem",<value_of_position>) does not work with the html view: the select button stays on the last choice.
    • If I am using the --%%proxy=name_of_proxy then the QA in HC3 is behaving as expected. You can see this with the test QA below.

    Also, if I am using the Live Server it was almost impossible to make a selection in the dropdown list: I have added in setting.json the line "liveServer.settings.wait": 3000 but it seems not to fix the problem, the list is going back to the previous choice within less than a second (but the proxy does behave correctly).

     

      QA for testing DropDown list:

    if require and not QuickApp then require('hc3emu') end

    --%%name=SelectTypeButton
    --%%type=com.fibaro.deviceController
    --%%manufacturer=christb
    --%%u={label="info0",text="Test for select and multi select buttons"}
    --%%u={{select='selectChange',text='Choosing mode',options={{text='Choosing Change',value='reset'},{text='Manual',value='manual'},{text='Vacation',value='vacation'},{text='Return to Schedule',value='schedule'},{text='Change Schedule settings',value='Auto'}},onToggled='makeChange'}}

    --%%u={{button='b1',text='Reset',onReleased='fReset'},{button='b2',text='Manual',onReleased='fManual'},{button='b3',text='Vacation',onReleased='fVacation'},{button='b4',text='Retur to Schedule',onReleased='fReturnSchedule'},{button="b5",text="Change Sechedule settings",onReleased="fChangeSettings"}}
    --%%u={label="info1",text="Selected Button & Value"}
    --%%webui="install"
    --%%proxy=SelectTest
    --%%remote=devices:*
    local version=0.1 -- created with hc3emu

    --===================================== multilanguage V0.01 =================================
    local Langg={
    ["en"] ={ 

    info0 = "Test Select buttons",
    selectMode="Choosing mode",
    selectManual="Manual",
    selectVacation="Vacation",
    selectSchedule="Return to Schedule mode",
    selectAuto="Change Schedule settings",
    newModeSelected="New mode selected: "   
         },

    ["fr"] ={ 

    info0 = "Test pour bouton Select",
    selectMode="Choisir le mode",
    selectManual="Manuel",
    selectVacation="Vacances",
    selectSchedule="Retour au mode Hedomadaire",
    selectAuto="Modifier les paramètres Automatique"

               }
    }

    local langCode, l = api.get("/settings/info").defaultLanguage
    --print("l: ",l," HC3 language: ",langCode)
    local lang = Langg[langCode] or  Langg["en"]-- default to "en" if unsupported language...

    print(lang.info0..version)
    local select1=lang.selectMode print(select1)
    local select2=lang.selectManual
    local select3=lang.selectVacation
    local select4=lang.selectSchedule
    local select5=lang.selectAuto
    local langChoice={
    {text=select1,type='option',value="reset"},
    {text=select2,type='option',value="manual"},
    {text=select3,type='option',value="vacation"},
    {text=select4,type='option',value="schedule"},
    {text=select5,type='option',value="auto"}
    }
    --print("onInit 2;",select1,"2 ", select2,"3 ", select3,"4 ",select4,"5 ",select5)

     

    function QuickApp:onInit()
        print("QA ",self.name," id:",self.id,", version:",version," started")
        --changing UI following HC3 language --
        self:updateView("b1","text",lang.selectMode)
        self:updateView("b2","text",lang.selectManual)
        self:updateView("b3","text",lang.selectVacation)
        self:updateView("b4","text",lang.selectSchedule)
        self:updateView("b5","text",lang.selectAuto)
        self:updateView("selectChange","options",langChoice)

    print("--onInit() end ----")
    end

    -- the function bellow are for forcing selected value in the dropdown list when pressing one of the 4 buttons

        function QuickApp:fReset()
            self:updateView("selectChange","selectedItem","reset")
            self:updateView("info1","text","b1; reset")
        end

        function QuickApp:fManual()
            self:updateView("selectChange","selectedItem","manual")
            self:updateView("info1","text","b2; manual")
        end

        function QuickApp:fVacation()
            self:updateView("selectChange","selectedItem","vacation")
            self:updateView("info1","text","b3; vacation")
        end

        function QuickApp:fReturnSchedule()
            self:updateView("selectChange","selectedItem","schedule")
            self:updateView("info1","text","b4;"..lang.selectSchedule)
        end
        
        function QuickApp:fChangeSettings()
            self:updateView("selectChange","selectedItem","auto")
            self:updateView("info1","text","b5; "..lang.selectAuto)
        end

     

        function QuickApp:makeChange(ev)
            print("----- fun makeChange() start -----")
            local choice= ev.values[1]
            print("makeChange; Choice: ",choice)
        end

     

  • Topic Author
  • Posted (edited)

    Yes, it's a problem with the drop down menu and live server.

    The problem is that when you click on the menu so it opens, IF it during the time the menu is open re-loads the webpage, there will be no selection.

    Per default, LS is set to reload every 100ms, so it's pretty hard to open and select within 100ms. 

    It's possible to change the reload time in the settings for the plugin, to something like 1000ms, which gives a chance to open and select, but it's not an optimal solution, as everything runs slow...

    At the moment I don't have a solution for this, but I will keep an eye on it....

    The Live Preview plugin don't have this problem as it doesn't reload the page all the time. So there it works ok.

    Note that with the Live Preview you need to have the .html file in the emu directory open in a vscode tab for the preview to automatically update.

    Edited by jgab
    Posted
    9 hours ago, jgab said:

    The Live Preview plugin don't have this problem

    Yes, I have used this preview at the start of development of my QA.

    I have seen that using --%%proxy gives an exact view on the HC3 of how the QA will behave with Select button working as expected, I will use this solution from now on. 

  • Topic Author
  • Posted (edited)
    13 hours ago, Christb said:

    Yes, I have used this preview at the start of development of my QA.

    I have seen that using --%%proxy gives an exact view on the HC3 of how the QA will behave with Select button working as expected, I will use this solution from now on. 

    One of the reasons I started coding hc3emu was to focus on the proxy approach as it was becoming my own preferred way of doing it.

    The emulated web view is just a fall-back for me when I don't have HC3 access. It's also almost impossible to get it 100% correct to how the real UI behaves on the HC3, with all its quirks and bugs... The proxy of course is 100% the correct behavior as it runs on the HC3...

     

    The workflow for me is

    1. Create the first code in vscode, add basic --%%u directives to create som buttons/labels. Run the code so the proxy is created.
    2. Add the --%%logUI=true directive in the code. Every time the code runs it will log in vscode the proxy's current UI as --%%u directives.
    3. Edit the proxy's UI on the HC3 using the UI editor. Rerun the code in vscode and cut&paste the --%%u directives being logged as it is now the real ui description.

    I only need to cut&paste the --%%u directives if the proxy UI is changed... and I know that I-get-what-I-see...

    The emulator will only use the --%%u directives when the proxy is created. After that it's the proxy's UI that is the "master".

    I may add an directive that force update of the proxy's UI from the --%%u directives, but the easiest way is to delete the proxy and just let the emulator re-create it at run.

     

     

     

    Edited by jgab
    • Like 1
    Posted (edited)

    Good morning,

    I've decided to move to the new emulator (mac OS 12.7).

    I've installed brew, luarocks, hc3emu. In brew info: not supported OS - warning about malfunction after installation. In hc3emu install many errors. Install again - less errors, and again: none (???). I have admin rights but have to run installers with sudo.

     

    Not working, even can't open installation directory. I have no idea what can I ask about for help - I'm completely in a dark forest. It's for smarter.

    To be honest the only question I would ask is: I have installed and what's next?

     

    Unfortunately, trusting new emulator setup will be easy on mac, I delete older  fibemu. So I would like to ask: is it old fibemu still available to download and reinstall?

     

     

    Edited by Łukasz997
    Posted

    OK, after many various trials (by a chance) I've come to this:

    [error] myQA/test.lua:1: module 'hc3emu' not found: no field package.preload

    ['hc3emu'] no file '/usr/local/share/lua/5.3/hc3emu.lua' 

    no file '/usr/local/share/lua/5.3/hc3emu/init.lua' 

    no file '/usr/local/lib/lua/5.3/hc3emu.lua' 

    no file '/usr/local/lib/lua/5.3/hc3emu/init.lua' 

    no file './hc3emu.lua' no file './hc3emu/init.lua' 

    no file '/Users/lukasz/.vscode/extensions/tomblind.local-lua-debugger-vscode-0.3.3/debugger/hc3emu.lua' no file '/usr/local/lib/lua/5.3/hc3emu.so' 

    no file '/usr/local/lib/lua/5.3/loadall.so' no file './hc3emu.so'

  • Topic Author
  • Posted

    Why are you running a 4 year old OS?  If you get warnings from brew on not supported OS all bets are off and it won't help if you try to install multiple times...

    You need to install brew - without errors.

    Then use brew to install lua and luarocks without errors.

    You may need to use brew to install openssl (depends on the MacOS version, don't know about 12.7)

    Then use luarocks to install hc3emu without errors.

    Them and only then, can you start to try and use hc3emu in vscode or zerobrane studio.

     

    Yes, fibemu is still available from the github repo in the link in the forum thread about fibemu.

    Posted (edited)

    I'm using 4 years old OS, because it's no newer OS for my computer. 

    I have installed brew without errors - I mentioned about warnings because of not supported OS.
    The errors begins with installing hc3emu.
    luarocks install hc3emu ends with no permissions error (to /usr/local).
    sudo helps with this, still other errors. Run again and it's completed (?)
    And now - as you can see from error messages missing files comes from /usr but also from /Users - why?
    Files should be in 5.3 directory - and I do not have such. I have 5.4 instead...

    Unfortunately, it's can be not so easy on mac.

    OK, thank you, I will try to revert to the old version and stay with it.

    Edited by Łukasz997
  • Topic Author
  • Posted
    10 hours ago, Łukasz997 said:

    I'm using 4 years old OS, because it's no newer OS for my computer. 

    I have installed brew without errors - I mentioned about warnings because of not supported OS.
    The errors begins with installing hc3emu.
    luarocks install hc3emu ends with no permissions error (to /usr/local).

    It looks like your have installed luarocks for 5.3 and lua for 5.4, or vice versa... they don't agree...

    10 hours ago, Łukasz997 said:

    sudo helps with this, still other errors. Run again and it's completed (?)

    Yes, to install lua/luarocks globally you need sudo

    I would be surprised if luarocks install hc3emu return success at this stage.

    10 hours ago, Łukasz997 said:

    And now - as you can see from error messages missing files comes from /usr but also from /Users - why?

    Because you are running the wrong launch.json file to start the emulator. You need the mobdebug task . See instructions in earlier posts.

     

    10 hours ago, Łukasz997 said:

    Files should be in 5.3 directory - and I do not have such. I have 5.4 instead...

    See above

     

    10 hours ago, Łukasz997 said:

    Unfortunately, it's can be not so easy on mac.

    I wondering what brew complains is not supported? Is it luarocks for 5.4, or lua for 5.4?

    You need to have them installed the same version.

     

    10 hours ago, Łukasz997 said:

    OK, thank you, I will try to revert to the old version and stay with it.

     

    Posted

    I've set a clean OS X 12.6 installation as VM on VMware Fusion. And follow the instructions to install hc3emu.
    ssl cannot be installed. Log says (part):

    Please login or register to see this attachment.

     

    hc3emu log says (part):

    Please login or register to see this attachment.

     

    brew warning:

    Please login or register to see this attachment.

     

    So hc3emu maybe won't work on OSX 12.6.

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