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 (edited)
On 7/27/2025 at 1:50 PM, jgab said:

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

This issue is happening inside a function and only the lines of code between the end of the 'if condition' and the end of the function. The QA do not crashed and other buttons were still working. 

On 7/27/2025 at 1:50 PM, jgab said:

Is it in the emulator?

Yes it is.

Yesterday evening, I had again a function which has line of codes ignored and this one was working before because it has the local function wich includes previouly ingnored code.

With absolutly no change of any part of the QA code, now, the lines are no more ignored... Strange

Even if I am using  Copilot (super!), the QA is not generating itself corrections when stopped😪.

Attached my QA which can work online in taking your Climate Zones information or offline in readin the json file (attached also).

Note: this QA is still under development an pressing a button not in a logic order may crash the QA: I need to add a some control to prevent that. 

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by Christb
add QA lua file
  • Topic Author
  • Posted (edited)
    On 7/31/2025 at 8:50 PM, Christb said:

    This issue is happening inside a function and only the lines of code between the end of the 'if condition' and the end of the function. The QA do not crashed and other buttons were still working. 

    Yes it is.

    If the crash happens in a callback, like a settimout or setintervall, or http success handler, the whole QA don't stop, just the callback.

    I don't have time right now, away on vacation, too look at your code. try and wrap your callbacks in a pcall to try and catch the error. 

    normally fibemu should catch it an print out the callback error but I'm unsure about ex. http callbacks.

    Edited by jgab
    Posted
    8 hours ago, jgab said:

    I don't have time right now, away on vacation,

    No worries, I can wait until your are back. 

    Enjoy your vacation.

    • 3 weeks later...
    Posted
    On 8/1/2025 at 8:46 PM, Christb said:
    On 8/1/2025 at 12:12 PM, jgab said:

    I don't have time right now, away on vacation,

    No worries, I can wait until your are back. 

    Enjoy your vacation

    Hi @jgab,

    The issue with code following 'if <api error test> then <lines of code> else <lines of code> end' not running is only comming from the test with an api.get error value. I am now using a local variable "line= 200" when HC3 is reachable  or "line=400" when not and now all lines of code are processed.

    Will be good if you can detect this problem in your error management but not mandatory.

     

    For your information, HC3 being offline (PC without any network access) and with this code at the top of the code:

    settings, apiError=api.get("/settings/info")

    print("apiError",apiError,", settings ->", json.encode(settings))

    and launch the QA(F5), I get in the  DEBUG CONSOLE:

     

    -HC3 is not reachable, please check your HC3 URL and network connection (timeout)
    -HC3 URL: http://192.168.1.107/
    -HC3 user: xxxx@zz

    -HC3 password: *************

    -Switching to offline mode
    -Running in offline mode

    HC3Emu - Tiny QuickApp emulator for the Fibaro Home Center 3, v2.0.31
    [11.09.2025][16:23:59][DEBUG  ][EMU]: Proxy devices not supported in offline mode -ignored
    [11.09.2025][16:23:59][DEBUG  ][MANUAL HEATING OVERRIDE5000]: apiError 200 ,settings -> {"newestStableVersion":"5.180.17","installVersion":{"version":"","status":"","progress":0,"type":""},"isFTIConfigured":true,"timestamp":1748181717,"currentVersion":{"version":"5.180.17","type":"stable"},"tosAccepted":true,"softVersion":"5.180.17","zwaveVersion":"4.33","skin":"light","timezoneOffset":7200,"hasFIDConnected":true,"updateStableAvailable":false,"updateBetaAvailable":false,"zigbeeStatus":true,"newestBetaVersion":"5.0.0","timeFormat":24,"decimalMark":".","sunsetHour":"00:00","isSlave":false,"sunriseHour":"00:00","defaultRoomId":219,"date":"16:01 | 25.5.2025","oemId":"HC3","temperatureUnit":"C","zwaveEngineVersion":"2.0","batteryLowNotification":false,"beta":false,"hcName":"HC3-00000000","online":false,"serverStatus":1748004478,"hotelMode":false,"mac":"ac:17:a2:0d:35:e8","serialNumber":"HC3-00000000","skinSetting":"manual","zwaveRegion":"EU","platform":"HC3","dateFormat":"dd.mm.yy","currency":"EUR","defaultLanguage":"en"}
    [11.09.2025][16:23:59][DEBUG  ][MANUAL HEATING OVERRIDE5000]: Language selected:  en ( 200 )

     

    Then the QA crashes as other api.get request are giving a nil value (normal behavior). 

     From where these settings values are comming?

  • Topic Author
  • Posted

    So, the error you have with if-then-else, has nothing to do with if-then-else per se, it must be that in one of the branches you have an error that throws you out of the code.

    I have tried some errors but haven't been able to reproduce it.
    Can you create a minimal QA/lua program, that behaves that way and show me?

     

    If the emulator can't connect to the HC3 (and you have NOT set --%%offline=true)
    then it will assume that there is something wrong with your connection, or credentials, causing the connection to fail.
    It will then log the credentials so you can check them.

    Then it will switch to offline mode (like if you had set --%%offline=true) and try to continue.

    When in offline mode, proxy directive is ignored.

    In offline mode, there are some default values for some of the api calls, like /settings/info

     

    So, HC3EMu is not developed anymore as all my efforts these days go into plua - that's going to be my last emulator :-) 

    Posted
    17 hours ago, jgab said:

    o, HC3EMu is not developed anymore as all my efforts these days go into plua - that's going to be my last emulator

    Thanks for your reply. I am moving now to plua.

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