Rule Trigger - only when mode = "home" (not necessarily changes TO home)

I have started to move my existing rules from webCoRE and re-creating them in the Rule Engine.

This was my existing webCoRE code that I am trying to replicate;

(Switch 5 is a virtual switch that I use during the kids holidays so that the two switch’s stay on permanently all the while we are at home)

What i have tried to re-create in rules;

However, i don’t seem to be getting any logs so the rules would appear not to be triggering.
I don’t know if it is my triggers, as the rule is only supposed to work when the mode is “home” as well when the mode changes to “home”


I believe it is only when the mode is switched to home will it trigger. So either you need to have it loop or add additional triggers. Possible both.

You can trigger a loop by setting the home mode to home again at the end of you action statement.

This is one of the differences between WebCoRE and SharpTools. With SharpTools, you specify which events you want to trigger the rule in the Triggers section.

I didn’t use WebCoRE, but from what I gather, it’s loosely equivalent to your IF lines with lightning bolts next to them.

So if you want the rule to be triggered by the switches changing (or time events), you would want to add those to the Triggers section.

@BeardedTechGuy put together a nice video for WebCoRE users transitioning to SharpTools Rules with some of the things he learned / experienced:

It doesn’t look like your new SharpTools Rule Flow mirrors your WebCoRE rule.

Your new SharpTools rule is using the ELSE path for the first IF Condition (which you weren’t doing in WebCoRE) and is always turning on the switches in that case.

Furthermore, the IF condition is doing the same thing as it’s ALL of the listed conditions in the block that must be matched… the order of the conditions and them being near each other doesn’t impact anything. So you have two date related conditions, but those aren’t going to be paired up with the time condition near them. Instead ALL of the conditions will be evaluated and combined in your current layout.

It might be helpful to describe in words what you’re trying to accomplish though, so we can better point you in the right direction.

For example, some people find it easier to use the new Expressions feature to create complex compound conditions where they need to compare multiple subsets of conditions together.

Please don’t do this. Without delays in a rule, that would cause an infinite loop and would hit rate limits.

In this particular case, since you’re using a ‘state stays’ condition on the mode rather than just the mode changing, it won’t retrigger the rule if the mode gets changed to the same value again.

Good to know. I have a couple rules that use this but they do use a wait. It is however used to reset a sharptools variable and the rule is trigger by the variable. If I remember correctly the rates for calls in the ST API is 12 per min up to 60 per minute depending on what type of call is being used. So yeah, Listen to josh.

OK thanks. Some useful info there.

What I am trying to accomplish is;
I have 2x sockets that are only supposed to be switched on between 07:30 and 20:30 during the school week so they then effectively turn off on school nights (Monday to Thursday) @ 20:30 before bed and not turn on until the following morning.
This timer is only supposed to work when the hub is in “home” mode and if the virtual switch, which i have called “holiday mode” is turned OFF.
During the school holidays I then turn ON the “holiday mode” virtual switch which then ensures the sockets stay on all the time.
I use the “home” mode so it would force the sockets OFF when i change the mode to “away” but whenever we arrive back home and the mode changes to “home” then the sockets turn back on and resume their schedule (depending on the virtual switch) i.e. If the virtual switch is off and the mode is “home” and this happens at say 13:00 during the school week, then the sockets would turn on but if we arrived home at say 21:00 during the school week then the socket would NOT turn on.

I hope i have tried to explain it well enough :slight_smile:

Would i have been better to do it this way but then i still have the same problem that conditions won’t be paired and ALL of the conditions will be evaluated and combined?:

Thanks for the explanation. That certainly helps clarify what you’re trying to do!

I think one piece that was (and is?) throwing me off is I don’t see anywhere in your WebCoRE piston where you were turning things off.

Yes, it’s a step in the right direction, but as it is pictured, that rule will only be triggered when the Mode changes to Home. I think there’s two mental hurdles in translating this. In this example, the triggers and the conditions in the WC piston are effectively the same, so it’s accomplished with a single top-level IF condition. The other one is how time triggers vs conditions work in SharpTools. You can easily build a combined date/time trigger, but in conditions they are separate components so the compound statement gets a bit verbose to setup.

Personally, I think this rule would be easier to model broken down into individual parts. You could create a rule based on the combined triggers to flag whether or not you are in the ‘TV Allowed During School Week’ timerange:

Note that I’m using an arbitrary time between 7:30 am and 8:30pm as the IF Condition to determine if it’s the morning or evening trigger

Alternative approach with Expressions (tap to expand)

You could also just use a single expression in the flow rather than the IF condition as it’s effectively the same thing.

Or even apply the same conditional time range again (the 30 is implicit based on the trigger, but you could add it in if you really wanted):

From there, you could mimic your existing WebCoRE rule as follows:

Based on your description, it sounds like you might want the ‘turn off’ part of things added to the rule too. And from what you described, I believe you would need to add a nested condition in the ELSE path of the first IF condition (rather than just adding the ‘off’ commands there directly) as you don’t want the TV to turn off when it’s Holiday time.

Edit: One other thing - I would add a Mode tile to a dashboard to make sure the event subscriptions for modes are setup. There’s a known bug where the mode event subscription isn’t automatically setup in the next-gen SmartThings platform, but adding a mode tile to dashboard forces it to get setup. :slight_smile: