DewGew / DZGA-Flask

Domoticz Google Assisting using Flask
GNU General Public License v3.0
8 stars 4 forks source link

Problem migrating from DZGA to DZGA-Flash with Google connection #113

Open xvisor16 opened 1 month ago

xvisor16 commented 1 month ago

Hi I am having difficulties migrating. First of I tried migrating since DZGA stopped working yesterday and I saw 403 and 404 errors in the log. Did some searching and suggestions were to update DZGA. Only then I found out it's archived so saw the new DZGA-Flask solution. I disabled DZGA and installed DZGA-Flask as per Wiki.

Now with Google Assistent disabled I see and can use all my devices in the Dashboard and Device overview. I created a new key for my existing project and uploaded it and used the same clientid and secret as used in DZGA. But if I enable Google Assistent and try to sync my devices I get this error:

Starting new HTTP connection (1): 192.168.68.97:80
http://192.168.68.97:80 "GET /json.htm?type=command&param=getversion HTTP/1.1" 200 328
Starting new HTTPS connection (1): homegraph.googleapis.com:443
https://homegraph.googleapis.com:443 "POST /v1/devices:requestSync HTTP/1.1" 404 None
Traceback (most recent call last):
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/werkzeug/middleware/proxy_fix.py", line 182, in __call__
    return self.app(environ, start_response)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/root/DZGA-Flask/modules/api.py", line 152, in gateway
    rs.call_homegraph_api('sync', {"agentUserId": flask_login.current_user.username})
  File "/root/DZGA-Flask/modules/reportstate.py", line 111, in call_homegraph_api
    r.raise_for_status()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://homegraph.googleapis.com/v1/devices:requestSync
If I try to test from Google Actions it says it can't reach my home and the log says:
Traceback (most recent call last):
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/werkzeug/middleware/proxy_fix.py", line 182, in __call__
    return self.app(environ, start_response)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/root/DZGA-Flask/smarthome.py", line 278, in fulfillment
    user_id = flask_login.current_user.username
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/werkzeug/local.py", line 311, in __get__
    obj = instance._get_current_object()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/werkzeug/local.py", line 515, in _get_current_object
    return get_name(local())
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask_login/utils.py", line 25, in <lambda>
    current_user = LocalProxy(lambda: _get_user())
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask_login/utils.py", line 372, in _get_user
    current_app.login_manager._load_user()
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask_login/login_manager.py", line 378, in _load_user
    user = self._load_user_from_request(request)
  File "/root/DZGA-Flask/env/lib/python3.9/site-packages/flask_login/login_manager.py", line 441, in _load_user_from_request
    user = self._request_callback(request)
  File "/root/DZGA-Flask/smarthome.py", line 77, in request_loader
    if user.username:
AttributeError: 'NoneType' object has no attribute 'username'

I've tried creating 2 new projects, actions and keys as per Wiki but still the same error :( What did I miss or am I running into a bug?

Regards Peter