Wait rule for virtual switch in Routines

Hi,

If I have a number of Routines where the status of a particular virtual switch changes to On,

could a rule be written that delays execution of any Routine where this occurs… for five seconds?

1 Like

Can you use the advanced option “stays this status for how long?” And set it to 5 seconds?

If I’m understanding that option correctly, I don’t think so. In this use case it does not matter how long the switch stays in that status. What matters is that the next step not execute for five seconds, in order to allow the device (a Bravia TV) to boot up sufficiently to accept and process the next command.

If you make the trigger condition for the routine that the switch must be on for 5 seconds it will fire when that condition is true, ie after it’s on for 5 seconds. You need to make this a separate routine not an extra step in an existing one.

The routine is to be initiated by Alexa voice command. The ‘wait’ has to occur within the string of commands that comprise the Routine. Do X, wait 5 seconds, do the next thing. Else I end up with a cascade of Routines, at least four between ST and Alexa, in order to accomplish what could be accomplished by a simple Wait command. And three of those four Routines would have to be replicated for each of a dozen different channels (I’m setting up voice commands on an old Bravia Android TV).

Thirty six new Routines, in order to do what could be accomplished by a simple Wait command, is bordering on preposterous.

Either a separate Wait command, and/or allow delayed execution of device drivers capable of it within manually triggered Routines, would make a world of sense.

If you don’t care about local execution, you could accomplish this with Sharptools.

As it is dependent upon Alexa, which is not local, I can live with this not executing locally.

Been a few years since I purchased Sharptools. Might have to delve back into it

I’m pretty certain there is no pause or wait available in between steps in a SmartThings routine. Other than introducing a delay with a virtual switch and triggering another routine based on a time event on that switch I don’t know if you can do what you want in SmartThings directly.

I have achieved a similar effect though in my setup using a smart life ir controller from Ali express and its integration with Alexa to control a Sony tv.

What I did was

  1. Configure the ir controller to control the tv in smart life
    2 create a tap to run scene which turns on the tv , waits 9 seconds and then changes channel. Note I use the 9 button to turn the tv on rather than the power control, so the scene still works if the tv is already on.
    3 I can launch this from Alexa with “Alexa turn on tv time”

The device from aliexpess was about 5 uk pounds and works over WiFi and is usb powered so no extra hub required.

I appreciate it’s probably not the solution you’re after but I have used this approach and it does work.

This is the device I bought

| Tuya Smart WiFi IR Remote Universal for Smart Home Control for TV Air Conditioner Works with Alexa Google Home Yandex Alice
https://a.aliexpress.com/_mqXRUSC

I know I mentioned this in your other thread, but I think I may have confused you, because I mentioned the four routine method first.

But there is a “wait“ available in Alexa routines if that helps at all. That way you would only need one routine in smartthings (to turn on the trigger device for an Alexa routine) and then one Alexa routine to turn on the TV, wait five seconds, and then do the next step.

(“Atomic” is the name of my television. “Hulu” is a scene that changes that television to Hulu.)

This is the Alexa routine created in the Amazon Alexa app.

I don’t know if that’s of any help or not, but I just wanted to clear up any confusion I may have introduced in the other thread. :man_shrugging:t2:

Here is an example of Rules API routine (including delay = sleep)

{
  "name": "TV FRANCE24 vSwitch -> TV F24",
  "actions": [
    {
      "if": {
        "equals": {
          "right": {
            "device": {
              "devices": [
                "select-f24-vswitch-id"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch"
            }
          },
          "left": {
            "string": "on"
          }
        },
        "then": [
          {
            "command": {
              "devices": [
                "sony-bravia-id"
              ],
              "commands": [
				{
					"component": "main",
					"capability": "switch",
					"command": "on"
				},
                {
					"component": "main",
					"capability": "mediaPresets",
					"command": "playPreset",
					"arguments": [{ "string": "FRANCE 24" }]
				}
				]
            }
          },
	  {
			"sleep": {
				"duration": {
					"value": {
						"integer": 5
					},
					"unit": "second"
				}
			}
		  },
          {
            "command": {
              "devices": [
                "sony-bravia-id"
              ],
              "commands": [
                {
                  "component": "main",
                  "capability": "platinummassive43262.sonyIrccCommand",
                  "command": "sendCommand",
				  "arguments": [{ "string": "10,13" }]
				}
				]
            }
          },
		  {
			"command": {
			  "devices": [
				"select-f24-vswitch-id"
			  ],
			  "commands": [
				{
				  "component": "main",
				  "capability": "switch",
				  "command": "off"
				}
			  ]
			}
		  }		  
        ]
      }
    }
  ]
}
4 Likes

Sidetrack question: Can the Alexa skill for this support multiple devices. Can I have Livingroom TV and Media room TV? Logitech did not handle this well, and my logitech remote has failed so I’m looking for a new solution.

I’m not sure I’m totally understanding exactly what you are needing. Anyway, all of my SmartThings devices have a ‘delay this action’ timer. Yours don’t?

Voice Command ‘Turn on X’ a virtual switch.

Routine
If
Virtual switch X turns On

Then
Turn on first device

Turn on the next device with delay this action for 5 seconds

Turn on the next device with delay this action for 10 seconds

Turn on the next device with delay this action for 15 seconds

And so on…

3 Likes

@warnersmith: the condition “manually run” prohibits the addition of other conditions. See attached photos; that option gets grayed out.

@Ptbradford: I think Alexa routines do support that.

@DaWeav: the “delay this action” capability vanishes when the Routine is run manually! See attached photos.


Correct. Manually run routines (formerly called scenes, and called scenes by pretty much every other home automation platform) by definition don’t have any conditions. They are just a single moment in time.

They can be actuated by other methods which do have conditions, such as an automatic routine. Or an Alexa routine. So you would need to put the wait into the actuating method. But it is more set up work, for sure. :thinking:

2 Likes

@JDRoberts already mentioned a simple solution for this. Put the wait command in the Alexa routine that calls the scene! You could also add an action to turn on the Bravia TV right before the wait command and have it all in one Alexa routine.

1 Like

Thanks for that… but the concept here is to limit the numbers of routines and devices. Alexa limits you to 200 routines, just as Smartthings has a 200 device limit. So I’m doing my utmost to limit the new devices & routines I create.

ST apparently has a 250 routine limit. And unlike the above I do not have a large number of ST Routines. So that’s where I’m working at this point.

In the grand scheme, having a routine turn the device on in the way I desire is nothing but a convenience. I’ll pursue it, just because… but it’s no make-or-break thing.

In the meantime, I still think ST should include a WAIT function in Routines! Or at least not block the individual device delay on manually-run routines. It just makes sense.

ST’s routine limit was raised to 1000 months ago.

2 Likes

That’s great news!

Can I ask why you’re using scenes (manually run routines) to begin with? Is it just so you have an easy voice command with Alexa?

If so, maybe it would be easier and require the fewest possible number of routines if you just built an automatically run routine with all the conditions you want and use a virtual switch as a pre-condition, and then use Alexa to turn on the virtual switch by voice.

Since this virtual switch doesn’t need to trigger an Alexa routine you can just create one with any of the official features, including the advanced functions page in the official web UI.

My.smartthings.com/advanced

So one virtual switch and one smartthings automatic routine. Just a thought. :thinking:

2 Likes

Answer: the limit on the number of devices. Or has that also changed? When I google it, it still says 200 devices… I’m nearly at that limit.

1 Like