[OBSOLETE] Smart Sprinkler System

@kmugh I think this is possible without any changes to the Arduino or Device Type, although, there may be some strange side effects. Here is how you could hack a solution together. :smile:

As @d8adrvn mentioned, you would setup a virtual switch following @badgermanus instructions (seen here). This is what I did, following those instructions:

Create the switch device type:

preferences {
    input("num", "number", title: "Switch number", description: "The switch (relay) number to connect to (1 to 8)", required: true)
}

metadata {
    definition (name: "Virtual Switch", author: "you", namespace: "smart things") {
        capability "Switch"
        capability "Momentary"
    }
    
// simulator metadata
simulator {
    status "on":  "command: 2003, payload: FF"
    status "off": "command: 2003, payload: 00"

    // reply messages
    reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
    reply "200100,delay 100,2502": "command: 2503, payload: 00"
}

// tile definitions
tiles {
    standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
        state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
        state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
    }

    standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
        state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
    }

    main "switch"
    details(["switch","refresh"])
}
}
// handle commands
def on() {
	log.debug "On"
    sendEvent (name: "switch", value: "on")
}

def off() {
	log.debug "Off"
    sendEvent (name: "switch", value: "off")
}

Use the IDE to create the device and select this device type.

Create the parent app that ties the v. switch to the Irrigation Controller and makes the switch behave as a momentary (you need to space out the on and off or the Arduino device will lose messages)

definition(
    name: "Virtual Garage Door Switch Parent App",
    namespace: "smartthings",
    author: "you",
    description: "Virtual Garage Door Relay Parent App",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
    
preferences {
	section("Connect this virtual switch to the Arduino's relays") {
		input "switch1", title: "Switch for relay", "capability.switch"
	}
    section("Which Arduino relay board to control?") {
		input "arduino", "capability.switch"
        input "channel", "string", title: "Channel to switch (1 to 8)"
    }
}

def installed() {
	log.debug "Installed with settings: ${settings}"
	subscribe()
}

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	subscribe()
}

def subscribe() {
    subscribe(switch1, "switch.on", on)
    subscribe(switch1, "switch.off", off)
}

def on(evt) {
    log.debug "on($evt.name: $evt.value: $evt.deviceId)"
    arduino."RelayOn${channel}For"(1)
    runIn(10, "switchOff")
}

def off(evt) {
    log.debug "off"
    arduino."RelayOff${channel}"()
}

def switchOff() {
	switch1.off()
}

You should be able to use the new virtual switch in a Garage Door app. I’ve tried this in the IDE. It seems to work. Now, you will see your irrigation device type tile turn on when you open your garage door. This is not ideal, but you could save a little money.