veista / smartthings

A fork of the Home Assistant SmartThings Integration. This adds better support for Samsung OCF Devices.
172 stars 40 forks source link

Token renewal #65

Closed LeChat109 closed 1 year ago

LeChat109 commented 1 year ago

i have a problem, my token has expired (for some reasons idk) and i can't find a way to renew it without completely uninstall the add-on and re-install it and in the process, i lose all my config.

the problems occurs when i restore a backup of my system or when i restore a backup of the add-on.

thx in advance for the help 😄

veista commented 1 year ago

You should not lose your config, if you reinstall.

LeChat109 commented 1 year ago

it's not exactly my "config" it's the devices that i disable and the devices names.

veista commented 1 year ago

You probably will have to name them again if you have changed the names. If you did not rename the unique id:s all other configs should be fine.

LeChat109 commented 1 year ago

Yeah but I have a lot of AC and it's the 7th time I've done it.

I wanna find an easier way to do it

veista commented 1 year ago

You can change the device names from the smartthing api website. I don't rename them other than that. Translations of entities are not yet supported in HA if that is why you rename them.

LeChat109 commented 1 year ago

Ok, I do it but can you make something to renew this access because the problem exists

veista commented 1 year ago

If you have to recover from backup, it is likely the authorization to the api goes bad. I'm not sure, but you could maybe use custom translations on HA level.

LeChat109 commented 1 year ago

I think it's the token that changes sometimes for security and if I restore an older version of the add-on, it sends an old token

veista commented 1 year ago

I think it's the token that changes sometimes for security and if I restore an older version of the add-on, it sends an old token

This is my understanding yes.

spanzetta commented 1 year ago

Have the same issue.. How to renew the token?

LeChat109 commented 1 year ago

Unfortunately, you can't.

You have to delete the add-on and re-configure it.

LeChat109 commented 1 year ago

Until an update

spanzetta commented 1 year ago

Ok.. good to know.. Will do that way Many thanks

spanzetta commented 1 year ago

Tried to setup it again but it always fails with a generic error..

veista commented 1 year ago

@spanzetta Remove the tokens from your smartthings mobile app and try again.

@LeChat109 The token expiring is something I can do nothing about. You can try the official integration if you have better luck with that.

spanzetta commented 1 year ago

I did it already.. remove current token and create a new one.. but get always the error (pls try again).. I also tried to remove the Hacs custom integration to use the original Smartthings integrated but again.. same error! Any idea how to solve?

veista commented 1 year ago

Make sure your ha instance is connectable from the internet and your ssl certificates are working. Follow the instructions from the official integration and make sure everything works.

spanzetta commented 1 year ago

It is connectable.. and everything else works.. here is the error I get with the token

image

image

spanzetta commented 1 year ago

@spanzetta Remove the tokens from your smartthings mobile app and try again.

It is already removed by SmartThings Mobile app.. :-(

spanzetta commented 1 year ago

This seems to be the error.. Anyone can guide me how to fix it/understand the cause of the error?

Logger: homeassistant.components.smartthings.config_flow Source: components/smartthings/smartapp.py:176 Integration: smartthings (documentation, issues) First occurred: 13:23:50 (3 occurrences) Last logged: 17:46:13

API error setting up the SmartApp: {'requestId': '160A574A-E27A-4BF5-9FF1-DFFEAB699145', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'PatternError', 'target': 'targetUrl', 'message': 'targetUrl is malformed.', 'details': []}]}} API error setting up the SmartApp: {'requestId': '42420777-D6B9-44C9-AFC8-3C9801416702', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'PatternError', 'target': 'targetUrl', 'message': 'targetUrl is malformed.', 'details': []}]}} API error setting up the SmartApp: {'requestId': 'AA3F565B-728D-4C95-A07A-2DB85A758162', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'PatternError', 'target': 'targetUrl', 'message': 'targetUrl is malformed.', 'details': []}]}} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 104, in async_step_pat await update_app(self.hass, app) File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 176, in update_app await app.save() File "/usr/local/lib/python3.10/site-packages/pysmartthings/app.py", line 349, in save response = await self._api.update_app(self._app_id, self.to_data()) File "/usr/local/lib/python3.10/site-packages/pysmartthings/api.py", line 179, in update_app return await self.put(API_APP.format(app_id=app_id), data) File "/usr/local/lib/python3.10/site-packages/pysmartthings/api.py", line 399, in put return await self.request("put", self._api_base + resource, data=data) File "/usr/local/lib/python3.10/site-packages/pysmartthings/api.py", line 368, in request raise APIResponseError( pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "160A574A-E27A-4BF5-9FF1-DFFEAB699145", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "PatternError", "target": "targetUrl", "message": "targetUrl is malformed.", "details": []}]}}

veista commented 1 year ago

I think you would get better support on the official HA repo.

spanzetta commented 1 year ago

solved.. the config for duckdns was missing some parameters.. and even if it was working (the external access).. the smartthings integration would not complete the configuration without that parameters..

veista commented 1 year ago

As of the latest HA release the support for entity translation is made available. This would fix your issue when implemented. You could also make your own translation to keep the custom entity names intact.

LeChat109 commented 1 year ago

Ok, thanks, I haven't had the problem again since.