Conflicts when 1 Smart App used twice on same device

I’ve written a SmartApp that will flash a light of your choosing as often as you’d like when someone rings your doorbell. I have tested the app and it works fine.

However, I ran into an issue when I installed the same app, for the same doorbell twice. Once for the front door light, once for the back door light. (I want the front light to turn on for a few minutes, but I want the back door light to flash to get my attention if I’m outside when a guest arrives).

The issue is that the calls to turn the light on and off seems to get conflicted. The light that should flash only once, flashes several times, even though the code and settings clearly should only flash it once.

Am I missing some basic check in my code to confirm the device before calling a method to turn it on or off? I don’t understand how having the app installed twice can cause this, but it seems to be the case.


No idea!
'Cause we can’t see your code!

If you post the code then someone might spot something :slight_smile:

1 Like

Sure, I was asking in general, if there was some reason the same app could conflict with another instance.

Here is my code:

name: “Doorbell Flash Notification”,
namespace: “rjison9000”,
author: “Robert Ison”,
description: "When someone rings the bell of your Ring doorbell, a light of your choosing will flash. It will end up in the same state as it started. Enter 1 for flashes, it’ll just turn on and off over the time you’ve selected. Enter 0 for flashes, it’ll stay on for the number of minutes you select, then turn off regardless. ",
category: “My Apps”,
iconUrl: “”,
iconX2Url: “”,
iconX3Url: “”)

preferences {
section(“Ring Doorbell”) {
input “ringbutton”, “capability.button”, required: true, title: “Select your Ring doorbell?”

section("How many times do you want the light to flash?") {
    input "flashes", "number", required: true, title: "Number of Flashes?"

section("How many minutes should the light flash?") {
    input "minutes", "number", required: true, title: "Number of Minutes?"

section("Light to Flash") {
    input "theswitch", "capability.switch", required: true


def installed() {

def updated() {

def initialize() {
subscribe(ringbutton, “button”, ringDetectedHandler)
log.debug “Initialize”

void ringDetectedHandler(evt) {
log.debug "ringDetectedHandler"
def switchState = theswitch.currentState(“switch”)
//log.debug "switchState.value $switchState.value"
def switchlevelState = theswitch.currentState(“level”)
//log.debug “switchlevelState.value $switchlevelState.value”

def currentTotalDelay = 0
def switchStartedOn = switchState.value == 'on'

if (flashes == 0){
	flashes = 1
    switchStartedOn = false;

// Let's calculate this AFTER we turn a values of 0 flashes to 1
def millisecondDelay = Math.round((minutes * 3000 ) / flashes)

if (evt && evt.value && evt.value == 'pushed'){
    for (int i = 0; i < flashes; i++){
        log.debug "Flash " + i + " of " + flashes + ". (Delay: " + currentTotalDelay + " ms)"
        if (switchStartedOn){
            log.debug "OFF"
  [delay: currentTotalDelay])
            currentTotalDelay += millisecondDelay
        log.debug "ON"
        theswitch.on([delay: currentTotalDelay])
        currentTotalDelay += millisecondDelay
        if (!switchStartedOn){
            log.debug "OFF"
  [delay: currentTotalDelay])
            currentTotalDelay += millisecondDelay