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.
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.
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:
My problem, shown below, is the http post in the app\src\server.lua is not executed but times out instead. This is the only piece of the tutorial example code that does not work and it was working back in December. Any idea what changed and how to fix it?
This section of code is supposed to update the device state at ST when a change is made on the ESP8266 web control page.
Sorry for the delay.
Recently, there have been issues with the function register_channel_handler. So, instead of using this one, you need to change it to:
cosock.spawn(function()
local client = serversock:accept()
watch_socket(client)
end)
That helped point me in the right direction. To add it to the tutorial sample I made several
changes. The biggest issue was what is watch_socket? I replaced it as shown and now the http post does not time out and ST updates the light status correctly.
Thanks (I hope the html below renders correctly)
local lux = require(‘luxure’) –rlg local cosock = require(‘cosock’).socket
local cosock = require(‘cosock’)
local json = require(‘dkjson’)
local hub_server = {}
function hub_server.start(driver) --rlg local server = lux.Server.new_with(cosock.tcp(), {env=‘debug’})
local server = lux.Server.new_with(cosock.socket.tcp(), {env=‘debug’})
– Register server
–rlg driver:register_channel_handler(server.sock, function ()
–rlg server:tick()
–rlg end)
cosock.spawn(function() --rlgRTE local serversock = server.sock --rlg added
–rlgRTE local client = serversock:accept()
–rlgRTE watch_socket(client)
while true do –rlgALT
server:tick() --rlgALT
end –rlgALT
end)