dstrigl / HtREST

Heliotherm heat pump REST API server
Other
11 stars 0 forks source link

Error in getting timeprogram #275

Open kevin-kling opened 12 months ago

kevin-kling commented 12 months ago

Hi, thank you very much for writing this tool. Makes my old heatpump kind of smart :)

Works great - I'm only having troubles reading and possibly writing (not tested yet) the timeprogram using: /api/v1/timeprog/

Error message: { "message": "get() got an unexpected keyword argument 'id'" }

I'm not really sure how to troubleshoot that issue.

If someone has a solution I would be really happy because I'm trying to let the heatpump run when the PV produces enought energy - which is not working without these commands :)

BTW: Needed to use flask version 2.3.3 because the newest version is making troubles as well. Maybe the error is connected to that.

dstrigl commented 12 months ago

Have you tried to execute it in the Swagger UI at http://192.168.11.90:8777/api/v1/? (replace IP address by yours)

kevin-kling commented 12 months ago

Thank you for your help :) Swagger UI opens - but when I try to input the value it gives me a red sign during mouse over - so I can't input the id. Btw this happens in every input field in SwaggerUI - ID, name, ....

dstrigl commented 12 months ago

Which version of HtREST are you using? Looks like a problem with Flask ...

kevin-kling commented 12 months ago

I'm using HTRest 0.1.11

I updatet my packages: No I got this error again which I initally fixed using flask 2.3.0:

2023-10-06 10:11:23,301 INFO [htrest.app|create_app]: open connection to heat pump (<htheatpump.htheatpump.HtHeatpump object at 0x7646ecb8>) 2023-10-06 10:11:23,356 INFO [htrest.app|create_app]: successfully connected to heat pump #140491 2023-10-06 10:11:23,422 INFO [htrest.app|create_app]: software version = 3.0.20 (8744) 2023-10-06 10:11:23,450 INFO [htrest.app|create_app]: *** created Flask app <Flask 'htrest.app'> with config <Config {'DEBUG': False, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None, 'SECRET_KEY': None, 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(days=31), 'USE_X_SENDFILE': False, 'SERVER_NAME': None, 'APPLICATION_ROOT': '/', 'SESSION_COOKIE_NAME': 'session', 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_SECURE': False, 'SESSION_COOKIE_SAMESITE': None, 'SESSION_REFRESH_EACH_REQUEST': True, 'MAX_CONTENT_LENGTH': None, 'SEND_FILE_MAX_AGE_DEFAULT': None, 'TRAP_BAD_REQUEST_ERRORS': None, 'TRAP_HTTP_EXCEPTIONS': False, 'EXPLAIN_TEMPLATE_LOADING': False, 'PREFERRED_URL_SCHEME': 'http', 'TEMPLATES_AUTO_RELOAD': None, 'MAX_COOKIE_SIZE': 4093, 'SWAGGER_UI_DOC_EXPANSION': 'list', 'RESTX_VALIDATE': True, 'RESTX_MASK_SWAGGER': False, 'ERROR_404_HELP': False, 'BUNDLE_ERRORS': True}> Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/flask_restx-1.1.0-py3.9.egg/flask_restx/api.py", line 18, in from flask.helpers import _endpoint_from_view_func ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (/home/admin/.local/lib/python3.9/site-packages/flask/helpers.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/htrest", line 33, in sys.exit(load_entry_point('htrest==0.1.11', 'console_scripts', 'htrest')()) File "/usr/local/lib/python3.9/dist-packages/htrest-0.1.11-py3.9.egg/htrest/main.py", line 178, in main app = create_app( File "/usr/local/lib/python3.9/dist-packages/htrest-0.1.11-py3.9.egg/htrest/app.py", line 87, in create_app from htrest.apiv1 import blueprint as apiv1 File "/usr/local/lib/python3.9/dist-packages/htrest-0.1.11-py3.9.egg/htrest/apiv1.py", line 26, in from flask_restx import Api File "/usr/local/lib/python3.9/dist-packages/flask_restx-1.1.0-py3.9.egg/flask_restx/init.py", line 2, in from .api import Api # noqa File "/usr/local/lib/python3.9/dist-packages/flask_restx-1.1.0-py3.9.egg/flask_restx/api.py", line 20, in from flask.scaffold import _endpoint_from_view_func ModuleNotFoundError: No module named 'flask.scalffold'

This fix seems not to work anymore

Even though, the following packages are installed: Flask==3.0.0 Flask-BasicAuth==0.2.0 Flask-Helper==2.1.1 Flask-Migrate==4.0.5 Flask-RESTful==0.3.10 flask-restx==1.1.0 Flask-Scaffold==0.5.1 Flask-Script==2.0.6 Flask-SQLAlchemy==3.1.1

dstrigl commented 12 months ago

Have you tried any of the sollutions here? https://stackoverflow.com/questions/67496857/cannot-import-name-endpoint-from-view-func-from-flask-helpers-in-python

Maybe "pip install Flask-RESTful==0.3.9" will help?!

kevin-kling commented 12 months ago

I already tried these workarounds but not really working. I tried to flask.scaffold working but it seems really old having a look on the dependecies.

Found no Flask-Restful version that would be working