[withdrawn]

I got it kind of working by editing the device to put the mac in the device ID. However, the only place I see any response to opening/closing the sensor is by opening the device in the SmartThings API and viewing “list events.” The report changes each time I pull the device pin high or low, but the reported state (open, closed) in the app is unchanged. Here’s what I see in “list events”:
Any advice?

2016-02-22 5:51:59.834 AM UTC moments ago DEVICE index 05, mac Sensor 8266 index is 05, mac

It cycles from 05, mac to 06, mac as the state of the sensor changes. But again, the reported state (open, closed) never changes.

I can access the JSON via http as described in the top comment via(http://:/status).
I’ve added the .groovy as a device by code via graph.Smartthings. Not sure how ST is suppose to find it on the network.
Is anything suppose to be changed in the esp8266 file “SmartThingsContactSensor.ino” ?

==
Ok, so after having added the code to ST as a device handler, then adding the device I selected the generic “open/closed sensor” not realizing to select the title ESP8266 Contact Sensor at the bottom of the list as the device type. So now in my ST app I see the device correctly with the option to add the IP/Port.

Now Serial Monitor via Arduino IDE is repeating
ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
~ld

which looks like its repeatedly rebooting.

================

So does any of the following explictly have to be changed? or is it optional?

const char APPSETTINGS[] PROGMEM = "/appSettings.json";
const char LOADED[] PROGMEM = " loaded: ";
const char HUBPORT[] PROGMEM = "hubPort";
const char HUPIP[] PROGMEM = "hubIp";
const char DEVICENAME[] PROGMEM = "deviceName";

const unsigned int serverPort = 9060; // port to run the http server on

// Smartthings hub information
IPAddress hubIp = INADDR_NONE; // smartthings hub ip
unsigned int hubPort = 0; // smartthings hub port

String deviceName = "ESP8266 Contact Sensor";
const char *OTApassword = "123456"; //you should probably change this…

Hi Charles. Great work!

I’ve added the Device Handler to the IDE. I’ve also added the IP address and port number to the handler.

However, I’m just wondering if using your sketch is mandatory? I’ve got a very basic sketch that uses the following
http://x.x.x.x/pin1/0 for off and /pin1/1 for on. Is this possible to use in your sketch with http posts?

I’d like to avoid using the wifi manager and all the extra because i’ve already set up my ESP8266 and will be expanding upon it, I just need teh SmartThings hub to do some LAN based HTTP requests.

is that possible?

shavelieva,

Having the same problem, did you resolve it?

Thanks

You can get these “arduino sensors” really cheap on ebay or amazon:

Door window reed sensors 10 for ~$10:

Fairly accurate temperature / humidity sensor ~$4:

Water level sensor ~$2:

Gas Sensor ~$2:

PIR motion sensors 5 for $5:

LDR - Light Dependent Resistors 20 for $5

I have purchased all the above (or very similar) and used most of them on my arduinos past couple years. My garage arduino has ESP8266 from adafruit with 2 door, PIR motion, LDR, temp/humid. Just switched to SmartThings so I haven’t gotten them recognized yet.

My other Arduino (actual arduino with ethernet shield) is in basement and monitors sump pump, temp/humid, door, motion. Need to add some water leak sensors to it scattered around the sump pump, water softener, water heater. I think I can do this with a single 2-conductor wire with insulation stripped every foot or so.

I’ll probably go with a NodeMCU (now less than $3 !!!) for #3 so it can be powered with MicroUSB.

1 Like

Withdrawn and github 404’s…? =\

1 Like

I’m not sure how up-to-date this all is as I have switched all my ESP8266 integration over to MQTT using the MQTT bridge as I’ve found it to be more reliable and far more flexible for all sorts of use cases. Moreover, the authors of that bridge don’t seem as inclined to take their ball and go home which is pretty important for my own projects as I don’t want to have to redevelop my own code in response to someone else’s rage against the machine.

Anyway, here’s what I have saved. This was originally released under the Apache License so share and share alike:
SmartThingsContactSensor.ino
esp8266-contact-sensor.groovy

1 Like

I’ve looked into MQTT, but it appears I would need to setup Home Assistant, a local MQTT broker, and the MQTT bridge. And although I do have an extra RaspberryPi that I have thrown Home Assistant on, I still need something to host both the broker and bridge, as I’m assuming I can’t run everything on the Pi, or can I?

Home Assistant is not required, that’s just another tool you can use with MQTT once you have the bridge setup. @xAPPO seems to have had an easy time of getting the bridge running on an rPi so you might want to check out the ThingBox image as it already has an MQTT broker built in.

MQTT is super handy for integrating all sorts of disparate systems. Once you have the MQTT bridge running with SmartThings, you can directly tie that to other platforms like EventGhost, Home Assistant, OpenHAB, etc. Events that happen in one environment can be acted upon in the other environments, providing a “glue” to tie all the systems together. It’s worth looking into and MQTT is dead simple to setup.

1 Like

did you post your mqtt code, or is there a good reference thread? I’m currently trying to get my JSON similar to top of this thread to work.

I wrote up a recent project where I added MQTT/ST support to a tea kettle on another forum here. Source code for that effort is here. The sketch offers WiFi, MQTT, and OTA updates and shows how to subscribe and publish to MQTT.

Hi Luma
I have a question, It is necessary to have the hub v2 or can I use my V1 Hub? Also, do you know if it’s possible to avoid using the hub and communicate directly to the ST CLoude?
Thanks

I don’t see any reason why it wouldn’t work on a v1 hub. The hub is required for any ST use, so I’m not sure how you’d avoid that piece.

I cant see how are you using the hub in your project, I thought that your wemos sent the request directly to your mosquito service that then sent the request to the ST cloud directly without pass trough the hub.
Sorry Im confused now

To get MQTT talking to SmartThings I’m using the MQTT Bridge. Take a look at that code and the install directions and it might become a little more clear. The bridge lets you communicate between ST and MQTT.

Thanks for posting this! I’m connecting some sensors to Adafruit Feather Huzzahs, and this greatly sped up the implementation time.

1 Like

I got it to work but it seem’d flaky, sometimes the status wouldn’t update.

Also, is MQTT dated? Or is it still considered viable?

MQTT is still in wide use for IoT machine-to-machine communication and the major cloud vendors all support it natively, so no problem on that front.

Why was this removed?

There was a bunch of dumb drama a little over a year ago that resulted in several developers pulling their apps.