Accessing rules from custom tile

Is it possible to run a Rule from a custom tile?
I tried calling an http trigger but I get an error ‘Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at](…)’ (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Is there a better way to do this?

I am creating a pin pad (variation on the Community Project: Pin Entry Custom Tile) which I want to use for turning an alarm an and off as either Home mode or Away mode.

We should be able to add a CORS allowance for the Custom Tile domain so you can run rule triggers from there. I’ll take a look and let you know.

In the meantime, since you’re creating a Custom Tile with a PIN Pad, you could use the API for your hub directly.

Thanks @josh
I am a little surprised this has not come up before as it would seem to be a good feature to have, but then maybe it is just me.
Another option would be to be able to change the value of a variable if that is possible.

Is the API URL mentioned in the PIN Demo ( usable in the future? I was thinking that it came from the old Groovy option so wouldn’t be available when that support ends.
If it is, then I think that would work for me.

Yes, that API is the next generation SmartThings API and is not associated with Groovy.

Okay - thanks - I will give it a go.

Thank you for the quick response - on a weekend too :smiley: :clap:

1 Like

We pushed an allowance for this with today’s platform release. The Rule Trigger URLs now support CORS mappings for the Custom Tile domain. :slight_smile:

Thanks @josh
I have got it working through the Smartthings API, but it is a bit messy.
I’ll give it a try directly to Sharptools which I think will be a cleaner solution.
I’ll let you know how I go.

1 Like

I have created a key pad that turns an alarm on and off.

Pressing ‘0’ and either the ‘Home’ or ‘Away’ key will set the alarm in either ‘Home’ (stay) mode or ‘Away’ mode. You key in the 4 digit pin to disarm the alarm (set by the Custom Tile Settings).
I have created three virtual switches (using the vEdge Creator from TAustin) for Set Away, Set home and Set Disarm. These trigger Routines in Smartthings which set the alarm modes.
I have a rule in Sharp Tools, triggered from the Custom Tile (thanks @josh) which sets the virtual switches.
I have a question though:
I had the idea to change the colour if the custom tile depending on the alarm mode (off, home or away), which I have working, but it is not persistent if the dashboard is refreshed. Is there any way to make this persistent?

I am also still testing this against the Smartthings API to see if one or the other has a faster execution.

How are you determining the Alarm Mode in your Custom Tile?

It sounds like that state isn’t being determined properly when the tile loads. One approach might be to query SmartThings for the status of your various Virtual Switches (assuming those track with the expected state). Other people have loosely mapped their SHM states into various ‘modes’ – in which case you could query the current location mode.

That is what is happening. I had thought of querying SmartThings, but I was hoping there may be a simpler way.