Integration Smartthings fails

Fixed it for me. Thank you so much for posting the linux command line step-by-step. That’s exactly what I was looking for.

I seem to be having the same problem here and have tried all the suggestions from this thread.

I had the integration set up and working but had removed some devices from the smart things integration and they still existed in home assistant, I could not find a way to remove these devices anywhere I searched, found a thread on the forum where people indicated the only real way to remove un-used devices was to remove and re-add the integration so I removed the integration which went fine but when I try to re-add it I get an error reporting “config flow could not be loaded” no matter what I try.

I have removed the left over file from config.storage and have also set the Nabu casa URL up under my external URL but I cannot seem to get past the “config flow could not be loaded” message, tried many reboots too.
image

Checking the log shows this error

Also every so often when I press add integration HA just hangs like this.

I also found steps in the main integration page

initially I was not able to install the ‘pip install hass_smartthings_remove’ application, I kept getting an error reporting failed to build wheel due to multidict error reporting error ‘gcc’ failed with exit status 1

After a bit of research I found that another user had similar issues and fixed them using the following commands

~ $ apk add python3
~ $ apk add python3-dev
~ $ apk add gcc musl-dev
~ $ pip3 install insteonplm (for example)

So after I ran above commands via a putty terminal session to HA I was able to install the removal application, once you install the removal application the instruction is to remove the personal access token using the following command:
hass_smartthings_remove PERSONAL_ACCESS_TOKEN

When I ran this I seem to get a 401 unauthorised error

I am really at a loss here I have spent upwards of 5 hours + trying to rectify this mess and really don’t know what I can do next???

Any help or guidance would really be appreciated

Here is aother error I seem to be getting from the logs:

Logger: aiohttp.server
Source: components/webhook/__init__.py:45
First occurred: 20:37:20 (2 occurrences)
Last logged: 20:52:26

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 92, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 138, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 130, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 197, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 224, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 60, in async_step_user
    await setup_smartapp_endpoint(self.hass)
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 225, in setup_smartapp_endpoint
    webhook.async_register(
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 45, in async_register
    raise ValueError("Handler is already defined!")
ValueError: Handler is already defined!

So no idea how or why but it just started working after hours of trying! happy its working but sad as I dont know why or how!

This was the solution. That file should be removed by default when you remove the integration and I’m not sure why it’s not being done.

Same situation as everyone else, old, orphaned entries were competing with disabled devices (e.g. left_lamp was there and I had left_lamp_2 messing up all of my stuff).

Thanks thats works for me !

Worked perfectly. Thank you!

Worked like a charm … thanks :smile:

Removing the smart things dir and reattempting install worked for me!

Also worked for me! Thank you!

Hi All since few days, my Smarthing integration is not working. Here below is the logs, can someone help me please ?
Many thanks

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 14:54:03 (7 occurrences)
Last logged: 15:00:39

[139642221088704] 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/05b22a3b-b04d-8fc7-9b26-38d05c240598/commands')
[139641665934528] 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/7e3867b5-0e01-4c6a-a0d4-cbf75fa254c2/commands')
[139641665934528] 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/05b22a3b-b04d-8fc7-9b26-38d05c240598/commands')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/switch.py", line 54, in async_turn_on
    await self._device.switch_on(set_status=True)
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/device.py", line 1039, in switch_on
    result = await self.command(component_id, Capability.switch, Command.on)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/device.py", line 842, in command
    response = await self._api.post_device_command(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 147, in post_device_command
    return await self.post(API_DEVICE_COMMAND.format(device_id=device_id), data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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.11/site-packages/pysmartthings/api.py", line 376, in request
    resp.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/05b22a3b-b04d-8fc7-9b26-38d05c240598/commands')