Hi all,
I recently needed to create some buttons on my wife’s AT panel for manually overriding irrigation schedules and such. Basically she wanted some push-buttons, which would immediately run the drippers on specific circuits for a couple of minutes and then shut off again.
I tried a few DTH’s I found in the forums, unfortunately none of them seemed to be what I was after. Some trial and error (and a helpful nudge from @tgauchat thanks), I tweaked the existing ‘Simulated Button’ DTH so it works both from within the ST Classic app and when you authorize it to ActionTiles.
Code notes:
Really wasn’t much that needed to be changed, AT looks for the Momentary capability, so that was added. Second the endpoint in the original DTH was for some reason called ‘push1’, changed that to ‘push’, which is the one AT will execute.
Note: the hold endpoint does not appear to be supported by AT as of now, yet that’s IMHO something you would only use on a physical button anyway. In AT you would just create another tile button I suppose.
Anyway if you need something similar, here’s the McGyver’ed DTH:
Hi Robin, yes - routines are certainly useful, yet I guess my choice hinges on that I use Webcore pistons for most of my automation rules these days as they give me the best flexibility.
Second, do correct me if I’m wrong, however I haven’t come across a good way with the native smartapps (like button manager, smart lighting or said routines, to use a button press to trigger a switch to turn on and then turn off after a while, like you can do with a motion detector. That combo seems not to be available.
Btw, this is what the working end-result looks likes in AT:
This is really nice. My wife is always asking me to turn on a Rachio sprinkler zone for some number of minutes. I will shameless may borrow from your excellent work to implement a similar button using the RULE feature in HousePanel. Thanks so much for sharing this. Looks amazing.
@MaxVonEvil Why wouldn’t just creating a Virtual Switch (which is local), then a Smart Lighting rule to turn off after two minutes (with Power Allowance, also local), not work for you?
1 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
8
Thanks for sharing this Device Handler, Max.
I have to share a little bit of recurring education on the topic of Capability “Button” vs Capability “Momentary”:
A Button is a Sensor (i.e., it has Attributes and reports when pushed or held), but not an Actuator (i.e., it does not have any Commands). A Button is like a Contact Sensor - it tells you when it is pushed (opened), but: A SmartApp cannot send any Commands to a Sensor that isn’t also an actuator. A SmartApp cannot, for example, tell a Contact Sensor to be “closed”. It can’t tell a Smoke Detector or Leak Sensor to pretend there is smoke or water present. See this link: You will note that Button has no Commands: https://docs.smartthings.com/en/latest/capabilities-reference.html#button
Due to #1, a SmartApp (like ActionTiles) cannot do anything with a Button. ActionTiles cannot push() or hold() a Button. Just as ActionTiles cannot open or close a contact sensor.
SmartThings included a unique Capability “Momentary” which has a Command “push()” but no Attributes. In other words, it is just an Actuator and not a Sensor. It would be like a smart outlet that you could turn on/off remotely, but not physically, and that would never report its state back to SmartThings. Why bother? Well - There are a lot of physical devices in the world which react to Momentary presses: Elevator call buttons, Doorbell button, Start button on a computer, etc… The Capability for Momentary is described here: https://docs.smartthings.com/en/latest/capabilities-reference.html#momentary
Unfortunately, there are indications that SmartThings intends to deprecate or discontinue Capability “Momentary”. The latest Capability list is published here: https://smartthings.developer.samsung.com/docs/api-ref/capabilities.html#Capabilities - I have written to Developer Support and requested Momentary be added back; but they were unhelpful. They simply don’t understand the special use cases we deal with all the time in the Community: ActionTiles, WebCoRE, Virtual Devices, etc., etc…
But wait: Can’t “Virtual Devices” be special and have custom Commands and/or Attributes?
Yes - In the legacy SmartThings API this is permitted. That’s why you can have a “Virtual Button” and add a push, hold, etc., Commands to it for SmartApps to use.
But custom ad hoc Commands & Attributes are not permitted in the new API: All the Commands and Attributes must come from an officially published Capability.
ActionTiles is a “SmartApp” - not a “Device”. ActionTiles can issue a push() Command to a Momentary, but cannot “be” a physical button and sendpush() Events to SmartThings (for other SmartApps to respond to). Maybe this will be an interesting way to handle the situation in the future - but it isn’t trivial, because ActionTiles will need to be published as both a SmartApp and as a Device Type. Getting a Device Type published is hard. Would ActionTiles just be a Button? Or a set of Buttons? Or something more complex that needs a whole new Capability?
The short term implication is that your DH posted in this Topic, and all the folks who are using some variation of Virtual or Real Devices claiming Capability “Momentary” is completely functional with ActionTiles and within specifications for SmartThings SmartApps.
But that all goes aways when SmartThings enforces the new API rules: Deprecates Capability “Momentary” and forbids Capability “Button” from having any ad hoc custom Commands.
It is a messy loose end that’s been around for ages and no one at SmartThings is helping to resolve it.
Thanks for sharing your deep understanding of this issue. I struggled with figuring out a way to implement momentary buttons in HousePanel. I ended up visually faking the momentary push and sending the push command. My automations react to switch on because the DH sets the switch back to off after momentarily setting it to on. This is what the push() command does behind the scenes. So my automations work on switch on which means they will work equally well with a momentary as they will with a regular switch - sort of. When momentary goes away we will have to simulate it using timers to turn switches on and then off. I can now do this using a local JavaScript function. My hope is smart lighting will have something like this. My bigger fear is that apps like HousePanel will also not be allowed in the future. I suppose I should start working on getting it in certifiable shape. There is so much sloppy hobby code in there that I don’t look forward to that. Anyway I’m drifting off topic. Thanks again for the excellent summary of button vs momentary.
Hi Terry thanks for elaborating on this. It appears we’re on somewhat wobbly ground one way or the other when it comes to the ST API. Having worked with several software companies, an identifiable danger sign is when they begin to acquire Ivory Tower syndrome; “Everything we need to see, we can see from up here - Absolutely no need to venture out in the fields. Thar’ be dragons!”
Anyway, I digress - this DTH is a quick fiix which might only work for so long. If/when the API goes tits up, I’m sure someone will step up to the plate with another workaround. As @Alwas suggested one could use a virtual switch. I personally like the visual feed back of a button, thus I suppose one could set up a regular vswitch, flip it back to off after one second with Webcore and then do whatever additional stuff you need it to do. Just a thought.
1 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
11
The new SmartThings API / Samsung Developers team actually has somewhat “responsive” tech support, but so far they are not as in-tune with the real-world edge cases we continuously explore here in the ST Community.
We could reach out to (i.e., pester) them with our concern regarding the deprecation of “Momentary” (and, ummm, several other rather surprising Capability changes); but unless this is handled in a comprehensive, clear, and unified manner, then nothing will happen.
What Samsung SmartThings (and “we”) needs are “Developer Advocates” - a role they eliminated years ago.
With such significant changes to the API, such a team of resources are needed more than ever. This role used to be very trendy for all the various platforms that popped up over the past 5+ years. I can’t say for sure if only SmartThings has pulled away from offering it.
hmm cool idea but why not just create a virtual switch and use webcore to turn off after x amount of min after turning on? That way the AT icon would also be illuminated while the system is running.
As we often say, smartthings is very powerful but not very discoverable. However, this is a very creative and active community, when you come across any fairly straightforward use case the odds are high that it’s already been solved and the solution published. Or that the answer is “webcore.“
By the way, you keep writing “DHT.” Do you mean “DTH,” “device type handler”?
Well, it’s not a question of ‘why not’ per se - I think we can all agree there’s several ways to skin this particular cat. In my case I kinda wanted to have it both ways.
About DHT/DTH. Sorry, occupational hazard: Been tinkering too many years with Distributed Hash Tables… Fixed it for ya
Please forgive the newbie question: I’ve loaded this into IDE as a Device Handler. How do I setup the virtual device in Smartthings that uses this handler?
It’s exactly what I need for my ActionTiles implementation.
Thanks in advance!
1 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
16
In the IDE, try going to My Devices and select “Add”.
Most of the fields are not important (such as Device ID); but there’s a drop-down to select the Device Type . Custom personal Types are not in the main alphabetical list. They are at the very bottom.
I got the simulated button setup. Tested it with Webcore and it works!
The problem – it is not showing up in ActionTiles. Within Action Tiles, I authorized the inclusion of my simulated buttons, they’re not showing as available tiles. Any thoughts on that?
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
20
Please post a link to the Device Type Handlersource code.
Probably an easy fix; but make it easy on me to help by linking to the code that you are using.
My guess? (just a guess…)
You’re creating a Virtual Button instead of a Virtual Momentary.
A Button is a Sensor, not an Actuator. You want ActionTiles to actuate (i.e., issue a command) when the Virtual Momentary is tapped.
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
22
It looks OK, at a glance. Please contact Support@ActionTiles.com so we can discuss through a trackable channel. You can always post the final results / hints here later.