What should I be using for the “Device Network Id” of your new device type? I’ve tried the MAC, IP:Port (in hex) and IPPort (also hex). When I attempt to configure the new device I get “An unexpected error occurred”.
Edit: disregard, figured out I needed to edit the device from the Things screen. But… Now I don’t seem to be getting status. I’m probably doing something dumb, I’ll try again in the morning with fresh eyes.
When you first add the device from the IDE you can add whatever placeholder you want for its ID. You then use the “Configure Device” in the app to enter IP and port and click done. Back in the device screen click refresh. This should update the ID to match the device’s MAC and send the hub IP and port to the device.
My strategy of finally going to bed has paid off better than I expected! This morning it’s working with no changes made.
My overall goal here is a “switch” device type that will allow me to actuate a relay (or whatever, just bring a pin high/low), but then also monitor another pin state to detect when the switch (relay, whatever) has been activated locally. Your code is a great starting point, thanks again for your work here!
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)
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.
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.
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.
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?
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.
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 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.