I need a virtual toggle (turns on if off, turns off if on) binary, not momentary

I know somebody had some code for this, but I can’t find it.

I have a pushbutton switch that my service dog can use. I want a virtual switch stand-in for it it to turn on if it was off, turn off if it was on, and be a binary switch not a momentary.

Thanks! :sunglasses::dog:

1 Like

How do you plan to link to this virtual switch, that is, how do you expect it to work? A momentary switch has a command push(), and that could be made into a toggle. Or, on() could be redefined to mean toggle from a stock virtual switch. All depends on how you intend to use it.

The physical button is the Flic. It has an IFTTT channel.

So dog pushes the button, that’s the IF to IFTTT, SmartThings virtual switch is the THAT.

Couid be the virtual toggle, could be a switch that runs a routine or triggers a smartapp which flips the virtual toggle.

I just want to end up with a situation where the first time the dog pushes the button, The light goes on. The second time the dog pushes the same button, The light goes off.

Because the flic is pretty expensive, $34, and I don’t want to need two per light.

1 Like

That’s pretty easy to do, you know you are in good hands with @bravenel. Bruce, do you have time to help JD with this if not I’ll do it tomorrow…?

2 Likes

Not tonight, and probably not tomorrow :disappointed:

No rush, it will take a couple of weeks of button training before we’re ready to actually use it anyway. :sunglasses:

As an aside, I think that we ought to have a Capability “Toggle”, or at least make Command "toggle()` recommended for most Switch Device Type Handlers.

The problem with the slow evolution of the Capability Taxonomy is that new SmartApps will take a long time to offer to use such a Command.

Well one of the most common SmartApps (a parent with children, actually) would be one that simply asked:

  • When this or these Buttons are Pushed:
  • Toggle these Switches:

But, **eureka!, in fact, that is exactly what is provided in the standard old "Button Controller" SmartApp.

So:

  • (a) Can’t Button Controller SmartApp be used for this (if Button Controller can be modified to properly accept a Flic as equivalent to an Aeon Minimote or Enerwave 7-Button with, well, just one (1) Button?).
  • (b) Can’t this scenario fit in the functionality of the new way of using the Aeon Minimote (i.e., via “`Smart Lighting”)?
2 Likes

The Flic itself isn’t on the SmartThings network. It’s a Bluetooth device. The interface is via IFTTT.

1 Like

So IFTTT has a “Momentary Button” Device Type (trigger), essentially?

Rule: If Flic is Pushed Then Toggle SmartThing Switch X?

Yup… the nicest solution would be if every SmartThing Switch had a “toggle()” command in addition to on() and off … I asked for that many many months ago when I was coding a revised Button Controller (ie., the PIN SmartApp), and realized Toggle belongs in the Device, not in the SmartApp.

No, the physical Flic itself has three actions.

Press
Long Press
Double Tap

Their IFTTT channel can recognize all three states. So you can set up a different recipe based on any of those.

But in terms of using the SmartThings side of the IFTTT channel, every recipe is just a trigger event and a consequence. If then that.

The If is neither binary nor momentary because it’s not a switch. You can’t poll its state. It’s just a trigger. So that’s what we’re working with.

In terms of my particular use case, I’m not treating the virtual stand in as a momentary either. I don’t want it to switch back to off when it turns on. I want to be able to turn it on and have it stay on until I turn it off.

But what I want is for the next trigger event to change the state of the virtual stand in to the opposite of where it currently is. So if it’s on, turn it off. If it’s off, turn it on.

. But not “turn on then off” from one trigger like a momentary would do.

As far as the physical flic, neither my dog nor I can accurately distinguish between the three actions, so I’m just treating it like it only has one action. :sunglasses:

Yes… we’re on the same page; I just didn’t communicate clearly.

It’s not the “IF” part of the IFTTT that’s the issue. It’s the “THEN” phrase.

  • 'IF [Press,Long Press,Double Tap](Button) THEN Toggle(Switch)"

i.e., in general, it would be handy for IFTTT to allow “toggle( switch )” as a “THEN Action”.
But that, of course, would also require each of the various connected services to support “toggle()”.


Anyhow… expecting every SmartThings Switch to suddenly add a toggle() Command is unrealistic.

So, indeed, using a Virtual Device with a SmartApp as intermediaries is the flexible solution we apply to so many of these problems that could have been otherwise anticipated and come built-in.

The practical point: I suggest a SmartApp than can spin up as many Virtual Toggle Switches as the user might want. A “Toggle Switch” is useful in many scenarios. But if a Toggle Switch exists in the forest … does anyone ever flic it? :smile:

1 Like

IFTTT doesn’t define the actions available. That’s up to each company that creates a channel. That’s the power of IFTTT. That each company gets to say whatever they want their IFs and their THENs to be.

Philips Hue offers a “blink” action in their channel. SmartThings does not. Just a decision each company made. IFTTT doesn’t care. All it does is pass the service request over when the trigger is received.

If SMARTThings wants to add toggle capability to their existing IFTTT channel they can any time. :sunglasses:

2 Likes

IFTTT could be the better man here (i.e., be the more innovative platform) and add Toggle to the list of enhanced operations which it can perform on connected services. It would have to keep accurate and timely state of the connected service device (i.e., the target SmartThings Switch). Yet with IFTTT having a non-trivial lag time, it would frequently not know the accurate current state of the Switch.

Heck … even SmartThings has this problem:

  • Toggling a non-instant-reporting physical wall switch (or a Philips Hue bulb…) is non-deterministic, since SmartThings cannot be certain of the State of that switch … unless it polls first.

Obviously, you can add me to the list of volunteers to create this Virtual Toggle Switch and it’s spawning and child SmartApp, if needed.

Only condition: I think we all would love a short video of your service dog pressing the Flic and creating magic. :dog2: :paw_prints: :radio_button: :fireworks:

1 Like

JD, here it is…“Toggle Button Tile” device type. Create a simulated switch and use this device type. Then set IFTTT to turn it “on”.

https://raw.githubusercontent.com/sbdobrescu/SmartThings/master/ToggleButtonTile.groovy

4 Likes

Nice work @SBDOBRESCU, you beat me to it! I was so close :smile:.

1 Like

Awesome! And as luck would have it, my techie aide is the one who’s here this afternoon, so we’ll be able to try it out. :sunglasses:

1 Like

I just started drinking my coffee a tad earlier than you :slight_smile: Thx

2 Likes

Why not just use Tasker to issue a toggle command to the switch via Sharptools? You really don’t need to go to the cloud and back with IFTTT.

1 Like

I’m quadriparetic. Android doesn’t have the same accessibility options as IOS.

Tried the toggle, but it’s not working. It never changes the state of the device. That is never changes the state of the device that has the toggle tile type.

The change commands are sent by smartthings, just there are no events at all for the toggle. And no state.

The toggle tile shows as “Off” in the mobile app, but “no state” in the IDE.

In contrast, see the binary simulated switch “guestroom shelf virtual” which does show a state of off in the IDE.

The IFTTT recipe that I am using here is just if the guestroom shelf virtual turns on, turn on the toggle control. So I haven’t put the flic into the mix yet.