Thanks so much for creating this. I have 6 magnetic reed sensors hooked up to an Arduino Mega. I was able to create more sub tiles using the code that was created. Can anyone tell me how to write the code to allow the sub tiles in the ST Anything Tile to send notifications for each individual sub tile? I am not very familiar with programming. As of right now I am only able to include ST Anything as a whole to send a push notification using a smart app. Here is the code.
/**
*/
metadata {
definition (name: “ST_AnyThing”, namespace: “ogiewon”, author: “Daniel Ogorchock”) {
capability "Configuration"
capability "Illuminance Measurement"
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
capability "Water Sensor"
capability "Motion Sensor"
capability "Switch"
capability "Sensor"
capability "Alarm"
capability "Contact Sensor"
capability “Polling”
command "test"
command "alarmoff"
}
simulator {
}
// Tile Definitions
tiles {
standardTile("water", "device.water", width: 1, height: 1) {
state "dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff"
state "wet", icon:"st.alarm.water.wet", backgroundColor:"#53a7c0"
}
standardTile("motion1", "device.motion1", width: 1, height: 1) {
state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0")
state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff")
}
standardTile("motion2", "device.motion2", width: 1, height: 1) {
state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0")
state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff")
}
standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) {
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
}
standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}
standardTile("contact", "device.contact", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact1", "device.contact1", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact2", "device.contact2", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact3", "device.contact3", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact4", "device.contact4", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("contact5", "device.contact5", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
}
standardTile("alarm", "device.alarm", width: 1, height: 1) {
state "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff"
state "strobe", label:'', action:'alarmoff', icon:"st.secondary.strobe", backgroundColor:"#cccccc"
state "siren", label:'siren!', action:'alarmoff', icon:"st.alarm.beep.beep", backgroundColor:"#e86d13"
state "both", label:'alarm!', action:'alarmoff', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
}
standardTile("test", "device.alarm", inactiveLabel: false, decoration: "flat") {
state "default", label:'', action:"test", icon:"st.secondary.test"
}
standardTile("off", "device.alarm", , width: 1, height: 1) {
state "default", label:'Alarm', action:"alarmoff", icon:"st.secondary.off"
}
//standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat") {
// state "default", label:'', action:"alarmoff", icon:"st.secondary.off"
//}
main(["contact","contact1","contact2","contact3","contact4","contact5","motion1","motion2","alarm","water"])
details(["contact","contact1","contact2","contact3","contact4","contact5","motion1","motion2","alarm","test","off","water","configure"])
}
}
// parse events into attributes
def parse(String description) {
log.debug “Parsing ‘${description}’”
// TODO: handle ‘contact’ attribute
}
def openme() {
log.debug "Virtual Contact Open"
sendEvent(name: “contact”, value: “open”)
}
def closeme() {
log.debug "Virtual Contact Closed"
sendEvent(name: “contact”, value: “closed”)
}
// handle commands
def on() {
log.debug "Executing ‘switch on’"
zigbee.smartShield(text: “switch on”).format()
}
def off() {
log.debug "Executing ‘switch off’"
zigbee.smartShield(text: “switch off”).format()
}
def alarmoff() {
log.debug "Executing ‘alarm off’"
zigbee.smartShield(text: “alarm off”).format()
}
def strobe() {
log.debug "Executing ‘alarm strobe’"
zigbee.smartShield(text: “alarm strobe”).format()
}
def siren() {
log.debug "Executing ‘alarm siren’"
zigbee.smartShield(text: “alarm siren”).format()
}
def both() {
log.debug "Executing ‘alarm both’"
zigbee.smartShield(text: “alarm both”).format()
}
def test() {
log.debug “Executing ‘alarm test’”
[
zigbee.smartShield(text: “alarm both”).format(),
“delay 3000”,
zigbee.smartShield(text: “alarm off”).format()
]
}
def poll() {
//temporarily implement poll() to issue a configure() command to send the polling interval settings to the arduino
configure()
}