Duplicate Notifications

Hi guys,

I’m new to SharpTools having recently arrived from WebCore land. I’m in the middle of migrating my logic over the SharpTools and have come across a strange issue with duplicate Pushover notifications from a single event.

The rule I’m noticing this issue on is detecting the arrival of my wife (when she arrives home I’m notified twice). The way this particular logic works is:

  1. ST app on wife’s iPhone is setup as presence sensor with automation to turn a simulated switch on when she arrives home, and off when she leaves home.
  2. SharpTools uses the simulated switch as a trigger and sets a variable to TRUE when the simulated switch turns on, and FALSE when the simulated switch turns off. Logging shows that this runs twice.
  3. SharpTools sends a notification (to both of us) saying ‘arrived’ when the variable changes to TRUE, and ‘departed’ when the variable changes to FALSE.

I had the same behaviour (double notification) when the notification was tied to state of the switch. I thought the switch might be double-bouncing so thought I’d tie the notification to the state of the variable (thinking that something can’t become TRUE or FALSE twice in a row).

Other notifications from other pistons are only coming through once, and I’ve also sent a test message from the Pushover dashboard which again comes through once.

Any help would be appreciated.

PRESENCE DETECTION:

PRESENCE ACTIONS:

SMARTTHINGS IDE reports only a single event:

and if I check the SmartThings notification log on my phone again I see a single event:

With a normal “changes” trigger, the rule is still triggered each time the variable value is set.

If you use a state-stays trigger, it will “debounce” the event and only trigger when the state changes to your desired state.

I suspect the underlying source of the problem is probably the Simulated Switch though. Other people have run into this where their simulated switch is generating two events - keep in mind that the Groovy IDE doesn’t reflect the same events that SmartThings ultimately passed across to their ‘new’ platform. If you view the details of the triggering log entry in SharpTools and look at the event ID, you’ll see that there’s a different event ID for each rule trigger (sometimes the IDs are only a few characters different, sometimes they are completely different).

There are alternative approaches including changing to a different Simulated Switch. If you’re still using a Groovy Simulated Switch, you might want to consider switching to one of the many Virtual Edge Drivers. From what I recall, the people that were seeing this issue were still using Groovy DTHs - I suspect there’s a quirk internally with SmartThings when they hand off an event between their legacy Groovy platform and their next-gen platform that causes the duplication. Either way, Groovy is dying soon, so I would look for an alternative.

Another approach would be to use a condition when setting the variable. For example, in your rule that’s reacting to the Virtual Switch changing, you would have an IF Condition that checks if the variable is already true - if it’s already true do nothing, otherwise set it to true.

Thanks Josh,

I tried both ‘state stays’ and the adding an IF statement but unfortunately I’m still getting duplicate notifications.

I then created a fresh edge virtual switch and it works properly now (single notification when virtual switch and variable change state).

Thanks for your help :slight_smile:

Glad to hear that helped.

I would have needed to see the full set of rules (eg. the rule that’s sending the notification). If the other rule was triggered off the $AndyPresent changing and being true, in theory it should have worked. But it’s not clear where that variable was getting reset and how the other rule was being triggered based off this screenshot alone.

Either way, glad the change to an Edge Driver got things sorted for you. :slight_smile:

1 Like