Debug | Creating Drivers for LAN Devices with SmartThings Edge

I am following the tutorial " Tutorial | Creating Drivers for LAN Devices with SmartThings Edge" and can’t seem to get the device registered into the SmartThings app.

I am able to configure and set up the ESP8266 with the app. I am also able to upload the driver to my SmartThings hub. Everything seems to be working until the driver tried to get the device information from the xml file on the ESP device. The ESP seems to “lock-up” after sending the location of the xml file, and therefore it seems that the Edge driver times out and tries to process a NULL message at line 38.

The source is a clone of the SampleDrivers from github

Any help in deeper troubleshooting would be much appreciated.

See logs:

Here is the terminal log from the ESP8266

NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
        branch: release
        commit: f25dc56d3c6213b8ac7ce46d1293466137746eae
        release:
        release DTS: 202112300746
        SSL: false
        build type: float
        LFS: 0x0 bytes total capacity
        modules: file,gpio,http,net,node,pwm2,sjson,tmr,uart,wifi
 build 2022-06-15 21:04 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
> LightBulb ESP8266 App Ready...
> WiFi Access Point enabled...

> service: station
status:  connected
ssid:    XXXXXXXXXX
bssid:   e4:c3:2a:12:7e:92

service:  station
status:   IP Address ready
action:   start UPnP Socket
netmask:  255.255.255.0
gateway:  255.255.255.0
>>> DEVICE AVAILABLE OVER LAN AT: 192.168.1.105

INCOMING TRAFFIC:
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 4
ST: urn:SmartThingsCommunity:device:LightBulbESP8266:1

SSDP RESPONSE:
HTTP/1.1 200 OK
Cache-Control: max-age=100
EXT:
SERVER: NodeMCU/Lua5.1.4 UPnP/1.1 LightBulbESP8266/0.1
ST: upnp:rootdevice
USN: uuid:6003e2-SN-ESP8266-696
Location: http://192.168.1.105:80/LightBulbESP8266.xml


Here is the associated logcat:

connecting... connected
2022-06-15T21:29:36.461603962+00:00 TRACE LAN LightBulb  Setup driver LAN-LightBulb with lifecycle handlers:
DeviceLifecycleDispatcher: LAN-LightBulb
  default_handlers:
    init:
    added:
    removed:
    driverSwitched:
  child_dispatchers:

2022-06-15T21:29:36.465603837+00:00 TRACE LAN LightBulb  Setup driver LAN-LightBulb with Capability handlers:
CapabilityCommandDispatcher: LAN-LightBulb
  default_handlers:
    refresh:
      refresh
    switchLevel:
      setLevel
    colorControl:
      setColor
    switch:
      on
      off
  child_dispatchers:

2022-06-15T21:29:36.473678587+00:00 TRACE LAN LightBulb  Server.new_with
2022-06-15T21:29:36.476659587+00:00 TRACE LAN LightBulb  Server:post
2022-06-15T21:29:36.479638129+00:00 TRACE LAN LightBulb  Server:listen
2022-06-15T21:29:36.498580670+00:00 DEBUG LAN LightBulb  driver device thread event handled
2022-06-15T21:29:36.501626170+00:00 TRACE LAN LightBulb  Received event with handler _resync
2022-06-15T21:29:36.504757920+00:00 TRACE LAN LightBulb  Received event with handler environment_info
2022-06-15T21:29:36.508690920+00:00 TRACE LAN LightBulb  Received event with handler environment_info
2022-06-15T21:29:36.511569129+00:00 DEBUG LAN LightBulb  Z-Wave hub node ID environment changed.
2022-06-15T21:29:36.515362212+00:00 TRACE LAN LightBulb  Received event with handler discovery
2022-06-15T21:29:36.531520170+00:00 INFO LAN LightBulb  ===== SCANNING NETWORK...
2022-06-15T21:29:37.551655254+00:00 INFO LAN LightBulb  ===== DEVICE FOUND IN NETWORK...
2022-06-15T21:29:37.554529796+00:00 INFO LAN LightBulb  ===== DEVICE DESCRIPTION AT: http://192.168.1.105:80/LightBulbESP8266.xml
2022-06-15T21:29:37.557379837+00:00 INFO LAN LightBulb  ===== FETCHING DEVICE METADATA...
2022-06-15T21:29:37.570759671+00:00 ERROR LAN LightBulb  discovery thread encountered error: [string "discovery.lua"]:38: attempt to index a nil value (field 'root')

That example hasn’t been updated for some of the changes required in recent firmware. See the top post in the link below for changes to how socket.http should be pulled in, plus the dkjson library has been changed to st.json.

1 Like

Thanks for the help! I got the sample working, but it still seems finicky. Getting a lot of network errors, and colorControl not working; but that is troubleshooting for another day.

1 Like

Keep up the good work! :+1: Lan drivers are the ones community need right now. Zigbee and Z-Wave devices are covered quite well already.

Hi, @AVGAVR!
Thank you for sharing your experience, I’ll open a report to update that sample.
Let us know if you need any more help. In the case of the colorControl capability, check if you’re receiving an error from the actions in the capability handler:

Thanks, @philh30 for the help as well.

When will this example be updated?
SampleDrivers/lightbulb-lan-esp8266 at main · SmartThingsDevelopers/SampleDrivers · GitHub

It’s been a while after this hub firmware update, but there’s NO reference code for LAN connected devices after this update.

Sorry about that, the team is already working on that. I’ll keep you updated.

1 Like

@philh30, @AVGAVR
The sample was updated according to the requirements of the Hub’s firmware v43.

I made a test and I was able to install the device correctly and send commands.
Please, let me know if you have any questions.