Simple ESP8266 SmartThings switch

I wanted to write a simple SmartThings device handler for a ESP8266 NodeMCU based switch. I am not a developer and when I look at the many code examples available, I often have trouble figuring what the essential part the code are.

So I tried to write the most basic handler, that can turn on the LED on the EPS8266 NodeMCU using the Smartthings App on my phone and therefore also Amazon Echo. I mostly used code from Charles Schwer (cannot find anymore) and Daniel Ogorchock (https://github.com/DanielOgorchock/ST_Anything) as a guide.

My SmartThings hub and ESP8266 NodeMCU have manually assigned fixed IP addresses. I assigned then in the router.
The portion of the Arduino code that turns on/off the LED can be modified to turn on/off any other Arduino controlled switch.

4 Likes

Hello, I’m trying to use your application but I have the following problem:
The device (in smartthings app) is always ON, and it always send the " off " command.
This is my log:
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:58: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:58: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:58: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:58: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:57: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:57: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:56: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:56: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:56: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:56: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:55: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:55: debug Sending 'off’
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:51: debug Using ip: 192.168.137.197 and port: 9070 for device: 4732acbb-497a-4eb2-97cd-14ca24f53137
4732acbb-497a-4eb2-97cd-14ca24f53137 13:59:51: debug Sending ‘off’

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.