bramkragten / lyric

Add support for Honeywell Lyric thermostats in Home Assistant
MIT License
13 stars 18 forks source link

broken with .110 #8

Open thedude0101 opened 4 years ago

thedude0101 commented 4 years ago

worked great until .110 when home assistant depreciated base_url. not sure how to transition to the new get_url at: https://developers.home-assistant.io/docs/instance_url/

plum59 commented 4 years ago

Hello I confirm, i need help to

I give you some logs :+1:

Error during setup of component lyric Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request url, http_method=method, body=data, headers=headers File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token raise TokenExpiredError() oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component component.setup, hass, processed_config # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/lyric/init.py", line 135, in setup setup_lyric(hass, lyric, config) File "/config/custom_components/lyric/init.py", line 98, in setup_lyric hass.data[DATA_LYRIC] = LyricDevice(hass, conf, lyric) File "/config/custom_components/lyric/init.py", line 148, in init if not lyric.locations: File "/usr/local/lib/python3.7/site-packages/lyric/init.py", line 864, in locations if (self._locations): File "/usr/local/lib/python3.7/site-packages/lyric/init.py", line 808, in _locations new_value = self._get('locations') File "/usr/local/lib/python3.7/site-packages/lyric/init.py", line 754, in _get client_secret=self._client_secret) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 543, in get return self.request('GET', url, kwargs) File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 497, in request self.auto_refresh_url, auth=auth, **kwargs File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 446, in refresh_token self.token = self._client.parse_request_body_response(r.text, scope=self.scope) File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response self.token = parse_token_response(body, scope=scope) File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response validate_token_parameters(params) File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in validate_token_parameters raise MissingTokenError(description="Missing access token parameter.") oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

teunehv commented 4 years ago

Same issue here. So I removed the lyric.conf file and tried again. But some problems with the base_url.

I updated the init.py file https://github.com/bramkragten/lyric/blob/383e45ebb375d026355e7ed5a9dae0bdf6ea34ab/custom_components/lyric/__init__.py#L125

to: redirect_uri = conf.get(CONF_REDIRECT_URI, hass.config.internal_url +

But now I get the following error during the authentication process: `Logger: aiohttp.server Source: custom_components/lyric/init.py:199 First occurred: 10:06:04 AM (1 occurrences) Last logged: 10:06:04 AM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start resp = await task File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle resp = await handler(request) File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 125, in handle result = await result File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 120, in coro res = func(*args, **kw) File "/config/custom_components/lyric/init.py", line 199, in get data = request.GET AttributeError: 'Request' object has no attribute 'GET'`

any idea @bramkragten

thedude0101 commented 4 years ago

I also added at the top: from homeassistant.helpers import network

I think it is needed for the new get url call, but now I get:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component component.setup, hass, processed_config # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/lyric/init.py", line 127, in setup '/api/lyric/authenticate') TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

thedude0101 commented 4 years ago

also changed: redirect_uri = conf.get(CONF_REDIRECT_URI, hass.config.internal_url + to redirect_uri = conf.get(CONF_REDIRECT_URI, hass.config.external_url + '/api/lyric/authenticate')

it seems to be working!?

teunehv commented 4 years ago

also changed: redirect_uri = conf.get(CONF_REDIRECT_URI, hass.config.internal_url + to redirect_uri = conf.get(CONF_REDIRECT_URI, hass.config.external_url + '/api/lyric/authenticate')

it seems to be working!?

I got stuck at the same moment with the same error. After approving the app it ends up in a 500 error with the message from my previous post.

plum59 commented 4 years ago

hello i succeed to reinstall my thermostat :

plum59 commented 4 years ago

Hello,

i had do :

Delete all lyric folder in component and custome component i use virtual studio code to search and suppress all mention of lyric in ha folder for example i have one file in .storage\hacs whitch had delete and one part of file in .storage\hacs.repositories

after i had reboot home assistant

take all file of this repo https://github.com/home-assistant/core/tree/92082b687a46c17a9a94a598b245728a8832b179/homeassistant/components/lyric

Put it in custom_components\lyric\ folder

add this in my config file :

Thermostat Honeywell lyric: client_id: !secret lyric_client_id client_secret: !secret lyric_client_secret

create on honeywell developer a callback with this url : https://yourbaseip:8123/auth/lyric/callback where "yourbaseip:8123" is my base_url or (external url)

create secret with api identification restart home assistant

go in integration menu click + search for honeywell lyric , install it and i will redirect on hneywellsite to login me , and after it is done

plum59 commented 4 years ago

i hope it help you

teunehv commented 4 years ago

Yes, great... it's working again.

I had to update the https://github.com/home-assistant/core/blob/92082b687a46c17a9a94a598b245728a8832b179/homeassistant/components/lyric/config_flow.py

line 58: self.hass.config.api.base_url, AUTH_CALLBACK_PATH) changed to self.hass.config.internal_url, AUTH_CALLBACK_PATH)