ESP8266 TLS Communication

I would like the esp8266 to be able to update it status and not rely on ST polling. Most code of device types I see for devices that use network communication(particle photon, arduino w/ethernet, esp8266, pi) have to poll the device and parse the data that the device sends. I would like the device to send updates to ST and not rely on polling. If I have a contact sensor for a door I want to know the moment the door opens. This is why I am taking the approach I am using a smartapp.

Edit: I see your post and I’m going to play around with your example and report back.