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

    So in the command palette run the command "Python select interpreter"

    That seems to set the pyton.interpreterPath

    It may also solve @Christb problem - select the  interpreter with installed uvicorn...

    Posted
    10 hours ago, jgab said:

    Ok, pushed the changes

     

    Please login or register to see this code.

     

    Let me know if you are missing some functions

    this doesn't work

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2024_02/image.png.75a49513182651a29c2970b33b8d840c.png" />

     

     

     
  • Topic Author
  • Posted
    4 minutes ago, petrkl12 said:

    this doesn't work

    Please login or register to see this code.

    Please login or register to see this link.

     

     

     

    What? Read from the terminal?

    Posted
    2 minutes ago, jgab said:

    What? Read from the terminal?

    yes, I have some choices

    14 minutes ago, jgab said:

    So in the command palette run the command "Python select interpreter"

    That seems to set the pyton.interpreterPath

    It may also solve @Christb problem - select the  interpreter with installed uvicorn...

    I tried but nothing happened

    Are you sure that command is correct?

  • Topic Author
  • Posted
    10 minutes ago, petrkl12 said:

    this doesn't work

    Please login or register to see this code.

    Please login or register to see this link.

     

     

     

    It works if you "Run Without Debugger "

    6 minutes ago, petrkl12 said:

    I tried but nothing happened

    Are you sure that command is correct?

    What is nothing - that the command was not found when running?

    I tried in Win11 - I got the same error, but when I run "python select interpreter" it worked.

    This seems to be a mess...

  • Topic Author
  • Posted (edited)

    I reverted and pushed a launch.json that just runs python3

    Make sure that you pip installed requirements for the global python 3.11 environment that is called when you type python3 in an external shell - or type >Pythin3 in the vscode terminal without an active venv. (it's visible at the left of the terminal prompt (venv) if there is a vent active). To exit the venv type exit, it's like a pushed shell that is exited.

    Edited by jgab
    Posted

    now it works again OK

    Posted (edited)
    1 hour ago, jgab said:

    It works if you "Run Without Debugger "

    It works but only if there is not any breakpoint.

    You can try to add breakpoint to next row and you will see some interesting behaviour.

     

     

    There is also this error during start fibemu

    Please login or register to see this attachment.

    Edited by petrkl12
  • Topic Author
  • Posted
    9 minutes ago, petrkl12 said:

    It works but only if there is not any breakpoint.

    You can try to add breakpoint to next row and you will see some interesting behaviour.

     

     

    There is also this error during start fibemu

    Please login or register to see this attachment.

    Yes, thats a known problem. Sometimes when python is interrupted, it keeps a process that hangs the port.

    You need to kill the process.

    There is a script in examples/kill-port.ps1 for windows and on macOS it's 

    >kill -9 $(lsof -ti :5004)

     

    9 minutes ago, petrkl12 said:

    It works but only if there is not any breakpoint.

    You can try to add breakpoint to next row and you will see some interesting behaviour.

     

     

    There is also this error during start fibemu

    Please login or register to see this attachment.

    Yes, thats a known problem. Sometimes when python is interrupted, it keeps a process that hangs the port. I believe it's uvicorn.

    You need to kill the process.

    There is a script in examples/kill-port.ps1 for windows and on macOS it's 

    >kill -9 $(lsof -ti :5004)

     

    Posted

    OK - for others - in windows 11:

    run PowerShell

    set rights for running script: Set-ExecutionPolicy RemoteSigned

    run script in your folder: .\kill-port.ps1 5004

    result should be: SUCCESS: The process with PID xxxxx has been terminated.

     

    • Thanks 1
  • Topic Author
  • Posted
    16 minutes ago, petrkl12 said:

    OK - for others - in windows 11:

    run PowerShell

    set rights for running script: Set-ExecutionPolicy RemoteSigned

    run script in your folder: .\kill-port.ps1 5004

    result should be: SUCCESS: The process with PID xxxxx has been terminated.

     

    added it as a comment in the script

    Posted (edited)
    13 hours ago, Christb said:

    I have made some progress, I do not have anymore the error message for python3; this result after having desinstalled: python, Git and Visual studio and reinstall all.

    For this new installation, I have followed your video step by step and everything went well and as expected but...

     

    I have now an error when pressing F5 with QA_UI.lua which seems to explain that the server uvicorn is not there:


      File "D:\Mes_documents_perso\St_Loup\St_Loup_Travaux_et_Fournisseurs\Electricit�\Domotique\Domotique_ST_Loup\HC3\Vscode\fibemu\.vscode\emufiles\__init__.py", line 1, in <module>
        import uvicorn
    ModuleNotFoundError: No module named 'uvicorn'

     

    I tried "pip install uvicorn "and get the following

    PS D:\Mes_documents_perso\St_Loup\St_Loup_Travaux_et_Fournisseurs\Electricité\Domotique\Domotique_ST_Loup\HC3\Vscode\fibemu> pip install uvicorn                     
    Requirement already satisfied: uvicorn in c:\users\asus\appdata\local\programs\python\python311\lib\site-packages (0.22.0)
    Requirement already satisfied: click>=7.0 in c:\users\asus\appdata\local\programs\python\python311\lib\site-packages (from uvicorn) (8.1.7)
    Requirement already satisfied: h11>=0.8 in c:\users\asus\appdata\local\programs\python\python311\lib\site-packages (from uvicorn) (0.8.1)
    Requirement already satisfied: colorama in c:\users\asus\appdata\local\programs\python\python311\lib\site-packages (from click>=7.0->uvicorn) (0.4.6)

     

    It seems that uvicorn is installed but not recognised when run from the QA.

    I have found a directory C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvicorn

    Also in Visual Studio uvicorn is shown in directory Packages as below:

    Please login or register to see this link.

     

    Again a path issue? but I don't know how to solve it.

     

     

    @Christb

    Have you added this %USERPROFILE%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts to your path in windows 11 ?

     

    Open the Windows - Setting
    Under System, click on "About"
    Click on "Advanced system settings"
    Click "Environment Variables..."
    The User variables panel shows up on the screen and there is Path (Click)
    Click the New button to add new paths for user

    Add this: %USERPROFILE%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts

    Click "OK"

     

    (

    check if path for Python.3.11 is correct for your enviroment -

    in cmd type

    cd %USERPROFILE%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts

    )

     

     

    Please login or register to see this attachment.

     

    You can also check it via command PATH in cmd.

    Edited by petrkl12
  • Topic Author
  • Posted (edited)
    11 hours ago, petrkl12 said:

    It works but only if there is not any breakpoint.

    You can try to add breakpoint to next row and you will see some interesting behaviour.

     

    If you read the documentation for the "Local Lua Debug" extension used, they say something about Windows can use "communication":"pipes" if they have issue with reading from stdin...

    Edited by jgab
    Posted

    Yes I did and I have checked path:

    Using cmd I am getting the following result:

    C:\Users\ASUS>PATH=
    C:\ProgramData\Oracle\Java\javapath;
    C:\Program Files (x86)\Intel\iCLS Client\;
    C:\Program Files\Intel\iCLS Client\;
    C:\WINDOWS\system32;
    C:\WINDOWS;
    C:\WINDOWS\System32\Wbem;
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files (x86)\Google\Google Apps Sync\;
    C:\Program Files (x86)\Google\Google Apps Migration\;
    C:\Program Files\Intel\WiFi\bin\;
    C:\Program Files\Common Files\Intel\WirelessCommon\;
    C:\WINDOWS\System32\OpenSSH\;
    C:\Program Files\Git\cmd;
    C:\Users\ASUS\AppData\Local\Programs\Python\Python311\;
    C:\Users\ASUS\AppData\Local\Programs\Python\Python311\Scripts\;
    C:\Users\ASUS\AppData\Local\Microsoft\WindowsApps;
    C:\Users\ASUS\AppData\Local\Programs\Microsoft VS Code\bin
    ;

    When I looked to the environment variable I have this:

    Please login or register to see this image.

    /monthly_2024_02/image.png.03de0b0f4f57f52192f2d82ff9798a1d.png" />

    Still the same ModuleNotFoundError: No module named 'uvicorn'

    I changed "c:\users\ASUS\" by "%USERPROFILE%" with no result

  • Topic Author
  • Posted

    Some steps to try/verify.

    1. You use the version of launch.json that just uses "command" : "python3"

    2. Outside vscode, in a command prompt shell or power shell

    2.1 start python3

          >pyton3

    2.2 Inside pythons prompt, run

          >>>import uvicorn

     

    Does the import work without complaining?

    Posted (edited)

    Well, I have a very good news today: the QA_UI.lua is now working perfectly as well as the "

    Please login or register to see this link.

     

    What I have done :

    Desinstall in this order the following programs:

    - Visual Studio

    - Git

    - Phyton

     

    REBOOT the PC

    Suppress files in user directories: \.vscode and \Microsoft Visual Code

    REBOOT the PC

    Reinstall Python 3.11 from Microsoft Store application

    Then following your video, I have reinstaledl everything.

    The important thing to see when you run pip "install -r requirements.txt" are the yellow warning messages which are copied below (easy to miss them as the results are scrollinq quickly):

     

    WARNING: The script chardetect.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script wsdump.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script normalizer.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script uvicorn.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

     

    So I have open the "Environment variables" window and added this missing path and then F5 with QA_UI.lua worked immediatly.

    All my thanks for your support.

    Now I need read all your post and play with fibemu

     

    In the debug console I have 2 messages which are not comming from the QA:

     Unknown event type:     {"data":{"oldValue":22.4,"id":5,"newValue":21.8,"unit":"C"},"sourceType":"system","created":1707232284,"objects":[{"objectType":"climateZone","objectId":5}],"type":"ClimateZoneTemperatureChangedEvent","createdMillis":1707232284092}

    and

    Error: HTTPConnectionPool(host='hc3-00006080', port=80): Read timed out. (read timeout=None)

    Please login or register to see this link.

     

    I am not to worried by the bleu message as it seems to be an information comming from HC3 aboout a climate change temperature but there is not programmed change for zone 5 at that time; I hope it is a change of the mesured temperature.

    The red one is more important: I know that sometimes my HC3 is long to answer to request : is this message reflecting this?

    I had just now this one:


    Connection error: http://hc3-00006080:80/api/refreshStates?lang=en&rand=0.09580020181569104&logs=false&last=7340438
    Exiting refreshStates loop

    Edited by Christb
    add an error message
    • Like 1
  • Topic Author
  • Posted
    2 hours ago, Christb said:

    Well, I have a very good news today: the QA_UI.lua is now working perfectly as well as the "

    Please login or register to see this link.

     

    What I have done :

    Desinstall in this order the following programs:

    - Visual Studio

    - Git

    - Phyton

     

    REBOOT the PC

    Suppress files in user directories: \.vscode and \Microsoft Visual Code

    REBOOT the PC

    Reinstall Python 3.11 from Microsoft Store application

    Then following your video, I have reinstaledl everything.

    The important thing to see when you run pip "install -r requirements.txt" are the yellow warning messages which are copied below (easy to miss them as the results are scrollinq quickly):

     

    WARNING: The script chardetect.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script wsdump.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script normalizer.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The script uvicorn.exe is installed in 'C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

     

    So I have open the "Environment variables" window and added this missing path and then F5 with QA_UI.lua worked immediatly.

    All my thanks for your support.

    Now I need read all your post and play with fibemu

     

    In the debug console I have 2 messages which are not comming from the QA:

     Unknown event type:     {"data":{"oldValue":22.4,"id":5,"newValue":21.8,"unit":"C"},"sourceType":"system","created":1707232284,"objects":[{"objectType":"climateZone","objectId":5}],"type":"ClimateZoneTemperatureChangedEvent","createdMillis":1707232284092}

    and

    Error: HTTPConnectionPool(host='hc3-00006080', port=80): Read timed out. (read timeout=None)

    Please login or register to see this link.

     

    I am not to worried by the bleu message as it seems to be an information comming from HC3 aboout a climate change temperature but there is not programmed change for zone 5 at that time; I hope it is a change of the mesured temperature.

    The red one is more important: I know that sometimes my HC3 is long to answer to request : is this message reflecting this?

    I had just now this one:


    Connection error: http://hc3-00006080:80/api/refreshStates?lang=en&rand=0.09580020181569104&logs=false&last=7340438
    Exiting refreshStates loop

    Ok, ClimateZoneTemperatureChangedEvent is just an event from HC3 that I haven't seen yet. Added it to the source now.

    The connection error / timeout could be that your HC3 is a bit slow. Looking at the code I was a bit aggressive exiting the loop.

    I pushed a new version that is a bit more forgiving...

    Posted (edited)

    Ok, I will update fibemu

    Just a new one: QA_UI.lua (no change done) running I hav frequently the message below:


    [error] .vscode\emufiles\lua\emu.lua:132: bad argument #2 to 'format' (no value)
    stack traceback:
        [C]: in function 'string.format'
        .vscode\emufiles\lua\emu.lua:132: in field 'syslog'
        .vscode\emufiles\lua\refreshState.lua:319: in field 'logEvent'
        .vscode\emufiles\lua\refreshState.lua:328: in field 'newEvent'
        .vscode\emufiles\lua\emu.lua:697: in local 'h'
        .vscode\emufiles\lua\emu.lua:712: in function <.vscode/emufiles/lua/emu.lua:709>

     

    I need to restart the QA.

    I did in fact made an unvoluntary change

    Edited by Christb
  • Topic Author
  • Posted
    13 minutes ago, Christb said:

    Ok, I will update fibemu

    Just a new one: QA_UI.lua (no change done) running I hav frequently the message below:


    [error] .vscode\emufiles\lua\emu.lua:132: bad argument #2 to 'format' (no value)
    stack traceback:
        [C]: in function 'string.format'
        .vscode\emufiles\lua\emu.lua:132: in field 'syslog'
        .vscode\emufiles\lua\refreshState.lua:319: in field 'logEvent'
        .vscode\emufiles\lua\refreshState.lua:328: in field 'newEvent'
        .vscode\emufiles\lua\emu.lua:697: in local 'h'
        .vscode\emufiles\lua\emu.lua:712: in function <.vscode/emufiles/lua/emu.lua:709>

     

    I need to restart the QA.

     

    Thats a bug that appeared when I added the new event. I pushed a fix.

    Posted

    Hey @jgab,

    Don't know what happening, I can use the fibemu in multirootfolder mode, launching via the debug, and but none of the debugging feature,breakpoints, watches, works. 

    Running on windows, so python seems all ok and local lua debugger extension installed. 

     

    Even simpe lua is not debugging. 

     

    Any idea where I should try to seek for the issue

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