Thanks very much Dan!!
Hi Dan,
Action tiles is great, I really wanted the industrial look of the OLEDs BUT the actual functionality of Actiontiles on an old Kindle Fire7 is brilliant. I love that you can make a change on your phone and its instantly updated on the other devices which Iâm going to screw in place to hide the power cable too.
Iâve bought the license.
Thanks again for the recommendation!
Dan.
@Dan_Lumbard - I have finished my initial testing of the change you requested to the IS_DoorControl device. You can now determine in the Arduino Sketch if youâd like the output to behave as a momentary output (default) or as an on/off switch output.
You will need to update a few files which I have uploaded to my GitHub repository.
Arduino ST_Anything library files
- IS_DoorControl.h
- IS_DoorControl.cpp
SmartThings Groovy Device Handler
- Child Door Control
In your existing sketch, you will need to add an additional parameter when creating the device. Here is an example code snippet where the first door control device uses momentary (default, if no parameter is supplied) and the second door control device uses an on/off switch style output.
static st::IS_DoorControl sensor1(F("doorControl1"), PIN_DOORCONTROL_CONTACT_1, LOW, true, PIN_DOORCONTROL_RELAY_1, LOW, true, 1000, 1000);
static st::IS_DoorControl sensor2(F("doorControl2"), PIN_DOORCONTROL_CONTACT_2, LOW, true, PIN_DOORCONTROL_RELAY_2, LOW, true, 1000, 1000, false);
And here is the documentation for all of the parametersâŚ
// Create an instance of this class in your sketch's global variable section
// For Example: st::IS_DoorControl sensor3(F("doorControl1"), PIN_CONTACT_DOOR_1, LOW, true, PIN_RELAY_DOOR_1, LOW, true, 1000, 1000, true);
//
// st::IS_DoorControl() constructor requires the following arguments
// - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
// - byte pinInput - REQUIRED - the Arduino Pin to be used as a digital input
// - bool iState - REQUIRED - LOW or HIGH - determines which value indicates the interrupt is true
// - bool internalPullup - REQUIRED - true == INTERNAL_PULLUP
// - byte pinOutput - REQUIRED - the Arduino Pin to be used as a digital output
// - bool startingState - REQUIRED - the value desired for the initial state of the switch. LOW = "off", HIGH = "on"
// - bool invertLogic - REQUIRED - determines whether the Arduino Digital Output should use inverted logic
// - long delayTime - REQUIRED - the number of milliseconds to keep the output on
// - long numReqCounts - OPTIONAL - number of counts before changing state of input (prevent false alarms)
// - bool useMomentary - OPTIONAL - use momentary output (true) or standard switch (false) (defaults to true)
NOTE for ALL Users: The new groovy Device Handler and Arduino code are somewhat of a matched set. The new Child Door Control DTH should only be used after updating the Arduino code with the new IS_DoorControl.h and .cpp files.
So⌠after a bunch of debugging, I noticed that the version of the st_anything Child dimmer switch device handler that I was checking was in fact not published to my hub. So I was using an old version of that DH. Update that from the current and the world is beautiful again.
Key learning: When you think you have everything up to date, remember that youâre dealing with two different code packages and BOTH have to be up to date. Seems obvious in retrospect. Arduino was good. DH was good, but just not published.
I spent way too much time trying to be smart. 
Hello Dan and happy Monday
i am trying to get this ESP-01 and DHT22 combo to work per your instructions but i am unsure i have done the right copy and paste from your code.
Could you please have a look at it and let me know if i have done it right or wrong i am not that up to speed in coding for Arduino yet 
The ESP connects to the network and communicates with SmartThings i can see it on the IDE
but i am sure i have unnecessary stuff on the code below any help will be greatly appreciated
I know that esp01 is tricky but it is such a nice packaged combo this one it is worth a try
please let me know what you think of the below code
//******************************************************************************************
// File: ST_Anything_Multiples_ESP01WiFi.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 ESP8266-01 (ESP-01) 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 ESP-01's WiFi.
//
// ST_Anything_Multiples implements the following ST Capabilities in multiples of 1 as a demo of what is possible with a single ESP-01
// - 1 x Contact Sensor device (used to monitor magnetic door sensors)
// - 1 x Motion devices (used to detect motion)
//
// Note: The tiny ESP-01 only has 2 GPIO pins, so this example is somewhat limited. Use the ST_ANything_Multiples_ESP8266WiFi.ino example to see
// what else is possible. As long as you only try using 2 pins, you can use them for whatever you'd like.
//
// 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-02-21 Dan Ogorchock New example specifically for running everythin on a ESP-01 (no Arduino required!)
// 2017-04-24 Dan Ogorchock Updated for use with new v2.5 Parent/Child Device handlers
// 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_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 <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
//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************
//#define PIN_MOTION 0
#define PIN_TEMPERATUREHUMIDITY 2
//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid = "grabockanet_2ghz"; // <---You must edit this line!
String str_password = "4697374387"; // <---You must edit this line!
IPAddress ip(192, 168, 1, 99); //Device IP Address // <---You must edit this line!
IPAddress gateway(192, 168, 1, 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, 1, 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, 1, 192); // 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 ESP-01
// 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
static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 0, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22,"temperature","humidity");
//Interrupt Sensors
//static st::IS_Motion sensor1(F("motion1"), PIN_MOTION, LOW, true);
//static st::IS_Contact sensor2(F("contact1"), PIN_CONTACT, LOW, true);
//Executors
//*****************************************************************************
// Configure debug print output from each main class
//*****************************************************************************
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();
}
Thanks again
Denis
Thanks very much Dan. Iâll try this and let you know later in the week when Iâm back from holiday.
The first issue that pops out to me is the following line of code:
//Polling Sensors
static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 0, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22,"temperature","humidity");
change it to the following (note the names at the end of the line must have a numeric suffix)
//Polling Sensors
static st::PS_TemperatureHumidity sensor1(F("temphumid1"), 60, 0, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
Worked like a charm a
Again THANK YOU very much indeed
Any idea if ST Anything will work for the relatively new Arduino Nano 33 IoT?
https://store.arduino.cc/usa/nano-33-iot
I am guessing I could get ST_Anything to run on it, if I had one to test with. I was able to recently add support for the MKR1010 board.
If I had a way to send you one, I would. They are only $20.
Re. the update for the switch input. Iâve changed my code and updated the DH files and my child device. Oddly it now doesnât trigger the relay but you can see that the button press in the app is shown in the logging on the ST IDE website, the status on the button on my phone DOES change if you trigger the door manually though. its just tapping the button in the app doesnât seem to cause the relay flick. The other switch that is not a door control one works fine as before.
Not sure what Iâm missing here!
my code is as follows:
//******************************************************************************************
// File: ST_Anything_GarageDoors_ESP8266WiFi.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_Multiples implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
// - 2 x Door Control devices (used typically for Garage Doors - input pin (contact sensor) and output pin (relay switch)
//
// Change History:
//
// Date Who What
// ---- â ----
// 2019-01-24 Dan Ogorchock Original Creation
//
//******************************************************************************************
//******************************************************************************************
// 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
//******************************************************************************************
//Garage Door Pins
#define PIN_CONTACT_1 D1 //SmartThings Capabilty âDoor Controlâ
#define PIN_SWITCH_1 D2 //SmartThings Capabilty âSwitchâ
#define PIN_CONTACT_2 D3 //SmartThings Capabilty âDoor Controlâ
#define PIN_CONTACT_3 D4 //SmartThings Capabilty âDoor Controlâ
#define PIN_CONTACT_4 D5 //SmartThings Capabilty âDoor Controlâ
#define PIN_SWITCH_2 D6 //SmartThings Capabilty âDoor Controlâ
#define PIN_SWITCH_3 D7 //SmartThings Capability âDoor Controlâ
#define PIN_BUTTON_1 D8 //SmartThings Capabilty Button / Holdable Button (Normally Open!)
//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid = âblahâ; // <âYou must edit this line!
String str_password = âblahâ; // <âYou must edit this line!
IPAddress ip(192, 168, 1, 231); //Device IP Address // <âYou must edit this line!
IPAddress gateway(192, 168, 1, 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, 1, 1); //DNS server // <âYou must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on
// Smarthings Hub Information
IPAddress hubIp(192, 168, 1, 100); // smartthings hub ip // <âYou must edit this line!
const unsigned int hubPort = 39500; // smartthings 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
//Interrupt Sensors
static st::IS_DoorControl sensor1(F(âdoorControl1â), PIN_CONTACT_1, LOW, true, PIN_SWITCH_2, LOW, true, 1000, 1000, false);
static st::IS_Contact sensor2(F(âcontact2â), PIN_CONTACT_2, LOW, true);
static st::IS_Contact sensor3(F(âcontact3â), PIN_CONTACT_3, LOW, true);
static st::IS_DoorControl sensor4(F(âdoorControl2â), PIN_CONTACT_4, LOW, true, PIN_SWITCH_3, LOW, true, 1000, 1000, false);
static st::IS_Button sensor5(F(âbutton1â), PIN_BUTTON_1, 1000, LOW, true, 500);
//Executors
static st::EX_Switch executor1(F(âswitch1â), PIN_SWITCH_1, LOW, true);
//*****************************************************************************
// 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, âOfficeESPâ);
//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);
st::Everything::addSensor(&sensor3);
st::Everything::addSensor(&sensor4);
st::Everything::addSensor(&sensor5);
//*****************************************************************************
//Add each executor to the âEverythingâ Class
//*****************************************************************************
st::Everything::addExecutor(&executor1);
//*****************************************************************************
//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();
}
I am not following⌠Please explain and share screenshots of what youâre seeing. Very hard to troubleshoot otherwise. The issue may be specific to the ST Mobile App, as I only tested these changes on Hubitat, not on SmartThings.
The buttons in the Smartthings app that you tap on also have the status in them. if I tap the button that should trigger switch_2 nothing happens, if I manually trigger the contact that feeds back the state this does correctly update the button to show the open or closed state in the app.
so doorcontrol 1 and 2 both report the state if i physically operate the contact switch on the door but tapping the open button in the app wonât trigger the relay (likewise when its state shows as closed)
This is from the logs on the ST IDE when I tap the button in the app:
adc8662d-2fd0-4041-bd7c-fc4850ae2015 4:23:50 PM: debug Using ip: 192.168.1.231 and port: 8090 for device: adc8662d-2fd0-4041-bd7c-fc4850ae2015
adc8662d-2fd0-4041-bd7c-fc4850ae2015 4:23:50 PM: debug Executing âsendEthernetâ doorControl1 off
4:23:50 PM: debug Using ip: 192.168.1.231 and port: 8090 for device: adc8662d-2fd0-4041-bd7c-fc4850ae2015
adc8662d-2fd0-4041-bd7c-fc4850ae2015 4:23:50 PM: debug Executing âsendEthernetâ doorControl1 off
on the momentary doorcontrol method it works correctly.
Thatâs interesting. As you can see below, the Tile in the Mobile App for the Child Door Control device handler should call âopen()â if the door is currently âclosedâ or âclosingâ. If the door is is currently âopenâ or âopeningâ, the âclose()â command should be called.
multiAttributeTile(name:"door", type: "generic"){
tileAttribute ("device.door", key: "PRIMARY_CONTROL") {
attributeState "open", label: 'Open', action: "doorControl.close", icon: "st.doors.garage.garage-open", backgroundColor: "#e86d13", nextState: "open"
attributeState "closed", label: 'Closed', action: "doorControl.open", icon: "st.doors.garage.garage-closed", backgroundColor: "#00a0dc", nextState: "closed"
attributeState "opening", label: 'Opening', action: "doorControl.close", icon: "st.doors.garage.garage-opening", backgroundColor: "#e86d13", nextState: "closing"
attributeState "closing", label: 'Closing', action: "doorControl.open", icon: "st.doors.garage.garage-closing", backgroundColor: "#00a0dc", nextState: "opening"
}
As you can see, calling those commands will result in either âonâ or âoffâ being sent to the ST_Anything MCU board. What do you see in the Arduino IDE Serial Monitor window? Youâll need to use the contact sensor input to change from âclosingâ to âclosedâ, or from âopeningâ to âopenâ.
// handle commands
def open() {
sendData("on")
}
def close() {
sendData("off")
}
Iâll try to get my ST hub back and up running to test this to see if I have the same problem youâre seeing. Not sure when, though⌠
@Dan_Lumbard - so I am trying to do some testingâŚand I am immediately reminded why I love Hubitat and can no longer tolerate SmartThings!!! Just when I was about to begin the test, the ST cloud took another spectacular dump! 
@Dan_Lumbard - So I was finally able to get ST up and running. Everything works as I expect it to work. I have two doorControl devices in one sketch. One uses momentary and the other holds the output high for âopenâ and low for âclosedâ. I did have to reboot my ST hub to get it to respond correctly (as others have had to do so recently as well.)
Did you remember to publish the new Child Door Control device handler? Are you sure you rebuilt the Arduino sketch and loaded it to your micro-controller once you updated the ST_Anything libraries?
GRRRRRRRRRRRRRRRRRRR.
Iâve spent hours on this, you know what it was? The bloomin nodemcu board must have failed on the output pins. I flashed a new board with the same sketch altered my device with the new MAC address then plugged the new board into the same spot on the breadboard and it worked straight away.
Thanks again Dan!!!
I have successfully implemented a sketch for the multisensor that Ben from Bruh Automation designed based on a NodeMCU board. His implementation was for Home Assistant, but I figured with ST_Anything I could get it to work with ST. Iâll post the sketch here for anyone interested.
Two issues that I am still figuring out though:
- How to have ST display when it has lost connection to the device. Currently, ST just displays the last info received, and there is no indication that the device is not connected anymore.
- How to configure the LED to activate on certain triggers. For example, have the led blink red when motion is detected, go solid green when the temperature is within a certain range, and go blue when rebooting or receiving an update.
Right now the code works. The sensors report and the led is seen as an RGB lightbulb. So I could do some of the triggers as ST routines, but it would be better to have it activate on the device itself, as lag would be minimized.
//******************************************************************************************
// File: ST_Anything_Multiples_ESP8266WiFi.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_Multiples implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
// - 1 x Alarm device (using a simple digital output)
// - 1 x Contact Sensor devices (used to monitor magnetic door sensors)
// - 1 x Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
// - 1 x Motion devices (used to detect motion)
// - 1 x Smoke Detector devices (using simple digital input)
// - 1 x Temperature Measurement devices (Temperature from Dallas Semi 1-Wire DS18B20 device)
// - 1 x Relay Switch devices (used to turn on a digital output for a set number of cycles And On/Off times (e.g.relay, etc...))
// - 2 x Button devices (sends "pushed" if held for less than 1 second, else sends "held"
// - 1 x Water Sensor devices (using the 1 analog input pin to measure voltage from a water detector board)
//
// 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
// 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 <IS_Motion.h> //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor
#include <EX_RGB_Dim.h> //Implements an Executor (EX) for a RGB LED or strip with PWM using 3 digital output pins
//*************************************************************************************************
//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_ILLUMINANCE A0 //NodeMCU ESP8266 only has one Analog Input Pin 'A0'
#define PIN_RGB1_Red D1 // SmartThings Capability "Color Control"
#define PIN_RGB1_Green D2 // SmartThings Capability "Color Control"
#define PIN_RGB1_Blue D3 // SmartThings Capability "Color Control"
#define PIN_MOTION_1 D5 //SmartThings Capabilty "Motion Sensor" (HC-SR501 PIR Sensor)
#define PIN_TEMPERATUREHUMIDITY D7 //SmartThings Capabilty "Temperature/Humidity Measurement" (DHT22)
//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid = "mySSID"; // <---You must edit this line!
String str_password = "MyWiFipw"; // <---You must edit this line!
IPAddress ip(device, ip); //Device IP Address // <---You must edit this line!
IPAddress gateway(gateway, ip); //Router gateway // <---You must edit this line!
IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line!
IPAddress dnsserver(DNS, ip); //DNS server // <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on
// Smarthings Hub Information
IPAddress hubIp(hub, ip); // smartthings hub ip // <---You must edit this line!
const unsigned int hubPort = 39500; // smartthings 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
static st::PS_Illuminance sensor1(F("illuminance1"), 120, 0, PIN_ILLUMINANCE, 0, 1023, 0, 1000);
static st::PS_TemperatureHumidity sensor2(F("temphumid1"), 120, 7, PIN_TEMPERATUREHUMIDITY, st::PS_TemperatureHumidity::DHT22, "temperature1", "humidity1", true);
//Interrupt Sensors
static st::IS_Motion sensor3(F("motion1"), PIN_MOTION_1, HIGH, false);
//Executors
static st::EX_RGB_Dim executor1(F("rgbSwitch1"), PIN_RGB1_Red, PIN_RGB1_Green, PIN_RGB1_Blue, false);
//*****************************************************************************
// 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);
st::Everything::addSensor(&sensor3);
//*****************************************************************************
//Add each executor to the "Everything" Class
//*****************************************************************************
st::Everything::addExecutor(&executor1);
//*****************************************************************************
//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();
}
I am trying to setup a timed relay with a button to change the state of the relay. The application is for a pump. I want to use ST to start and stop the pump in a routine and manually start the pump from the ESP8266 box to avoid the need to have my phone with me. The timerelay sketch and relay button sketch worked well independently. Can I configure either sketch to do what I need or do I need to modify the underlining code?
Chris


