ActionTiles tile with TRIGGERcmd bookmark URL


  • administrators

    I tried ActionTiles for the first time tonight. Nate Hales's (Bubba's) youtube video inspired me to try it.

    I wanted to see if I could skip the step of setting up a SmartThings switch for each command, so I created a shortcut tile that points to a TRIGGERcmd Bookmark URL like this one that runs Calculator on my PC:

    https://www.triggercmd.com/trigger/bookmark?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJib29rbWFya3VzZXJfaWQiOiI1OGJiM2E3N2YyZjgzMTUzMjI0NzM1YjYiLCJjb21wdXRlcl9pZCI6IjU5ZDZhYjJlODRlOThkZjM2M2U2ZGY2NCIsImNvbW1hbmRfaWQiOiI1OWQ2YWIyZjg0ZTk4ZGYzNjNlNmRmNjUiLCJleHBpcmVzSW5TZWNvbmRzIjoiIiwiaWF0IjoxNTA3NDI5MjcyfQ._PHTPxVsMR-K6M4uQK3sbWuKMiJyfFzV_i-GEklt_vA
    

    You might not have noticed it, but you have a red Bookmark button for each TRIGGERcmd command you setup. That's how I created that URL.

    I used that URL in a shortcut tile on my ActionTiles panel that looks like this:
    Shortcut Tile

    It works pretty well on my Amazon Fire tablet using the Fully Kiosk browser, but on a regular browser it opens another tab which is awkward to have to close each time.

    On the Fully Kiosk browser that has my ActionTiles panel open, I can:

    1. Tap the Calculator tile and see two things:
      a. Calculator opens on my PC
      b. The Bookmark page for my trigger opens in the Fully Kiosk browser.
    2. Swipe down to re-run calculator if I want.
    3. Swipe up from the bottom of the tablet screen to bring up the Android back button.
    4. Tap the back button and see that Fully Kiosk closed the Bookmark page tab, and I'm back at my panel.

    EDIT 10/14/17: I submitted a feature request to ActionTiles to ask them to support an HTTP POST Webhook. That would prevent a new browser tab from popping up every time you tap the tile.

    EDIT 1/16/18: Now if you append &close=true to the end of your bookmark URL, the page will auto-close as soon as it opens. The Fully Kiosk browser honors the javascript close() command without prompting you.
    Like this: https://www.triggercmd.com/trigger/bookmark?token=BLAHtokenBLAH&close=true



  • @Russ this is awesome!


  • administrators

    Thanks Nate.

    Feel free to run Calculator on my computer. If too many calculators start poping up (because someone posted the URL on social media for instance) I can always delete and re-create my Calculator command to disable that URL.



  • Is there any way to run the URL from a tile without opening a new window? This would be the best way to add it to action tiles since the switches are on/off instead of momentary buttons, so i dont like the look of random switches being on when thats not actually the active thing. If i could just use a shortcut URL tile without it popping up, that might be the way to go, assuming it still fires the script. im running this in Fully Kiosk. Maybe i can block pop ups in fully?


  • administrators

    @elnorte13524, that's interesting. I run ActionTiles with Fully Kiosk and I tried to do the same thing and had the same problem - my button opened another browser tab to the bookmark URL that I had to close every time.

    I actually posted a suggestion on the ActionTiles forum asking them to add a feature to be able to send an HTTP POST to an API instead of pulling up a URL in a browser tab.

    As of a few minutes ago if you append &close=true to the end of your bookmark URL, the page will auto-close as soon as it opens. The Fully Kiosk browser honors the javascript close() command without prompting you.

    Like this:
    https://www.triggercmd.com/trigger/bookmark?token=BLAHtokenBLAH&close=true



  • @russ nice, thank you! im going to edit my URLs and set that up later today. Thatll work in AT, and thats really what im worried about right now.



  • Adding the statement at the end works to close the tab, the problem i have now is that Fully will open either into a window within fully but wont close that, a new fully instance, or a chrome tab where it closes that tab but then stays in chrome. I cant get it to just open one chrome tab, close that and go back to fully. I wonder if it would work different if it was the only chrome tab, though, then when it closes the tab it might go back to Fully. Ill have to test that on the tablet when i get home, i have 30 tabs open on my phone that i (might) come back to, so i cant test it until i get home. Did you make any changes to Fully for it to work within Fully to open the tab, run the command and close it to go back where you were in Fully?



  • Another question - is it possible to edit the .groovy to make the TriggerCMD switches into buttons? It would make for a cleaner look if they were momentary button tiles instead of toggle switches. Right now half of them are on, which on an AT panel just looks weird to me, showing 3 playlists as "on".

    im still working with the bookmark URL in an AT shortcut, i just havent gotten it working right to open then close the window in fully.


  • administrators

    @elnorte13524 yes, it's possible to change the groovy code if you don't mind having all virtual switches auto toggle back off as soon as you toggle them on. The older groovy code used to do that before I added parameter support.

    Remove the // in front of the off() in the device handler in this section:

    // handle commands
    def on() {
    	log.debug "Executing 'on'"
    	sendEvent(name:"switch",value:on)
    	parent.on(this)
    
        // off()
    }
    

    Also, remove all lines inside this off(childDevice) function except the debugOut line:

    def off(childDevice) {
    	debugOut "Off request from child device"
    
        def dni = childDevice.device.deviceNetworkId
    
        //Russ
    	def Params = [
    		token: "${atomicState.token}",
            uri: "/api/run/triggerByID",
            body: "trigger=${dni}&params=off"
    	]
    
    	apiPost(Params) { response ->
    		debugOut "OFF result: ${response.data}"
    	}
    }
    

    I think a better solution would be to make the virtual switch toggle itself off immediately only if the command doesn't have parameters turned on. I would need to add some code to the server side to accomplish that.



  • @russ ok cool. so the device handler would look like:

    **// handle commands
    def on() {
    log.debug "Executing 'on'"
    sendEvent(name:"switch",value:on)
    parent.on(this)

     off()
    

    }**

    And the then this is also the device handler? Would look like this:

    def off(childDevice) {
    debugOut "Off request from child device"

    }
    

    }

    is that what you meant? Making them momentary buttons would make it work much better in AT for me. I wouldnt need them to be links and try to close the page, i could just use them as a button to run the command on the computer. Thanks again for the help!

    apologies for the weird formatting, i cant figure out how to correct it so it looks like code, the way you did in your comment


  • administrators

    @elnorte13524 actually that off(childDevice) function is at the end of the Smartapp code, not the device handler code.

    Also I see that Action Tiles developers are going to create a way to call an API so you won't have to use SmartThings.

    Also to make your text show up as code you have to indent it at least four spaces.



  • maybe ill leave it alone until i can use it directly from Action Tiles with the API. i tried to edit the code but broke it all, so i had to paste the original code and itll be work how it is. Thanks for the help, though, this is an awesome app.


Log in to reply
 

Looks like your connection to TRIGGERcmd Forum was lost, please wait while we try to reconnect.