[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

The workaround is working on my V2 hub for me too.

Dan, any idea why the relay switch that in normal operation works with 500ms with the bug present holds the contact much longer (probably3 to 5 seconds)? I thought the timing code did only execute on the esp8266?

Assuming you’re using the TimedRelay device in your sketch, all of the timing is performed locally in the ESP8266. Have you tried restarting the ESP8266 to see if it’s performance improves?

Yes, I tried many power cycles. At first I thought my esp8266 was going bad. I’m using the TimedRelay device and it really baffled me because I remembered that I hard coded the timing and it just worked until this bug happened. Btw, thank you very much for creating this project. I have the esp8266 hooked up to two buttons of my bed frame remote. A short push on button 1 executes the preprogrammed bed position and a long push programs the position the bed is currently in. With the bug it mostly programs the flat position to button 1. Plus the lights on the remote turn on when the button is pushed and flashes differently depending how long the button were pushed. This indicates that it doesn’t release in time. The other button is the flat button and this one only has the long push option. I don’t have button 1 on the esp8266 programmed for a long push, only the flat button is long. But now with the bug all buttons behave like the long timing. Maybe I did something wrong when I modified the sketch one year ago. To be honest I don’t know where my code is right now, quick question: did something major change on this sketch that could explain this? Should I recreate it and load it again? As long as ST fixes the bug it works good, so I probably just wait it out by using the workaround. I just need to remember that I’m using this workaround and this can be difficult if ST takes a long time to address this.

The work around brought my contact sensors back, but now I can only send an open command to my garage door, close no longer works.

Without your sketch, I really can’t explain the behavior your seeing. However, the SmartThings issue should not have an impact on the timing of a timed relay device in ST_Anything.

Let me guess
you updated the ST_Anything Device Handlers, correct? You’ll need to upgrade all of the ST_Anything Arduino libraries and recompile and load the sketch to your micro-controller.

Or, you can revert the changes to the Child Door Control DTH so that it matches your current Arduino sketch.

Yep my bad, that’s what it was. I had updated yesterday thinking that would fix the problems from the FW update. Grabbed the new libraries and everything is back to normal. Thanks for the help!

1 Like

I found the code, there is nothing special as far as I can tell


//******************************************************************************************
// File: ST_Anything_Relays_ESP8266.ino
// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
// Summary: This Arduino Sketch, along with the ST_Anything library and the revised SmartThings
//          library, demonstrates the ability of one NodeMCU ESP8266 to
//          implement a multi input/output custom device for integration into SmartThings.
//
//          The ST_Anything library takes care of all of the work to schedule device updates
//          as well as all communications with the NodeMCU ESP8266’s WiFi.
//
//          ST_Anything_Relays_ESP8266 implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
//            - 3 x Relay Switch devices
//
//
// Change History:
//
//    Date        Who            What
//    ----        ---            ----
//    2015-01-03  Dan & Daniel   Original Creation
//    2017-02-12  Dan Ogorchock  Revised to use the new SMartThings v2.0 library
//    2017-04-17  Dan Ogorchock  New example showing use of Multiple device of same ST Capability
//                               used with new Parent/Child Device Handlers (i.e. Composite DH)
//    2017-05-25  Dan Ogorchock  Revised example sketch, taking into account limitations of NodeMCU GPIO pins
//    2017-11-27  Kai Lenk       Modified to 3 relaySwitch
//    2017-11-29  Dan Ogorchock  Revisions to make sure works for Kai Lenk
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for ESP8266WiFi
//******************************************************************************************
#include <SmartThingsESP8266WiFi.h>

//******************************************************************************************
// ST_Anything Library
//******************************************************************************************
#include <Constants.h> //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library
#include <Device.h> //Generic Device Class, inherited by Sensor and Executor classes
#include <Sensor.h> //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc
)
#include <Executor.h> //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch)
#include <InterruptSensor.h> //Generic Interrupt "Sensor" Class, waits for change of state on digital input
#include <PollingSensor.h> //Generic Polling "Sensor" Class, polls Arduino pins periodically
#include <Everything.h> //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications

#include <PS_Illuminance.h> //Implements a Polling Sensor (PS) to measure light levels via a photo resistor

