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)
    1 hour ago, Łukasz997 said:

    Good Morning Jan,

    I have to test an application which perform complex action at the year change.

    I've tried to use

    fibaro.fibemu.setTime(str)

    to simulate nearly and of the year, but it's not working. It seems as setTime is not present in fibaro.fibemu
    What am I doing wrong?

    It's os.setTime
    Ex.
     

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Edited by jgab
    • Like 1
    • Thanks 1
    Posted

    Thank you very much. Now I don't have to wait 11 months... 🙂

  • Topic Author
  • Posted (edited)
    12 hours ago, Łukasz997 said:

    Thank you very much. Now I don't have to wait 11 months... 🙂

    Kind of related to this, the most problematic for me is daylight time savings.

    In my QAs I usually start timers for specific time of days and DST makes those timers miss with an hour...

    My current solution is to restart the QA at DST.

    First I find the DST and then I set a timer to restart the QA at that time... If someone has a better solution let me know...
     

    Please login or register to see this code.

     

    Edited by jgab
    • 2 weeks later...
    Posted

    Good morning,

    here it is a distorted view of QA preview directly after doing in VSC Run task->update QA.

    To fix it it's needed to edit QA and do anything (press space) in code or label description area, save and it revers to normal.

    Nothing major but interesting. By the way you can compare heating gas prices in you country...

    Please login or register to see this image.

    /monthly_2025_02/image.png.e639d67e84132e1b4f8cf0b3ab69e2d5.png" />

    How it should look:

    image.png.f6deac94492b5fb550816ba7bdabdf42.png

     

    • Like 1
  • Topic Author
  • Posted
    21 hours ago, Łukasz997 said:

    Good morning,

    here it is a distorted view of QA preview directly after doing in VSC Run task->update QA.

    To fix it it's needed to edit QA and do anything (press space) in code or label description area, save and it revers to normal.

    Nothing major but interesting. By the way you can compare heating gas prices in you country...

    Please login or register to see this link.

    How it should look:

    Please login or register to see this link.

     

    Cool.

    For any serious UI layout I would use the proxy approach and run the UI on the HC3. The QA UI preview in vscode is not rendered 100% correctly, and allows more html tags/code than the HC3.

    Posted
    2 godziny temu, jgab napisał:

    Cool.

    For any serious UI layout I would use the proxy approach and run the UI on the HC3. The QA UI preview in vscode is not rendered 100% correctly, and allows more html tags/code than the HC3.

    UI in emulator is replicated very closely in my opinion. I'm not sure if I say it clear. This distorted view is from HC3! It happens after using a VSC task "update QA". And disappear when QA is restarted once again (on HC3). I have no idea if "failure" is on the HC3 side or VSC. I've sent it as an "eccentricity" example 🙂

  • Topic Author
  • Posted

    Replaced async_requests (that is being deprecated) with async-asgi-testclient python library.

    Updated requirements.txt and fibnet.py

     

     

    • 2 weeks later...
    Posted

    Dear @jgab,

    just updated fibemu with your last version and get at start (F5) of any QA lua file the following messages:

    Traceback (most recent call last): 

    File "C:\Users\ASUS\Documents\fibemu\.vscode\emufiles\__init__.py", line 6, in <module>

    import fibapi 

    File "C:\Users\ASUS\Documents\fibemu\.vscode\emufiles\fibapi.py", line 20, in <module>

    from fibenv import convertLuaTable 

    File "C:\Users\ASUS\Documents\fibemu\.vscode\emufiles\fibenv.py", line 17, in <module>

    import fibapi, fibnet 

    File "C:\Users\ASUS\Documents\fibemu\.vscode\emufiles\fibnet.py", line 7, in <module>

    from async_asgi_testclient import TestClient ModuleNotFoundError: No module named 'async_asgi_testclient'

     

    I have then run again (in vscode TERMINAL) the 'pip install -r requirements.txt' command  and got another error:

    ---

    Installing collected packages: lupa, websocket_client, Requests, pydantic, paho_mqtt, multidict, uvicorn, starlette, async-asgi-testclient, fastapi
      Attempting uninstall: lupa
        Found existing installation: lupa 2.1
        Uninstalling lupa-2.1:
          Successfully uninstalled lupa-2.1
    ERROR: Could not install packages due to an OSError: [WinError 5] Accès refusé: 'C:\\Users\\ASUS\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\~upa\\lua54.cp311-win_amd64.pyd'
    Consider using the `--user` option or check the permissions.

     

     

    How I can correct these errors??

  • Topic Author
  • Posted

    It's Windows which is not my specialty...

    The last pip install, seems to not have permissions.

    Can you run the pip command with admin rights?

    Do you have the sudo command?

    Or run it from a terminal outside vscode started with admin rights?

     

    Posted
    17 minutes ago, jgab said:

    Or run it from a terminal outside vscode started with admin rights?

    Using PowerShell with admin rights, pip install is finished correctly and QA in fibemu working as previously

    Thanks👍

    • Like 1
    Posted (edited)

    Dear @jgab,

    I am facing an issue using api.put in a QA:

    The code is the following:

    local getClimateZone,e=api.get("/panels/climate/"..ZoneId,"hc3") -- for testing api.put
     
            print("errorGet:",e)
    --         getClimateZone.properties.mode="Off"
             local a,b = api.put("panels/climate/"..ZoneId,getClimateZone,"hc3") --
             
             --local a,b = api.put("/pannels/climate/"..ZoneId,{climZTable],"hc3") --Was OK in ZeroBrane but not in fibemu
             print("updateHC3() 8; ",tostring(a),", errorPut:",b)

     

    and I am always getting an error 501 with api.put as bellow:


    [19.03.2025] [19:54:31] [DEBUG ] [QUICKAPP5000]: errorGet: 200
    [19.03.2025] [19:54:31] [DEBUG ] [QUICKAPP5000]: updateHC3() 8;  nil , errorPut: 501

     

    I think this code was working with your first emulator with ZeroBrane; what I am doing wrong using fibemu?

     
     

     

    Edited by Christb
  • Topic Author
  • Posted (edited)

    Can you do a json dump of the getClimateZone result?

    My suspicion is that the data structure contains an empty array somewhere...

    When json encode a lua table with an empty table, it has to choose if it's going to be encoded as "{}" an empty key-value table, or "[]" as an empty array.

    The climate api has an xml schema for what is an valid input data, e.g if a field is a key-value table or an array, and will reject the call if it's wrong.

    fibemu I think per default encodes empty array as "{}", which I think is the HC3 json behavior too.

    We can change that by marking an empty table as an array, by calling json.util. InitArray (works on the HC3 too).

    Here is a function that traverse a lua structure and marks all empty tables as arrays. If you know exactly what field it is you can of course mark only that...

     

    Try that before putting back the result

    Please login or register to see this code.

     

    No matter what default behavior for json.encoded that is chosen it will be wrong in some cases. fibemu choose to be compliant with the HC3...

    Edited by jgab
    • Like 1
    Posted
    22 hours ago, jgab said:

    Please login or register to see this code.

    Thanks a lot and yes the above function has made the HC3 update to be accepted (api.put returns code 200 and make the Climate Zone to be "Off")

    In fact, there is, in all climate zones of my HC3, a property with an empty array: "incompatibleDevices": [] and I was sending "incompatibleDevices":{}

    Below the json value read for zone Id 1:

    {
      "id": 1,
      "name": "CHAMBRE BEIGE",
      "active": true,
      "mode": "Schedule",
      "properties": {
        "mode": "Off",
        "monday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 22.5
          }
        },
        "tuesday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 22.5
          }
        },
        "wednesday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 22.5
          }
        },
        "thursday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 22.5
          }
        },
        "friday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 23.5
          }
        },
        "saturday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 23
          }
        },
        "sunday": {
          "morning": {
            "hour": 6,
            "minute": 0,
            "temperatureHeating": 16.5,
            "temperatureCooling": 24.5
          },
          "day": {
            "hour": 9,
            "minute": 0,
            "temperatureHeating": 18,
            "temperatureCooling": 24
          },
          "evening": {
            "hour": 17,
            "minute": 0,
            "temperatureHeating": 17.5,
            "temperatureCooling": 24.5
          },
          "night": {
            "hour": 21,
            "minute": 30,
            "temperatureHeating": 16.5,
            "temperatureCooling": 22.5
          }
        },
        "handSetPointHeating": 16.5,
        "handSetPointCooling": 32,
        "handTimestamp": 0,
        "handMode": "Heat",
        "vacationSetPointHeating": 16.5,
        "vacationSetPointCooling": 26,
        "vacationMode": "Heat",
        "vacationStartTime": 0,
        "vacationEndTime": 0,
        "currentTemperatureHeating": 17.5,
        "currentTemperatureCooling": 24.5,
        "currentSetpointTimeStartHour": 17,
        "currentSetpointTimeStartMinute": 0,
        "currentSetpointTimeEndHour": 21,
        "currentSetpointTimeEndMinute": 30,
        "devices": [
          162
        ],
        "incompatibleDevices": [],
        "temperatureSensors": [
          163
        ],
        "currentTemperature": 17.3,
        "calculationStrategy": "avg"
      },
      "created": 1734886491,
      "modified": 1734886491
    }

     

    • Like 1
  • Topic Author
  • Posted

    So,

    Please login or register to see this code.

    would be enough... (the last one just to be on the safe side)

    • Like 1
    Posted
    On 3/20/2025 at 8:59 PM, jgab said:

    (the last one just to be on the safe side)

    To be more safe: I think I need to add also in case of beeing empty;

    Please login or register to see this code.

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