The End of Groovy Has Arrived

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

According to the FAQ, devices WILL be migrated to community Edge drivers if the fingerprint matches.

3 Likes

That is good to know. But he will still need to manually add the community written edge driver to his hub.

Yup, just install it and should be good to go.

thanks for this
installed the driver
from Channel ā€œMariano Shared Beta Driverā€
Should I worry that this is beta? Ie if it migrates to this driver could the driver then disappear?

Anyone know if there is an edge replacement for
Google Sheets Logging smartapp? Or will that just die when Groovy IDE dies?

2 Likes

One a driver is installed it can’t be removed by the developer, but it can be automatically updated by the developer.

1 Like

Devices have state. I often use a Virtual Switch to store such.

1 Like

I’m doing that with the built-in routines. I have one routine for button pushing and another for motion. I control when those routines are active using a virtual switch as a precondition. The result is this:

If Between 10pm and Sunrise (Nighttime virtual switch is on)
If Motion is detected and the light is not already on, turn it on at 1% and auto turn off after 2 mins
If Button is toggled up and the light is not already on, turn it on at 100% and don’t turn it off

Turn on Nighttime virtual switch at 10pm and turn it off at Sunrise

I have the GE motion switch/dimmers which support Occupancy, Vacancy, and Manual modes. Mine operate in vacancy mode where motion does not active the light, only the button.

There is also the Sharptools rules engine which integrates with Smartthings, however, your rules aren’t running locally on your hub. All three of my routines above operate locally on my hub and are wicked fast when activated.

2 Likes

JDRoberts can comment better than I can, however, my understanding is that the framework for developing new SmartApps is not complete so all existing Groovy SmartApps die when the IDE goes away. ST is converting SmartLighting and SevereWeather into plugins so they will live on. One popular SmartApp is Lock User Manager (LUM) from Rboy and they post status here Migration FAQ's which gives you a flavor for how things are going.

1 Like

I have a bunch of devices with no standard fingerprints, below is an example. There work perfectly under Groovy (without custom device handlers, but sometimes requiring manual device handlers selection) and quite a few people on here use them. Generally from brands like Aubess and intended for Tuya. Can these be linked to the Edge drivers replacing the IDE drivers they work fine with or will they all become useless?

Data: application: 41

  • endpointId: 01
  • manufacturer: _TZ3000_mx3vgyea
  • model: TS000F
  • zigbeeNodeType: ROUTER

Raw Description: 01 0104 0100 01 08 0000 0003 0004 0005 0006 000A E000 1000 01 0019

Ok, So I had though the new start date was 10/15, not 9/30. However, a friend (who just started with Hubitat) told me he’d seen comments about it happening already. So I logged into the IDE and yes, one of my drivers had been switched. I’m not enrolled in beta and had not loaded new drivers, deciding to take the wait and see (and pray) approach. I confirmed it in the app as well. At first offline, due to a dead battery (a bali shade remote, which I rarely use), so I replaced the battery, confirmed the remote worked fine and then after 5-10 minutes it showed up again as active in the app and appeared to function (battery level only). In the IDE, it shows up as cloud and active though. Is all the IDE info no longer valid once moved to Edge? Has anyone else seen a diver update?

have you added any new devices in the past couple of months? (I can’t remember the date they started). Adding new devices or re-adding existing ones should get Edge Drivers unless you are using custom device handlers.

Yes, you can not rely on IDE for Edge devices… no routing, no ID#, shows as Unknown Device in routing tables for non-Edge devices, etc.

Also, many cloud-to-cloud integrations would display as Placeholder in IDE reflecting the new architecture of the platform.

1 Like

no, this device has been on the system fora couple of years with no changes. I’ve added other things a few months ago, but they all showed up as the older DTHs. I know this one just m,oved this week as I checked it about a week ago and there were no Edge drivers at that time.

I’m wondering that since the device had been offline due to a dead battery, possibly for some time, if the hub had to add the device back, causing it to pick up the new driver.

But it was offline a week or so ago, when I checked (and tried to document) all of my devices. And the battery was dead at that time, And it was not an edge driver. This driver would have been a logical first one to implement as if it got screwed up it would have little impact. I never got my other set of blinds set up with the remote, so I can’t tell if both would have been upgraded at the same time, which would have been expected.