Repeat rule until change

Yes. That should work.

I don’t know your comfort level but if you’re interested, there are also context variables available for use that slightly speed up rule execution because it doesn’t have to pull the actual devices status.

Right now… comfort level is about a 1. I just started using Sharptools 2 days ago. I am very comfortable using variables, expressions, etc. in WebCoRe, but this is just a bit different. I’m sure in time, I’ll get there. Thanks for your help!!!

No problem. Let me know if you need more help.

1 Like

So this is an old thread, but I used this to create a looping rule to watch a door lock being left unlocked for 10 minutes and send a message. Problem is, the lock is reporting back it is locked after it gets unlocked and I’m very confused. I checked the logs and it is reporting that it failed to match the if criteria and goes to the else. I viewed that it is reporting this:

[
{
“type”: “state”,
“subtype”: “device”,
“data”: {
“platform”: “samsung-smartthings”,
“locationId”: “98fbb808”,
“deviceId”: “cee2d65e”,
“attribute”: “lock”,
“state”: {
“attribute”: “lock”,
“value”: “locked”,
“timestamp”: “2023-02-14T19:15:28.133Z”,
“isStateChange”: null
}
}
}
]

I’m not sure if there is a huge delay in reporting, but the lock change triggers the rule, so that is also confusing to me. The lock icon changes on the smartthings app, too. Or am I missing something obvious in my rule set up.

Thanks for any thoughts.

Maybe this is part of my problem? SmartThings Status - SmartLock & SmartLock Guest Access Migration

For the IF condition, if you are trying to use the state from the lock/unlock event to update a variable, I would recommend using Context Variables → Event → Device → Value.

The condition would end up looking something like:

IF $context.event.value is ‘unlocked’
THEN …

This avoids any potential issues where SmartThings might have issued the event for your lock saying it was unlocked, but the state didn’t get updated yet. This can happen for a number of reasons - sometimes it’s just a simple race condition where the event is sent across and triggers the rule before SmartThings has updated their database. Or as you alluded to, in this case it could also be SmartThings bigger issues with some of their recent Edge Driver / Platform updates.

1 Like

Thanks @josh, that worked like a charm!

1 Like

So I set up a check to see if my door remains unlocked after 10 minutes and send an sms and announce on my echo device, too. I also set up a manual suppression of those alerts by utilizing a virtual switch and auto resume alerts after one hour. If anyone is interested in seeing how I did that, let me know and I’ll take screenshots of the rules and post them.

1 Like

I’m interested in seeing a screenshot of :point_up_2: this part, Thanks

Rule 1: The check rule is triggered when the door is locked or unlocked. I had to use the context value to get the lock state after the trigger event in the if statement because my lock was returning a locked state even after it was locked. Thanks to @josh for this tip!

I added a couple of virtual devices to get this all to work using this: [ST Edge] Virtual Hub Kit [BETA] - Community Created Device Types - SmartThings Community

I needed a virtual sensor to trigger Alexa and a virtual switch to trigger the reminder suppression.

Rule 2: The reminder loop checks the virtual switch to see if it should suppress the notifications, and sends a sms and triggers Alexa by changing the virtual sensor to open and then back to close. I had to use all lowercase when syncing the state of the virtual sensor or it threw an error.

Rule 3: Because an Alexa routine won’t trigger on a switch, I had to use a virtual sensor here. I have Alexa announce the door is unlocked when the virtual sensor opens.

@Paul_Paul here is where the suppression starts, but is integrated in previous rules…

Rule 4: When I turn on the virtual switch, it changes a variable for rule 2 so the notifications don’t go out. It also sends me an sms that tells me when the notifications will automatically resume, one hour from now. If the switch is set to off, it sends me an sms to tell me that. I trigger the switch in the Smartthings app.

Rule 5: When the suppression virtual switch has been on for an hour, it triggers this rule and the virtual switch is turned off which triggers a sms to tell me so.

Let me know if anyone has questions, I hope this helps @Paul_Paul

1 Like

Wow, Thanks for a great writeup

I must admit I’ve read through it 4 or 5 times to get my head around it

Detailed explanations like this are a massive help for understanding complex rules

1 Like

You’re most welcome. Let me know if I can help when you go to set up your own rule.

3 Likes

In this example. If the goal was to do this for all windows and doors, would you have to have a variable for each window and door?

For the entire rule, I think you would need individual variables for each physical sensor and timestamp.

However, I could see having a single switch to suppress all alerts for all sensors. If you gave us some what-ifs we might be able to brainstorm a little. I have two doors set up this way and wrote a set of rules and variables for each.

1 Like