Copy-Pasting Automations for creating multiple automations of similar nature?

Hi,
I started using SmartThings only recently with smart lighting, sensors, etc. I recently moved into a new home and have fitted about 12 motion sensors and some more contact sensors, etc. I need to create dozens of automations and smartApps which are similar but slightly different.
Are there ways to copy paste automations?
e.g.
when motion sensor of room A is triggered → what to do with fans and lights of room

  • depending on which room
  • depending on which day of week
  • depending on time of the day (abstracted using modes)
    similarly, for when motion is not detected.
    I am spending a lot of time doing very similar repetitive work in the automation creation.
    e.g. further this work gets increased if I wanna create a lot of virtual switches to control wifi plugs or Broadlink RF/IF devices or Somfy blinds that are connected to Alexa but not directly to SmartThings.

I choose smartthings instead of HomeAssistant because I don’t want to spend time coding. I used to code a little bit for my job till 5 years ago and since then haven’t coded and only do google-sheets style formula coding. don’t think I wanna get into coding unless it is required for automation.

Are there ways to copy-paste in SmartThings?

There are not with Automations in the ST app. The new Rules API (not finalized at this point I believe) probably allow it but I have not used that yet. Maybe another user who has can comment.

You may want to start planning to use Automations instead of Smart Lighting as it will be phased out at some point… probably the end of this year :frowning:

2 Likes

Input and output to the Rules API (and indeed all the other endpoints in the SmartThings API) is in JSON format, with the option of YAML format if you are using the SmartThings CLI tool as an intermediary. So you can most certainly exploit cut and paste if you are using the Rules API. Indeed while it evolves you do find you have little choice but to create multiple similar automations where perhaps you’d rather have one.

2 Likes

oh my, i didn’t realize smart lighting smartApp will be phased out. the problem with using automation to switch on lights is that I need to configure the brightness and color for 5-10 lights (per room) one by one, vs smartLighting lets me choose one time for all.
thanks for letting me know!

thanks! I checked out rules API thread on the community and it seems we are moving more away from the app / UI and more towards code-based automation. i guess that is natural to help developers or advanced users, but even a copy paste in the UI would’ve been so good. :frowning:
thanks for letting me know about the rules API.

Interesting. I am seeing a move towards giving end users app / UI based automations (Automations / Scenes) that shield them from coding completely.

At the moment there is a bit of a gap between the relatively basic app based tools, and the raw or command line based access to the API underpinning them. Something will probably bridge that gap.

There is certainly some scope for developing the Automations tool a little and being able to duplicate them would be my first choice.

1 Like

That would be my second choice. My own first choice would be making light groups actionable in scenes and automations. :sunglasses:

1 Like

ya thats there too. it is surprising to see there is an option to make a light group but it doesn’t show up anywhere.
I still think copy-paste would help more because light groups only helps group lights, whereas copy-paste helps scale effort across rooms, times of the day, etc. (like orangebucket mentioned)
thanks for chiming here and helping me understand about the Rules API and confirming that copying is a gap.
every day I write new automations I worry about a) no backup b) all the copy pasting i end up doing. and then wonder whether i should switch to Home Assistant. then i see the jargon used in HA community and I feel at home with smartthings. :smiley:

1 Like

I came across webcore references in HBS and checked out youtube, it seems webcore might be one way to write automation in a easy way but then copy paste the code to reuse it.
would you say that is the way some Smartthings users might be doing copy-paste?
maybe webcore is the answer to copy-pasting?

Unfortunately because WebCore runs in the groovy cloud hosted by Samsung, it will be going away in a few months when the cloud goes away like all the other groovy smartapps. :disappointed_relieved: it is being replaced by the Rules API discussed above. So Webcore would only be a temporary solution.

The chances are that if they are using webCoRE, users are taking advantage of variables and arrays and things and only writing one piston to cover multiple situations.

Here is an example of a button handler in the Rules API (it is actually for the ‘0’ button on an IKEA On/Off Switch). I have multiple buttons doing the same thing so I just cough and drop this one and change the IDs over.

name: 'Button: Bedroom: 0'
actions:
  - if:
      equals:
        left:
          device:
            devices:
              - &bedroom_button  REDACTED_DEVICE_ID
            component: button1
            capability: button
            attribute: button
        right:
          string: pushed
      then:
        - if:
            equals:
              left:
                device:
                  devices:
                    - &bedroom_wall_light  REDACTED_DEVICE_ID
                  component: main
                  capability: switch
                  attribute: switch
                  trigger: Never
              right:
                  string: off
            then:
              - command:
                  devices:
                    - &bedroom_virtual  REDACTED_DEVICE_ID
                  commands:
                    - component: main
                      capability: circlemusic21301.motionCommands
                      command: active
              - command:
                  devices:
                    - *bedroom_wall_light
                  commands:
                    - component: main
                      capability: switch
                      command: on
            else:
              - command:
                  devices:
                    - *bedroom_virtual
                  commands:
                    - component: main
                      capability: circlemusic21301.motionCommands
                      command: inactive
              - command:
                  devices:
                    - *bedroom_wall_light
                  commands:
                    - component: main
                      capability: switch
                      command: off
      else:
         - if:
             equals:
               left:
                 device:
                   devices:
                     - *bedroom_button
                   component: button1
                   capability: button
                   attribute: button
               right:
                 string: held
             then:
               - if:
                   equals:
                     left:
                       device:
                         devices:
                           - &bedroom_fan REDACTED_DEVICE_ID
                         component: main
                         capability: switch
                         attribute: switch
                         trigger: Never
                     right:
                       string: off
                   then:
                     - command:
                         devices:
                           - *bedroom_fan
                         commands:
                           - component: main
                             capability: switch
                             command: on
                   else:
                     - command:
                         devices:
                           - *bedroom_fan
                         commands:
                         - component: main
                           capability: switch
                           command: off
2 Likes

ah,
so on one hand, webcore will also go away or change significantly soon. webcore users would not need as much copy-paste as they would be able to use variables and arrays.
I’m guessing smartapps will also go away due to cloud going away.
and rules API is the next thing but seems rather technical to start with. i read samsung’s announcement and they focus on API-first

1 Like