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

Posted
3 hours ago, jgab said:

Try to add http:// in the beginning

The .hc2emu.lua is as below:

return{
    user="*******@orange.fr",
    password="************",
    url="http://192.168.1.107"
}

 

 

Posted
13 minutes ago, Christb said:

Try to add http:// in the beginning

Thanks for your suggestion.

I have found that 'http//:' was missing in the 'launch.json' file located in 'hc3emu-main/.vscode'.

Connection to HC3 is back🙂:

Process started
-Running in online mode
HC3Emu - Tiny QuickApp emulator for the Fibaro Home Center 3, v2.0.27

 

BUT I have lost the proxy feature, the previous QA (id701) was connected to the vscode running QA  but no more interaction 

Also at start of the process, hc3emu2 was detecting it and as you can see above it is no more the case.

the --%%proxy=Manual_Climate_Zone directive is still there: did you change something about proxy?

 

Posted
2 minuty temu, Christb napisał:

the --%%proxy=Manual_Climate_Zone directive is still there: did you change something about proxy?

@jgab said elsewhere that with emu2 proxy looks like:

--%%proxy=true

without a name. Maybe that's why it is not functioning.

  • Thanks 1
  • Topic Author
  • Posted
    1 hour ago, Łukasz997 said:

    @jgab said elsewhere that with emu2 proxy looks like:

    --%%proxy=true

    without a name. Maybe that's why it is not functioning.

    Yep, it changed to just true. The Proxy name will always be <name>_Proxy

    • Like 1
    Posted
    1 hour ago, jgab said:

    Yep, it changed to just true. The Proxy name will always be <name>_Proxy

    Yes working now. I have a new proxi which dialog with vscode.

     

    btw: I have discovered that in UI directives, 

    --%%u={{button="b20",text="weekDay",visible=true,onLongPressDown="",onLongPressReleased="",onReleased="weekDay"},{button="b21",text="Period",visible=true,onLongPressDown="",onLongPressReleased="",onReleased="Period"}}

    is creating an error at startup, "" empty string not accepted.

    So I created a fake function 'fFake' to enter a descriptor as below:

    --%%u={{button="b20",text="weekDay",visible=true,onLongPressDown="fFake",onLongPressReleased="fFake",onReleased="weekDay"},{button="b21",text="Period",visible=true,onLongPressDown="fFake",onLongPressReleased="fFake",onReleased="Period"}}

     

    Posted
    49 minut temu, Christb napisał:

    --%%u={{button="b20",text="weekDay",visible=true,onLongPressDown="",onLongPressReleased="",onReleased="weekDay"},{button="b21",text="Period",visible=true,onLongPressDown="",onLongPressReleased="",onReleased="Period"}}

    Actions with no functions bound to them may be simply omitted in UI description - and there's no error and no need to define "fake" functions.

    • Like 1
    Posted

    Hi again @jgab

    havent had time to use the emulator the latest weeks😅

    And now I get this error from the console when trying to run the "hc3emu2: current file":
     

    Please login or register to see this code.

     

    when trying to run this QA:
     

    Please login or register to see this code.

     

     

    I have used your extension to reset the task and launchfiles in the workspace inside the .vscode folder. 

    I also have updated the .hc3emu.lua and .hc3emu2.lua files to this: 
     

    Please login or register to see this code.

     

     

    I have searched in this topic about the rsrcs and tried diffrent things :D 
    But have to ask the expert for help :D




     

     

     

     

  • Topic Author
  • Posted
    50 minutes ago, Brors94 said:

    Hi again @jgab

    havent had time to use the emulator the latest weeks😅

    And now I get this error from the console when trying to run the "hc3emu2: current file":
     

    Please login or register to see this code.

     

    when trying to run this QA:
     

     

     

     

     

    Ok, it was a long time ago I tested on Windows. It seems to be a bug for Windows introduced when I moved from hc3emu to hc3emu2.

    I pushed v 2.0.30 that should fix it.

    • Thanks 1
    Posted
    24 minutes ago, jgab said:

     

    Ok, it was a long time ago I tested on Windows. It seems to be a bug for Windows introduced when I moved from hc3emu to hc3emu2.

    I pushed v 2.0.30 that should fix it.


    Nice :D It works! :D

    Posted
    34 minutes ago, jgab said:

     

    Ok, it was a long time ago I tested on Windows. It seems to be a bug for Windows introduced when I moved from hc3emu to hc3emu2.

    I pushed v 2.0.30 that should fix it.

     

    seems like this libs inst available in the hc3emu2?
     

    ----hc3emu lib files
    --%%file=$hc3emu.eventlib,Eventlib;
    --%%file=$hc3emu.qwikchild,qwickchild;

     

    Please login or register to see this attachment.

     

    Posted

    %%speed is super. I forgot about it - but now I saved a lot of my time during tests. A lot!

    • Like 1
  • Topic Author
  • Posted
    9 hours ago, Brors94 said:

     

    seems like this libs inst available in the hc3emu2?
     

    ----hc3emu lib files
    --%%file=$hc3emu.eventlib,Eventlib;
    --%%file=$hc3emu.qwikchild,qwickchild;

     

    Please login or register to see this attachment.

     

    They have moved down into a lib directory, and it's hc3emu2 now, so

    Please login or register to see this code.

     

    • Thanks 1
    Posted
    On 6/21/2025 at 9:55 PM, Łukasz997 said:

    Actions with no functions bound to them may be simply omitted in UI description - and there's no error and no need to define "fake" functions.

    In fact, omitting actions without function is only working for 'onLongPressDow' and 'onLongPressReleased', you need to declare 'onReleased' with a function or QA is not starting (error: onReleased is nil).

    When using complexUI with mobile application, it is sometimes preferable to use 'onLongPressReleased' action to prevent user launching an action inadvertently

    The fibaro QA editor authorises to leave blank any of the 3 actions for button.

    If you do so, --%%logui=true is giving onReleased=""  which seems not accepted in hc3emu2 ui declaration: reason of fFake function.

    • Like 1
    • Thanks 1
    • 4 weeks later...
    Posted

    I tryed using your solution for running my QA offline (if fibaro.hc3emu then <read local file> else <api.get("/string")> end😞

    The QA was working almost as if it was doing when onLine but:

     

    1) I have found that if this condition is included inside the QuickApp:onInit() function the QA stops just after the test is completed (online or offline).

    In order to have the rest of the onInit() following lines of code running I had to insert all these additional lines of code in a local function main() and launch main() at the end of then and else codes.

     

    2) When back with online HC3, I had the issue that if fibaro.hc3emu then <read local file> is still true so I cannot read the HC3 data.

     

    So I have now changed online/offline test in checking if api.get error code == 200 then I use the HC3 returned data else I am reading the local json file and now all ok. 

     

    I have almost finished this QA and intend to upload it into my HC3.

    When done, HC3 is always connected to the QA so api error code will be 200 and, normally, the else code will never run. 

     

    Is there a possibility that the else (reading file on my PC) code may be run?

    In this case I suspect that the QA crashes and hope not the HC3: true?

  • Topic Author
  • Posted
    On 7/17/2025 at 6:31 PM, Christb said:

    I tryed using your solution for running my QA offline (if fibaro.hc3emu then <read local file> else <api.get("/string")> end😞

    The QA was working almost as if it was doing when onLine but:

     

    1) I have found that if this condition is included inside the QuickApp:onInit() function the QA stops just after the test is completed (online or offline).

    In order to have the rest of the onInit() following lines of code running I had to insert all these additional lines of code in a local function main() and launch main() at the end of then and else codes.

     

    2) When back with online HC3, I had the issue that if fibaro.hc3emu then <read local file> is still true so I cannot read the HC3 data.

     

    So I have now changed online/offline test in checking if api.get error code == 200 then I use the HC3 returned data else I am reading the local json file and now all ok. 

     

    I have almost finished this QA and intend to upload it into my HC3.

    When done, HC3 is always connected to the QA so api error code will be 200 and, normally, the else code will never run. 

     

    Is there a possibility that the else (reading file on my PC) code may be run?

    In this case I suspect that the QA crashes and hope not the HC3: true?

    This sounds strange. Can you post your :onInit with the test?

    Posted
    6 hours ago, jgab said:

    This sounds strange. Can you post your :onInit with the test?

    I have attached the full vscode lua file if you want to test the on init live (I dont think you need to change any parameter to have it running for you (online or offline))

    Normally there is no more fatal error when using it but full testing not finished and I have still somme parameters changes which are not correctly sent to the HC3.

    My local file is a ClimateZone.json file in which I pasted the result of the swagger API: https://homecenter/api/panels/climate?detailed=true 

     

    Below my onInit() with new and old version of on/offline test

    --================================= On Init ==================================================
        function QuickApp:onInit()
          self.http = net.HTTPClient({timeout=3000})
          self:debug("----- Starting up QA : "..self.name.." - deviceId:",self.id.." ----- Version:"..version)
          self:updateView("info0","text",lang.info0..version.." ->\n ***** QA "..lang.starting.." *****") --hc3emu OK
          self:updateProperty("deviceIcon",1229)
         --        ======================= UI language update =============================
          self:updateView("b1","text",lang.b1txt)
          self:updateView("b2","text",lang.b2txt)
          self:updateView("b7","text",lang.b7txt)
          self:updateView("b8","text",lang.b8txt)
          self:updateView("b9","text",lang.b9txt)
          self:updateView("b10","text",lang.b10txt)
          self:updateView("b11","text",lang.b11txt)
          self:updateView("b12","text",lang.b12txt)
          self:updateView("b13","text",lang.b13txt)
          self:updateView("b14","text",lang.b14txt)
          self:updateView("b15","text",lang.b15txt)
          self:updateView("b16","text",lang.b16txt)
          self:updateView("b17","text",lang.b17txt)
          self:updateView("b18","text",lang.b18txt)
          self:updateView("b19","text",lang.b19txt)
          self:updateView("zoneLabel","text",lang.zoneLabeltxt)
          self:updateView("modeLabel","text",lang.modeLabeltxt)
          self:updateView("b20","text","---")
          self:updateView("b21","text","---")
          self:updateView("info1","text","---")
          self:updateView("info2","text","---")
          self:updateView("b22","text",lang.changeMode)
          self:updateView("b23","text","---")
          self:updateView("b24","text",lang.update)
          self:updateView("selectChange","options",langChoice)
          self:updateView("morningB","value","false") --to reset the 4 Switch buttons
          self:updateView("dayB","value","false")
          self:updateView("eveningB","value","false")
          self:updateView("nightB","value","false")
          self:updateView("selectChange","selectedItem","reset")
        
          --============================= other init actions =====================================
         local wDay = os.date("*t").wday
              --print ("wDay: "..wDay) 
              Jour=Week[wDay]
              --print("Jour : "..Jour)
          currentTimestamp = os.time()
    local function mainOnInit(climateZonesTable--added to have all lines of code after the test 'end' running 
            print("----- mainOnInit() start -----")
            --print("onInit() 18; json.encode(climateZonesTable)->", json.encode(climateZonesTable))
            NbZones = #climateZonesTable
            print("onInit() 19; Nb zones : "..NbZones)
            --print(json.encode(climateZonesTable))
            for k,v in ipairs(climateZonesTable) do
            print("onInit() 20; ",v.id,v.name,v.mode,v.properties.mode,v.properties.currentTemperatureHeating )
            end
            --Setting initial ClimateZone to display
            firstClimateZonesTable=climateZonesTable[1]
            --print("onInit() 21;",json.encode(firstClimateZonesTable)) --for debug only
            self:setVariable("CurrentClimateZoneId",1)
            self:setVariable("NewMode",firstClimateZonesTable.mode) --v3.12
            self:setVariable("ClimateZonesTable",climateZonesTable)
            print("onInit()22; Have updated QuickVarr 'ClimateZonesTable'")
            
            if firstClimateZonesTable.active then State="Active" else State="Inactive" end
            if State=="Inactive" then
              print("onInit() 23; Climate Zone is Inactive, setting 'NewMode' to Off")
              self:setVariable("NewMode","Off")
              self:inactiveUI() --v3.12
              self:resetButton() -- added in v5.0 to suppress error with currentZoneDetail table=null
            elseif State=="Active" then --end
              self:updateView("zoneLabel", "text",lang.zoneLabeltxt.."Id: "..firstClimateZonesTable.id..", "..firstClimateZonesTable.name.."  --- "..State.." ---")
              local txt1=firstClimateZonesTable.mode
              local txt2=firstClimateZonesTable.properties.mode
              print("onInit() 24; mode: ",txt1,", type: ",txt2)
              self:updateView("modeLabel", "text",lang.modeLabeltxt.." "..lang[firstClimateZonesTable.mode]..lang.Type..lang[firstClimateZonesTable.properties.mode])
              self:updateView("selectChangeType","text",lang.selectChangeType)
              self:updateView("currentTempLabel","text",lang.Consigne1..firstClimateZonesTable.properties.currentTemperatureHeating..tempUnit) --
              self:setVariable("NewHConsigne",firstClimateZonesTable.properties.currentTemperatureHeating)
              self:setVariable("NewCConsigne",firstClimateZonesTable.properties.currentTemperatureCooling)
              self:setVariable("NewMode","")
              self:getClimateZoneDetails(1) --added in v7.8
            end
            self:updateView("info0","text",lang.info0..version.." - OK")
          print("---- mainOnInit() end ----")
     end --mainOnInit()
     
          --new version of test for local or remote
        climateZonesTable,online= api.get("/panels/climate")
          if online==200 then
            print("onInit() 15; Climate Zones table read from HC3, online code: ",online)
            mainOnInit(climateZonesTable)
          else
            print("onInit() 15; Climate Zones table read from local file, online code: ",online)
            local f = fibaro.hc3emu.lua.io.open("ClimateZone.json", "r")
            assert(f,"onInit() 2; Couln't open the file")
            climateZonesTable = f:read("*a")
            f:close()
              if climateZonesTable == nil then
                self:debug("onInit() 16; climateZonesTable is nil")
              else
                self:debug("onInit() 17; climateZonesTable is not nil")
                --print("onInit() 18; json.encode(climateZonesTable)->", json.encode(climateZonesTable))
                climateZonesTable=json.decode(climateZonesTable) -- added in v8.8
                mainOnInit(climateZonesTable) -- call main function to set the UI
              end
          end --end test of local or remote
     
          --[[--old version of test of local or remote using fibaro.hc3emu
     
        if fibaro.hc3emu then --We run in the emulator
          print("onInit() 1; We run in the emulator")
          local f = fibaro.hc3emu.lua.io.open("ClimateZone.json", "r")
          assert(f,"onInit() 2; Couln't open the file")
          climateZonesTable = f:read("*a")
          f:close()
       
          if climateZonesTable == nil then
            self:debug("onInit() 3; climateZonesTable is nil")
          else
            self:debug("onInit() 4; climateZonesTable is not nil")
            --print("onInit() 5; climateZonesTable->", climateZonesTable)
            climateZonesTable = json.decode(climateZonesTable)
            NbZones = #climateZonesTable -- OK (16)
            print("onInit() 6; Nb zones : ".. NbZones) --OK (16)
            --print("onInit() 7; json.encode(climateZonesTable)->", json.encode(climateZonesTable))
            mainOnInit(climateZonesTable) -- call main function to set the UI
            return climateZonesTable
          end --]]--
         --return climateZonesTable
         --mainOnInit(climateZonesTable)
        --else -- we run on HC3
          --print("onInit() 8; We run on HC3")  
          --climateZonesTable,f= api.get("/panels/climate")
          --if f ~=200 then print("onInit() 9; error code f: ",tostring(f)) end
          --mainOnInit(climateZonesTable)
          --return climateZonesTable
        --end --old version for test of local or remote
     
        self:updateView("info0","text",lang.info0..version.." - OK")
        print("--------fun onInit end -----------")
          return NbZones, State, langChoice, climateZonesTable
        end
        --
     

    Please login or register to see this attachment.

    Posted (edited)

    Dear @jgab

    in hc3emu2, it seems that when creating a table in html format is not possible using self:updateView("label","txt","<html code>") to update the HC3 proxi label but 

    print(<html code>) is giving a table in DEBUG CONSOLE:

    Dimanche, Jour

    Matin 07 45 20°C 23°C
    Jour 10 30 20°C 24°C

    Soir 19 15 20°C 25°C

    Nuit 21 00 20°C 26°C

     

    Testing the same code in an existing QA of the HC3 is updating the label as a table:

    Please login or register to see this image.

    /monthly_2025_07/image.png.003d1753380087bcc522a37962d675c6.png" />

    Do I have made something wrong in vscode?

    Edited by Christb
    Posted
    On 7/20/2025 at 5:45 PM, Christb said:

    in hc3emu2, it seems that when creating a table in html format is not possible using self:updateView("l

    Sorry @jgab, the fact that the table was not visible was comming from similar issue as the one I found in onInit() - see my previous post.

    I have suppressed the condition if table[1]~=nill then <code> end as the updateView(info1,"text",tbl) line was just after.

    I have now the table shown in the Proxy as below:

    Please login or register to see this image.

    /monthly_2025_07/tbl.png.2a020e0e8bf53b451a0acf155764369b.png" />

     There are a lot of "if then else end" lines of code in my QA but only 2 of them are having this issue.  

    Posted

    This morning, similar issue with no more line of code running at the end of a if <condition> then <code> else <code> end.

     

    A function that worked smothly yesterday, this morning, without any change of the QA code, all lines of  code following a if  *** end are no more run!

    It seems that this issue is with this type of condition:

    currentZoneDetail,online = api.get("/panels/climate/"..zoneId)  -- working when HC3 on line
          if online == 200 then -- We run on HC3
            print("getClimateZoneDetails() 1; connected to HC3")
        else -- We run in the emulator so we will use a local PC file
            print("getClimateZoneDetails() 2; We run in the emulator and read ClimateZone.json file ")
            local f = fibaro.hc3emu.lua.io.open("ClimateZone.json", "r")
            assert(f,"Couln't open the file")
            currentZoneDetail = f:read("*a")
            f:close()
             if currentZoneDetail == nil then
              self:debug("currentZoneDetail is nil")
            else
              self:debug("currentZoneDetail is not nil")
              --print("getClimateZoneDetails(zoneId) 3; currentZoneDetail->", currentZoneDetail)
              currentZoneDetail = json.decode(currentZoneDetail)
              currentZoneDetail = currentZoneDetail[zoneId] -- in order to get the current zone details for the current ID
             
              self:setVariable("CurrentZoneDetail",currentZoneDetail)

     

              print("getClimateZoneDetails(zoneId) 4; json.encode(currentZoneDetail)->", json.encode(currentZoneDetail))
              return currentZoneDetail
            end
          end
    <following lines of code are ignored now>

     

    I have not any clue of what happened from yesterday to this morning:

    Is it a vscode or hc2emu issue; api.get asynchrone issue or bad code from me? 

    The only solution I have found to fix it was to include all following lines of code in a sub function on top of this "if then else end" condition and launch the function inside each of the 2 condition codes, as its last line.

  • Topic Author
  • Posted

    If the code after the last end is ignored, it means that your code within the if-then-else is throwing an error and you exit out if the code you have...
    Is it on the HC3? Then there can be issues if you block of code is called from a timer or http request - not always are the error well reported.

    Is it in the emulator? Then I would like to see the whole QA so I can test and add a better error message for this kind of error in the code.

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