LAN Edge device is not created in hub after successful discovery

Hi!

A few years ago, I developed an EDGE driver to control my security system from the LAN. It has been working well all this time. Recently, I made some changes to the code to improve certain aspects. However, the code related to the discovery or creation of the device was not modified.

I decided to retest the integration and reinstall it in my hub. It didn’t go as planned.

When I tried to remove the device or uninstall the driver using smartthings/cli, I received the following axios error: Error: Request failed with status code 500: unsuccessful-http-call status=500.

So I used the web interface (Samsung account) to manually remove the device and the driver, also unsubscribing the channel.

Since then, when I try to reintegrate the device into SmartThings, it is not created. I can integrate the driver and perform the discovery, but no devices are being added, and the added or init events are no longer triggered. Here’s an example of the commands.

The discovery is called and seems to be working well, and driver:try_create_device() returns a success (1).

2024-10-16T12:26:52.189018753Z TRACE Interlogix NetworX NX-595E  Setup driver interlogix-networx-nx-595e with lifecycle handlers:
DeviceLifecycleDispatcher: interlogix-networx-nx-595e
  default_handlers:
    driverSwitched:
    init:
    removed:
    added:
  child_dispatchers:

2024-10-16T12:26:52.194871169Z TRACE Interlogix NetworX NX-595E  Setup driver interlogix-networx-nx-595e with Capability handlers:
CapabilityCommandDispatcher: interlogix-networx-nx-595e
  default_handlers:
    chime:
      chime
      off
    doorControl:
      open
      close
    refresh:
      refresh
      disarm
      armStay
      armAway
  child_dispatchers:

2024-10-16T12:26:52.217690419Z INFO Interlogix NetworX NX-595E  Created dispatcher [SecretDataDispatcher]interlogix-networx-nx-595e that had no handlers
2024-10-16T12:26:52.279856044Z TRACE Interlogix NetworX NX-595E  Setup driver interlogix-networx-nx-595e with Secret Data handlers:
SecretDataDispatcher: interlogix-networx-nx-595e
  default_handlers:
  child_dispatchers:

2024-10-16T12:26:52.294795836Z INFO Interlogix NetworX NX-595E  interlogix-networx-nx-595e driver started...
2024-10-16T12:26:52.304221045Z TRACE Interlogix NetworX NX-595E  Received event with handler driver_lifecycle
2024-10-16T12:26:52.308756128Z INFO Interlogix NetworX NX-595E  received driver startupState: {"hub_zigbee_id":"xxxx","hub_node_id":1,"hub_ipv4":"xxxx"}
2024-10-16T12:26:52.326046670Z TRACE Interlogix NetworX NX-595E  Received event with handler discovery
2024-10-16T12:26:52.356400711Z INFO Interlogix NetworX NX-595E  Starting Interlogix NetworX NX-595E Discovery
2024-10-16T12:26:52.364834878Z INFO Interlogix NetworX NX-595E  Metadata: {device_network_id="C0A8020A:0253", label="Security system", manufacturer="Simon Hebert", model="Interlogix NetworX NX-595E", profile="interlogix-networx-nx-595e.v1", type="LAN", vendor_provided_label="Alarm system"}
2024-10-16T12:26:52.376074128Z INFO Interlogix NetworX NX-595E  try_create_device success: 1
2024-10-16T12:26:52.380592211Z DEBUG Interlogix NetworX NX-595E  discovery device thread event handled
2024-10-16T12:27:49.793086468Z TRACE Interlogix NetworX NX-595E  Received event with handler discovery
2024-10-16T12:27:49.863791135Z TRACE Interlogix NetworX NX-595E  Received event with handler driver_lifecycle

Does anyone have any ideas or could help identify the issue?

I’ve tried removing everything, recreating everything, restarting the hub, and researching the topic, but nothing works.

Thank you!

1 Like

How does the driver communicate with the device? HTTP(S)-Requests? If yes, luasocket/luasec?

The LAN device is a web REST API interface. Nothing has changed in this aspect since the beginning though.

cosock/socket.http is used for requests.

local cosock = require "cosock"
local http = cosock.asyncify "socket.http"

Thanks

1 Like

Do a lot of log.info() in and around your requests, especially the very first.

Start the logcat and keep it running for longer (5 minutes).

I think there’s a problem with the sockets, timing, timeouts that affects other drivers as well.

See this comment, the issues on GitHub and the code that could fix it:

That looks odd to me, in that securitySystem capability commands without default handlers are listed as if they are part of the default handler for the refresh capability.

I haven’t seen the driver start up sequence for a while though so maybe looking odd is perfectly correct.

Thank you for your response.

What bothers me a bit is that this code (sockets) isn’t executed until the device is initialized, and added/init hasn’t been called yet when the discovery ends because the device isn’t added to the hub.

Since my code hasn’t been modified in this regard, I think this issue comes from the SmartThings platform configuration because, despite all the debugging I’ve done, it doesn’t point to the code. The removal of an old Edge/LAN device that caused 500 errors with smartthings/cli makes me suspect this.

1 Like

You’re right that the capability commands are very strange and don’t represent what’s declared in the code and in the profile file, I hadn’t noticed that. This points even more to a SmartThings platform configuration issue.

I simply recompiled/reinstalled the same driver code last night, and the problem mysteriously disappeared since then. I had done that many times the previous day without success. I also changed the device_network_id once again, but I had tried that before as well.

I think the old driver or the previous device was still ‘stuck’ somewhere. Now it’s working, at least for the moment.

Thank you all for your quick and helpful responses!