The End of Groovy Has Arrived

Thank you for the tag, @JDRoberts :smiley:
@Jun_Li, yes, the dates shared here correspond to the Groovy-based integrations (SmartApps and DTHs) in the IDE. The endpoint app registered in the Dev Workspace isn’t part of that environment.

1 Like

yes, its very ugly because it’s an API. It’s not really meant to be used directly. Instead it should have an application for the UI to call the API. Routines in the mobile app does this. But there has yet to be a more complex UI for Rules API created.

4 Likes

Isn’t that what “Routine Creator” (beta) is supposed to be?

The app needs a way to group or sort routines by room or something, it’s not great.

Makes sense; the problem being that one rules UI is deprecated without a replacement being made available
 Folks will undoubtedly leave the platform in this case, chose your poison so to speak!

gst - where’s the “Routine Creator”? I think the app needs lots of things but to be honest there’s a UI/UX challenge in not making it overly complicated for new users.

1 Like

https://routinecreator.smartthings.com (currently a closed beta)

Thanks - Just found it in another thread :slight_smile:

Depends how you choose to use it. Currently I write Rules in raw YAML in text files as the CLI will consume those directly. I find them quite readable, although quite spaced out, and with nesting they get awfully wide. It meets my needs at the moment.

However Rules are just simple data objects. A combination of however you prefer to describe arrays and key-value pairs. They are defined in JSON because the SmartThings API consumes and outputs JSON, but you can write them in any language you like that supports those constructs. There is a strong chance you can trivially export to JSON given its ubiquity. You can write them as scripts that automatically install the Rule if you really want.

How do we get access to the closed beta? Might be helpful to many of us


1 Like

Its a depricated project.

Look at post 662

3 Likes

Multi gang switch.
I have a 2 gang Zemismart switch in my kitchen currently using a DTH.
When this migrates to edge will this now move to a single switch with two controls, and will I lose the ability to control both lights from Alexa?

As it stands now, only the master component will be exposed to Alexa.

The workaround is to create a virtual device for each subcomponent, use routines to keep those in sync with the actual switches, and have Alexa control the virtual devices.

It’s annoying, and it’s extra work, but the problem was reported last year and isn’t fixed yet, so I’m not holding my breath on it. :thinking:

2 Likes

Thanks, workaround is a bit painful, thankfully I only have one multigang switch at the moment

1 Like

@Mariano_Colmenarejo ZigBee switch with child’s Mc Edge Driver is probably what you are looking for. It will give you 2 separate switches if that is what you want. It works well with my 3gang Zemismart switch.

2 Likes

Thanks for chiming in - I can see this as quite powerful. I have the cli setup this week but didn’t really digest everything just yet; I took a look at the example using Postman but given I like to keep things simple I’m reluctant to go down this path. A yaml file with cli injection would be a good place to start playing around. Are there any decent examples (or tutorials yet); this all needs a modicum of comprehension in terms of exploring device-id, things that can be changed etc
 (I’m not there yet!)

A simple task I’m looking to complete, I turn on a light based on motion detection, after 10 minutes it switches off (I have kids!), however, if I turn on the light switch manually it stays on. I believe a variable is needed to store the state (e.g. manualActivation == True/False). If I’m reading the threads correctly this can’t be done as there are no variables in the rules engine?

thanks for that, will that be deployed automagically when groovy is shut down or will i need to take action then?

You can use a virtual switch to store status

2 Likes

OK, Thanks. I keep reading about these virtual switches (which I have in the IDE) but I have no idea how to implement them in the new scheme of things? Deeper down the rabbit hole I go!

There aren’t any variables in the Rules but you can use a virtual switch to hold a binary status. My approach to this problem actually uses a virtual motion sensor as it simplifies the logic. I turn a light on if there is motion between fifteen minutes before sunset and and thirty minutes after sunrise. I also turn the light off if motion goes inactive as my Ikea motion sensors give me a three minute delay that suits me just fine. This is actually my code, such as it is 


