I haven’t figured out your approach here, I’ve been using @Jason_Bush’s example. I don’t see where you create a SmartThings endpoint for the ESP8266 to post to?
With Jason’s there is a DH for the whole ESP which creates difficulties handling multiple contact sensors. With yours you have multiple DH plus a smartapp for each ESP. My preference would be to have one DH because in my head I want to hook as many sensors to each ESP as possible
I’m more of an EE / embedded software guy I am not familiar with LUA, I’ve been using Arduino/C on mine.