#include <PS_TemperatureHumidity.h> //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <PS_DS18B20_Temperature.h> //Implements a Polling Sesnor (PS) to measure Temperature via DS18B20 libraries
#include <PS_Water.h> //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector)
#include <IS_Motion.h> //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor
#include <IS_Contact.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_Smoke.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_DoorControl.h> //Implements an Interrupt Sensor (IS) and Executor to monitor the status of a digital input pin and control a digital output pin
#include <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
#include <EX_Switch.h> //Implements an Executor (EX) via a digital output to a relay
#include <EX_Alarm.h> //Implements Executor (EX)as an Alarm Siren capability via a digital output to a relay
#include <S_TimedRelay.h> //Implements a Sensor to control a digital output pin with timing capabilities

//*************************************************************************************************
//NodeMCU v1.0 ESP8266-12e Pin Definitions (makes it much easier as these match the board markings)
//*************************************************************************************************
//#define LED_BUILTIN 16
//#define BUILTIN_LED 16
//
//#define D0 16  //no internal pullup resistor
//#define D1  5
//#define D2  4
#define D3  0  //must not be pulled low during power on/reset, toggles value during boot
#define D4  2  //must not be pulled low during power on/reset, toggles value during boot
//#define D5 14
//#define D6 12
//#define D7 13
//#define D8 15  //must not be pulled high during power on/reset

//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************

#define PIN_TIMEDRELAY_1 D3 //SmartThings Capability "Relay Switch"
#define PIN_TIMEDRELAY_2 D4 //SmartThings Capability "Relay Switch"


//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = "...";                           //  <---You must edit this line!
String str_password = "...";                   //  <---You must edit this line!
IPAddress ip(192, 168, 0, 2);       //Device IP Address       //  <---You must edit this line!
IPAddress gateway(192, 168, 0, 1);    //Router gateway          //  <---You must edit this line!
IPAddress subnet(255, 255, 255, 0);   //LAN subnet mask         //  <---You must edit this line!
IPAddress dnsserver(192, 168, 0, 1);  //DNS server              //  <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on

// Smartthings / Hubitat Hub TCP/IP Address
IPAddress hubIp(192, 168, 0, 3);    // smartthings/hubitat hub ip //  <---You must edit this line!

// SmartThings / Hubitat Hub TCP/IP Address: UNCOMMENT line that corresponds to your hub, COMMENT the other
const unsigned int hubPort = 39500;   // smartthings hub port
//const unsigned int hubPort = 39501;   // hubitat hub port

//******************************************************************************************
//st::Everything::callOnMsgSend() optional callback routine.  This is a sniffer to monitor 
//    data being sent to ST.  This allows a user to act on data changes locally within the 
//    Arduino sktech.
//******************************************************************************************
void callback(const String &msg)
{
//  Serial.print(F("ST_Anything Callback: Sniffed data = "));
//  Serial.println(msg);
  
  //TODO:  Add local logic here to take action when a device's value/state is changed
  
  //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line)
  //st::receiveSmartString("Put your command here!");  //use same strings that the Device Handler would send
}

//******************************************************************************************
//Arduino Setup() routine
//******************************************************************************************
void setup()
{
  //******************************************************************************************
  //Declare each Device that is attached to the Arduino
  //  Notes: - For each device, there is typically a corresponding "tile" defined in your 
  //           SmartThings Device Hanlder Groovy code, except when using new COMPOSITE Device Handler
  //         - For details on each device's constructor arguments below, please refer to the 
  //           corresponding header (.h) and program (.cpp) files.
  //         - The name assigned to each device (1st argument below) must match the Groovy
  //           Device Handler names.  (Note: "temphumid" below is the exception to this rule
  //           as the DHT sensors produce both "temperature" and "humidity".  Data from that
  //           particular sensor is sent to the ST Hub in two separate updates, one for 
  //           "temperature" and one for "humidity")
  //         - The new Composite Device Handler is comprised of a Parent DH and various Child
  //           DH's.  The names used below MUST not be changed for the Automatic Creation of
  //           child devices to work properly.  Simply increment the number by +1 for each duplicate
  //           device (e.g. contact1, contact2, contact3, etc...)  You can rename the Child Devices
  //           to match your specific use case in the ST Phone Application.
  //******************************************************************************************
  //Polling Sensors
  
  //Special sensors/executors (uses portions of both polling and executor classes)
  static st::S_TimedRelay sensor1(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, true, 1000, 0, 1);
  static st::S_TimedRelay sensor2(F("relaySwitch2"), PIN_TIMEDRELAY_2, LOW, true, 4000, 0, 1);


  //*****************************************************************************
  //  Configure debug print output from each main class 
  //  -Note: Set these to "false" if using Hardware Serial on pins 0 & 1
  //         to prevent communication conflicts with the ST Shield communications
  //*****************************************************************************
  st::Everything::debug=true;
  st::Executor::debug=true;
  st::Device::debug=true;
  st::PollingSensor::debug=true;
  st::InterruptSensor::debug=true;

  //*****************************************************************************
  //Initialize the "Everything" Class
  //*****************************************************************************

  //Initialize the optional local callback routine (safe to comment out if not desired)
  st::Everything::callOnMsgSend = callback;
  
  //Create the SmartThings ESP8266WiFi Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, st::receiveSmartString);
 
    //DHCP IP Assigment - Must set your router's DHCP server to provice a static IP address for this device's MAC address
    //st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, serverPort, hubIp, hubPort, st::receiveSmartString);

  //Run the Everything class' init() routine which establishes WiFi communications with SmartThings Hub
  st::Everything::init();
  
  //*****************************************************************************
  //Add each sensor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addSensor(&sensor1);
  st::Everything::addSensor(&sensor2);

      
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
    
  //*****************************************************************************
  //Initialize each of the devices which were added to the Everything Class
  //*****************************************************************************
  st::Everything::initDevices();
  
}

