Hello,
I want to setup automation rules, so I can reuse the logic and just swap out the parameters or devices.
I know I can copy rules, but if I want to update the logic, I have to go to each rule and then update it.
Hello,
I want to setup automation rules, so I can reuse the logic and just swap out the parameters or devices.
I know I can copy rules, but if I want to update the logic, I have to go to each rule and then update it.
I don't know if you've read that or not.
Are you looking to use Rule Machine or other built-in apps or write your own? Rule Machine can't use devices as "variables," though you can otherwise use trigger-less rules that you just run from other rules as a way to effectively share actions among different rules. If that's what you're looking for, webCoRE can, so that's one place you can look.
An alternative is writing a custom app yourself, as hinted at above. Specifically, I would look at the app documentation, including:
You could write an app that you either install multiple instances of (one for each device or whatnot) and just update your app code when you want to change the logic, or if you're able to figure out a way to track each device separately in your app if needed, you could select all devices in a single app and handle things that way.
It's hard to say more without a concrete example of something you're actually trying to do, but these are a few ideas that sound like the general idea of what you may want.
For us newbies, it would be a great option to get started with Apps to be able to save a rule from Rule Machine as an app. I realize that a conversion is required.
Even after the latest version of SmartThings, that RM and Apps have a significant learning hurdle.
If you want a starting point, I can offer that template. It does nothing but it does install and provides a basic structure to start groovy coding.
Grab the source from github (raw) and paste it into the Apps Code menu item as a New App. Save it. Then in Apps, click Add user app, and find that New App Template.
It offers a Device Selector (capability.actuator) as well as a numeric input.
That would be a significant undertaking, though not technically impossible -- but there's nothing about RM itself that would help (it's an app itself that works via the same means any app you could write would work--not like it's internally writing a Groovy app for you or anything, which it seems you may realize). Writing a Groovy app isn't really what I'd consider "newbie" level, assuming you mean new to everything and not just writing apps or writing code in general, so this particular request may be somewhat niche. But anyone could write any app-generation tool they want--just seems no one has, possibly for the low effort-to-reward ration when things like RM and webCoRE, to say nothing about the variety of built-in (and user) apps, exist.
If you want to write an app, I think a better approach would be to learn how. If you have the general skills, it isn't that hard to learn the environment, and a lot has been added to the Hubitat developer docs in the last year or so to help you get started. For example:
The above appears to be another "template" you can use to get started. Lots of people here are also happy to help if you get stuck.
Two things:
There are a number of example apps in our public GitHub repo. They all do something real and useful. They also show some of the basics of creating an app, and are possible starting points to be modified into something different. The way I learned to create apps was just that, I took from others and modified what they had done.
For quite a few years now I thought that the creator of webCoRE missed an opportunity when he created it. It's a very good tool with a great UI for creating automations. It takes that UI and spits out a coded representation of the automation, and that coded representation is later run as the Piston. Both of those steps are non-trivial. What I thought he missed was that instead of putting out a coded representation of the automation, he could have spit out Groovy code, an app that implemented the automation directly. Had he done that, the second step would have been avoided completely, and resulting app would have been super efficient.
I know enough computer science to know the challenge what I just wrote represents. It would be a difficult, although achievable project. The result would be very close to what you are describing. I keep tossing this idea out in public in hopes that someone would take it on.
Ironically, Rule Machine actually does something like this. It has snippets of code that run depending upon the definition of the rule. Each action runs such a snippet. So in theory, a variation of Rule Machine could be created that writes those snippets of code out to create an app with equivalent functionality. Unfortunately, Rule Machine has grown to be so feature rich that this doesn't make much sense as a practical matter, and the resulting code wouldn't be the sort that makes a decent template. There is too much complexity.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.