UI for picking list of devices


#1

I would like to create a piston that will do some things (not important what) with a number of devices. I would like the list of devices to be picked by the user just before triggering the piston, using my dashboard - I’m currently experimenting with action tiles as a dashboard solution, but I’m open to suggestions. How do you think I go about doing this?

I was thinking of creating a global variable and then create triggers for each device to add the device into the global variable or remove it if it’s already there. Then I would bind these add/remove triggers to tiles and then have an extra tile to trigger the piston. But this looks like a lot of work and also… I don’t see an option to create global array variables.

Any ideas?


#2

use a static list of devices and a second boolean array to ‘enable’ or ‘disable’ use of the device. if you get a device event from a ‘disabled’ device skip processing of the event otherwise process the event. you could use tiles for the piston to enable/disable these devices or do it another way.

device variable implicitly is an array. though not directly addressable as an array, can be used with functions that support array use as a parameter.


#3

hi. thanks. newbie here :slight_smile:
Static list of devices? Can you perhaps give me an example?


#4

I may have mislead you by using the term “static”. Define a device variable and select a list of devices to include in the device variable. This device list doesn’t change. In another array have a corresponding flag for if device is enabled or disabled.

Does that make more sense?


#5

This is a bit better, thanks. But how do I change the state of the other array from my actiontiles dashboard? I was thinking of having somehow one tile for each device which changes the state when it is pressed. This means that I need to trigger one piston for each tile, or, if possible, have only one piston for all the tiles and pass a device identifier as an argument.


#6

well, if you have <= 16 devices you could create a tile per device in one piston and user can click on a tile to enable or disable device?


#7

that’s what I’m saying too, but if it’s one piston, how will it know which device to enable. can I pass a parameter to a piston invoked with a GET request on a url?


#8

do you mean webcore tile? if you are doing it in webcore you dont really need a get request. you can check if a tile was clicked like this:

image

EDIT: reading up i see you may have meant action tiles. if yes, then yes you can pass in a parameter on a https request to execute a piston. but, i dont use action tiles so couldnt tell you how do it from there. but to see the general format go to webcore dashboard -> settings -> integrations then look at the executing pistons section.


#9

Thanks @bangali, that dashboard>settings>integration was what I was looking for! So my idea is to make a piston which accepts a device id and a true/false and will save it in a generic way in a global variable. Then another piston will just a process with the selected devices. The important thing here was not to hard-code any device id on webcore.


#10

I’m back with more questions, I’m afraid.

  1. Can I have an example of a piston which parses incoming arguments from a POST?
  2. Would it be possible to pass arguments with a GET request? From what I see, ActionTiles cannot execute POST requests.

#11

heres a post request from ifttt (sensitive fields are hidden) with json

and how those arguements are referenced in a piston:

i dont have one for GET. @ipaterson when he is around probably has a few of those :slight_smile:


#12

In a GET request to trigger a piston your params will be in the format ?pollen=low&checkTime=09:00 appended to what the dashboard shows as the external URL. Your browser will do a GET request when you visit that URL so it’s easy to test, here is a full example of what such a URL would look like (with fake token and id):

https://graph.api.smartthings.com/api/token/ac44e52d-45da-41fe-a4cb-a79c5c201623/smartapps/installations/fd139844-299d-4bb0-93ba-de7ea6f0c819/execute/:413241eba71a4a8da4c3e965d440f3a7:?pollen=low&checkTime=09:00

This would allow your piston to access $args.pollen and $args.checkTime as shown in @bangali’s example.