name: '[R] Motion: Landing'
actions:
  - if:
      and:
        - equals:
            left:
              device:
                devices:
                  - &landing_motion xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                  - &landing_virtual xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                component: main
                capability: motionSensor
                attribute: motion
            right:
              string: active
            aggregation: Any
        - between:
            value:
              time:
                reference: Now
            start:
              time:
                reference: Sunset
                offset:
                  value:
                    integer: -15
                  unit: Minute
            end:
              time:
                reference: Sunrise
                offset:
                  value:
                    integer: 30
                  unit: Minute
      then:
        - command:
            devices:
              - &landing_shelf_light xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
            commands:
              - component: main
                capability: switch
                command: on
      else:
        - if:
            and:
              - equals:
                  left:
                    device:
                      devices:
                        - *landing_motion
                        - *landing_virtual
                      component: main
                      capability: motionSensor
                      attribute: motion
                  right:
                    string: inactive
                  aggregation: All
              - between:
                  value:
                    time:
                      reference: Now
                  start:
                    time:
                      reference: Sunset
                      offset:
                        value:
                          integer: -15
                        unit: Minute
                  end:
                    time:
                      reference: Sunrise
                      offset:
                        value:
                          integer: 34
                        unit: Minute
            then:
              - command:
                  devices:
                    - *landing_shelf_light
                  commands:
                    - component: main
                      capability: switch
                      command: off

My buttons have push, held and double options. I use the push for a toggle on/off on the motion-controlled light. It does look like there is such a thing as a toggle command but if so it doesn’t seem to be available to the punters yet. I’ve stripped down my actual code here 


name: '[R] Button: Landing'
actions:
  - if:
      equals:
        left:
          device:
            devices:
              - &landing_button xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
            component: main
            capability: button
            attribute: button
        right:
          string: pushed
      then:
        - if:
            equals:
              left:
                device:
                  devices:
                    - &landing_shelf_light xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                  component: main
                  capability: switch
                  attribute: switch
                  trigger: Never
              right:
                  string: off
            then:
              - command:
                  devices:
                    - &landing_virtual xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                  commands:
                    - component: main
                      capability: switch
                      command: on
              - command:
                  devices:
                    - *landing_shelf_light
                  commands:
                    - component: main
                      capability: switch
                      command: on
            else:
              - command:
                  devices:
                    - *landing_virtual
                  commands:
                    - component: main
                      capability: switch
                      command: off
              - command:
                  devices:
                    - *landing_shelf_light
                  commands:
                    - component: main
                      capability: switch
                      command: off

The ‘landing_virtual’ virtual motion sensor has both switch and motion capabilities so I can treat it like a switch in this rule.

I actually have multiple copies of this rule, one for each button I have doing the same thing. In webCoRE you can differentiate between ‘any button is pushed’ (condition) and ‘any button gets pushed’ (trigger) but if there is a way of doing the same with Rules I hadn’t spotted it at the time.

Last, but by no means least. If the light is turned off by any mechanism (app, ActionTiles, Google etc) I need to clear the manual override.

name: '[R] Virtual: Landing'
actions:
  - if:
      and:
        - equals:
            left:
              device:
                devices:
                  - &landing_shelf_light xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                component: main
                capability: switch
                attribute: switch
            right:
              string: off
        - equals:
            left:
              device:
                devices:
                  - &landing_virtual xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                component: main
                capability: motionSensor
                attribute: motion
                trigger: Never
            right:
              string: active
      then:
        - command:
            devices:
              - *landing_virtual
            commands:
              - component: main
                capability: switch
                command: off

I wrote ‘I could probably turn off triggering on the motion sensor there, but that was documented after I last pondered the rule at all.’ but it turns out I had pondered it and had turned it off. I do have some unnecessary triggering going on somewhere.

While I am here, here is how I turn off a switch if it has been running for 45 minutes. You can do something similar to turn off lights if motion remains inactive for a while.

name: '[R] Fan Timer: Bedroom'
actions:
  - if:
      remains:
        equals:
          left:
            device:
              devices:
                - &bedroom_fan xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
              component: main
              capability: switch
              attribute: switch
          right:
            string: on
        duration:
          value:
            integer: 45
          unit: Minute
      then:
        - command:
            devices:
              - *bedroom_fan
            commands:
              - component: main
                capability: switch
                command: off

The [R] in the name of the rule just helps me identify rules in the app history.

1 Like

You can use it to make a new virtual device with Edge drive [ST Edge] vEdge Creator: a virtual device generator for end users

but maybe your question wasn’t how to make them, but how to implement them in the new scheme of things :slight_smile: sorry for that I don’t have an answer, still too far for me

No, it will not be an automatic switch because it is a community written driver.

But once the automatic transition occurs it will be easy to switch over to the community driver.

1 Like