//******************************************************************************************
//Arduino Loop() routine
//******************************************************************************************
void loop()
{
  //*****************************************************************************
  //Execute the Everything run method which takes care of "Everything"
  //*****************************************************************************
  st::Everything::run();
}

Your 2 relays are set to stay on for 1000ms (1s) and 4000ms (4s) respectively
 not 500ms.

Yes you are correct, sorry I didn’t remember correctly. I think at first I had it at 500ms but later I changed it to 1s. It was just working flawlessly for so long that I forgot the details.

Regardles the exact timing values, when the ST bug is present it energizes a lot longer than it’s programmed. From observing it looks like at least 3s or maybe even longer.

I just don’t get it why a network ST issue affects the mc operation in this manner.

If you think it would help your project, I could power cycle my ST hub and recreate the issue on the weekend.

Workaround not working for me. I get blinking blue light as soon as I pull ethernet cable. Waited for 30 seconds and reconnected. Nothing.

@Oldjetdriver: I forced a disconnect/reconnect to your hub which should get received traffic on 39500 going again. Let me know if you still have issues.

1 Like

Thanks. That got it working.

BarryA, Mine is not working after a LAN cable pull, can you do something for me? Do you need my Smarthings account email?

@BarryA It appears I may need a forced disconnect as well. What information do you need?

You should be able to send a disconnect command on your own from the Hub utilities page in the IDE.

1 Like

Thanks I did the reconnect from the IDE page. Now working again.

1 Like

I forced a disconnect from the IDE last night. It didn’t seem to have worked initially but when I got up this morning things were working again.

1 Like

Hi there, I hope I’m in the right place here for solving the issue I’ve run into.

I’ve bought a Z-UNO from zwave.me planning to use it to drive a selection of relays for (primarily) garden irrigation valves. Unfortunately it seems that the basic z-uno device handler will only report the first device to smartthings and all other devices are ignored.

If I understand correctly from browsing this and other threads, it should be possible to integrate ST_Anything with the Z-Uno.

  • Is this correct?
  • What steps do I need to take to do that? Is it entirely on the arduino sketch side, or do I need to also adapt c program files? Do I need to modify the device driver?

A summary of the steps to take would be very helpful - at the very least to determine if I stand a chance in hell of making it work.

Thanks!

1 Like

Unfortunately, no. You cannot use the Z-Uno with ST_Anything. You’re probably going to have to write all of your own Arduino code as well as Z-Wave Device Handlers. Not a trivial task.

Personally, I would return the Z-Uno and simply buy an Arduino MKR WiFI 1010, an Arduino Nano 33 IoT, a NodeMCU ESP8266, or a NodeMCU ESP32 board. All of these are single board solutions that can use ST_Anything to communicate to SmartThings (or my HubDuino to communicate with Hubitat.) These are inexpensive, robust, reliable soultions with ready to run software. Of course, they use WiFi instead of Z-Wave
so that may or may not be a concern for you.

1 Like