SmartThings integration fails, ValueError: Handler is already defined!

I’m having trouble with a SmartThings integration. I am running a newly installed version of HomeAssistantOS on an rpi4. I started the integration process before I had an external webhook, and the suggested one was on my local network. I aborted the process and set up a nabu casa account. Now when I recreate the process by adding a SmartThings integration, I get an immediate return to the integrations panel.

Here’s the underlying error. How can I clear out the previous integration information? I can’t find any reference to it in the configuration files.

Thanks.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, 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 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 69, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_init
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 67, in async_step_user
    await setup_smartapp_endpoint(self.hass)
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 227, in setup_smartapp_endpoint
    webhook.async_register(
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 36, in async_register
    raise ValueError("Handler is already defined!")
ValueError: Handler is already defined!
1 Like

New to HA and have also misconfigured Smartthings,I’m having exactly the same issue and associated log error… did you manage to resovle.

Cheers.

No resolution. I’m considering wiping and starting over, since I didn’t get too far…

Have the same problem :frowning:

yep, ended up blowing away my config… is now working after following the instructions to the letter… another little trap for newbies is to delete the hidden folders in the config directory… this smart thing is why to smart for me :blush:

would be nice to have an update token script

In my case it was enough to delete

config/.storage/smartthings

and restart HA.

Best,
Philip

6 Likes

Does not work for me. Frustrating too that I can not find a clear fix on this.

2021-04-18 06:08:36 ERROR (MainThread) [homeassistant.components.smartthings.config_flow] API error setting up the SmartApp: {‘requestId’: ‘80526DD3-C49D-46CB-93EE-78AF2821FEEB’, ‘error’: {‘code’: ‘ConstraintViolationError’, ‘message’: ‘The request is malformed.’, ‘details’: [{‘code’: ‘TargetNon200Error’, ‘target’: ‘https://xxx.xxxxxxxx.com/api/webhook/2a1f2b305ff092e762c7ffc6b2472cf2ac52b5be150fd3c7d96a6ac9193a0cc2’, ‘message’: ‘Target did not respond with a 200 status. Upstream status code=403’, ‘details’: []}]}}
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py”, line 130, in async_step_pat
app, client = await create_app(self.hass, self.api)
File “/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py”, line 145, in create_app
app, client = await api.create_app(app)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/smartthings.py”, line 110, in create_app
entity = await self._service.create_app(app.to_data())
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 171, in create_app
return await self.post(API_APPS, data)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 395, in post
return await self.request(“post”, self._api_base + resource, data=data)
File “/usr/local/lib/python3.8/site-packages/pysmartthings/api.py”, line 368, in request
raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {“requestId”: “80526DD3-C49D-46CB-93EE-78AF2821FEEB”, “error”: {“code”: “ConstraintViolationError”, “message”: “The request is malformed.”, “details”: [{“code”: “TargetNon200Error”, “target”: “https://xxx.xxxxxxxx…com/api/webhook/2a1f2b305ff092e762c7ffc6b2472cf2ac52b5be150fd3c7d96a6ac9193a0cc2”, “message”: “Target did not respond with a 200 status. Upstream status code=403”, “details”: []}]}}

I’m having the same issue.
How do you get to
config/.storage/smartthings
To delete it?

This worked for me, I know this post is old, but just found it today. Worked like a champ - after pounding my head into the wall for days!

Deleting config/.storage/smartthings worked for me. I was only able to delete the smartthings file by using sudo through the terminal.

Specs:
Homeassistant Core v2022.7.5 on Debian 11 on Hyper-v

Thank you @philjak. I manually deleted this file and it fixed my SmartThings 500 “ValueError: Handler is already defined!”.