For the last few days I've been playing around with a few different ESP8266 devices using ST_Anything, and it works just fine. I'm interested in playing around with deep sleep capabilities, so I started digging under the covers, particularly using the SmartThingsESP8266WiFi class directly.
I've realized that there is some tribal knowledge that I'm missing.
It is not clear from reading any of the samples I've found, or even going back to the ST DTH docs, how actions I do on the ESP map into the right things in the driver.
I started out by implementing a switch, using the example here: Hubduino Question
No problem. I understand how the Switch capability defines the interface requiring on() and off() methods. But I also noticed that the ESP code sends back a state update like this:
From that I inferred that there is some kind of mapping between the payload of the message being sent and the capability (or attribute?) that is being targeted. So in the case above, it is setting the state of the switch to off.
Is that correct?
If so, then if I want to add the "Contact Sensor" capability, after adding it to the metadata block in the driver, shouldn't I just have to do this in the ESP code?
But clearly I'm missing something here. After adding the capability, I don't see any contact state information in the device page... not at the beginning and also not after sending from the device.
I think what I'm really missing here is an understanding of the message passing / mapping between the hub and the device.
If it would help, I'm happy to post both the sketch and driver code.