CoRE and Piston Rules Engine, first design steps

I think providing a way to run the rules manually is important and shouldn’t be that difficult to implement.

I’m not saying it’s a great UI, but the Switches screen of the Simple Device Viewer SmartApp toggles the switches when they are pressed without using “submitOnChange”.

You mean you’ll use SmartThings in the way the platform was designed?

Bruce said it way too many times:

1 Like

Yeah, but with specialized apps that do more than the flagship one.

You know, it will turn the lights off too…

Smart Lighting does that too, no need to reinvent the wheel there …

href generated vs submitOnChange generated events, potatoes patatoes…

where’s the GD button input?, why do we have to hack into dynamic page events in the first place?

How about a freaking button…
Oh, wait!, here we go, how annoying is this?

def buttonsPage() {
    dynamicPage(name: "buttonsPage", title: "Every 'button' type") {
        section("Simple Buttons") {
            paragraph "If there are an odd number of buttons, the last button will span the entire view area."
            buttons(name: "buttons1", title: "1 button", buttons: [
                    [label: "bar", action: "bar"]
            ])
            buttons(name: "buttons2", title: "2 buttons", buttons: [
                    [label: "foo", action: "foo"],
                    [label: "bar", action: "bar"]
            ])
            buttons(name: "buttons3", title: "3 buttons", buttons: [
                    [label: "foo", action: "foo"],
                    [label: "bar", action: "bar"],
                    [label: "baz", action: "baz"]
            ])
            buttons(name: "buttonsWithImage", title: "This element has an image and a long title.", description: "I am setting long title and descriptions to test the offset", image: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", buttons: [
                    [label: "foo", action: "foo"],
                    [label: "bar", action: "bar"]
            ])
        }
        section("Colored Buttons") {
            buttons(name: "buttonsColoredSpecial", title: "special strings", description: "SmartThings highly recommends using these colors", buttons: [
                    [label: "complete", action: "bar", backgroundColor: "complete"],
                    [label: "required", action: "bar", backgroundColor: "required"]
            ])
            buttons(name: "buttonsColoredHex", title: "hex values work", buttons: [
                    [label: "bg: #000dff", action: "foo", backgroundColor: "#000dff"],
                    [label: "fg: #ffac00", action: "foo", color: "#ffac00"],
                    [label: "both fg and bg", action: "foo", color: "#ffac00", backgroundColor: "#000dff"]
            ])
            buttons(name: "buttonsColoredString", title: "strings work too", buttons: [
                    [label: "green", action: "foo", backgroundColor: "green"],
                    [label: "red", action: "foo", backgroundColor: "red"],
                    [label: "both fg and bg", action: "foo", color: "red", backgroundColor: "green"]
            ])
        }
    }

}
1 Like

I was being facicious. Lol. Thing is, that’s almost all it can do!

href doesn’t have the Android issue and I was just pointing out that it is possible to create a screen that allows you to execute rules.

You’re right, there should be a button and a bunch of other UI related features like full size images.

:point_up_2: what Mike said… +1,000!!!

I am hacking my way through this pain now with a SA I am trying to create for multi-branded cameras… ponderous!

you can do images right now…, unless you mean something different…

href (
	url			: "https://raw.githubusercontent.com/MikeMaxwell/zmm/master/falseReduction.png"
	, style			: "embedded"
	, required		: false
	, description		: "Tap to view the zone graphic..."
	, title			: ""
)
1 Like

Time to put my money where my mouth is. So I’ve starting meddling with the ST UI trying to implement something RM did not directly allow: condition grouping. I know RM allows evaluation of other rules within a rule, effectively providing such grouping capabilities, but I think having it right in the engine as an option is better/easier to use/maintain.

I only concentrated on getting the UI to allow adding groups/conditions up to 3 levels over the main level. So you can go as deep as A AND (B OR (C AND (D OR E))). Also added the XOR logical operation - which may never be useful, not sure yet.

I also tried to maintain an object-oriented version of the app for easy JSON conversion, but if this is to ever allow both UI and web configuration, then the app information itself has to rely on the State variable, as I cannot modify the Settings variable programmatically (outside the UI - with the user actually typing in things). Data is not yet populated into the state.config.app object. To do.

The app doesn’t actually do anything, other than allowing the creation of conditions (which also don’t do anything yet) and groups of conditions. Just a proof of concept, if you want.

https://raw.githubusercontent.com/ady624/HomeCloudHub/master/smartapps/ady624/smartthinger.src/smartthinger.groovy

Any positive comments are welcome. Any critical ones, no. Just kidding, any comments are welcome, please feel free to propose changes.

And to those who are saying they don’t need anything since they have RM and that nothing will ever better RM, they don’t have to use anything else than RM. But I can only think of the newcomers who are not so lucky to have RM. We cannot be so selfish, can we?

IMPORTANT: If anyone decides to help on this project, then they have to agree to Apache License v2.0 being the only license to be used for this project. I am willing to work on this as long as it stays Open Source and available to anyone. Thank you.

Thank you,
Adrian

12 Likes

Rule Machine does allow condition grouping… unless I’m not understanding what you’re saying?

I’m looking forward to seeing what direction you head. I think you’ll find nothing but support from this community for another freely-available rules engine that can exist without any outside hosting.

Regardless of how ST was originally designed, I think the success of generalized rules engines speaks for itself.

1 Like

Can you combine ORs and ANDs in a single rule? Say:

([First Floor Door is open] and [First Floor Window is open]) OR [Back Porch Motion detected]

UPDATE: Apparently there is something with parenthesis support, but it’s so convoluted and apparently complicated that I can’t really imagine how most people would use it :frowning:

I don’t think is complicated man, you just need to get used to it. For those with BO, SQL even Excel exposure comes natural…

4 Likes

Yep.

It’s not so bad once you get used to it. The UI leaves a ton to be desired… that’s the downside of building this all within a Smart App. Keeping a Smart App simple allows for better UI… but then of course you have a simple Smart App.

1 Like

Do you find this easy for the average user?



Lookup my take on complex conditions (link above) - provided, I am using generic texts (Condition 1, Condition 2) that need to be replaced with “Front Door open”, etc.

It doesn’t have to be complicated… It can be flexible and easy to understand/use. Just very different approaches

I’m the first to admit, even now, this confuses me, it’s just not easy to process quickly as I work through EXISTING rules. Setting them up with and/or hasn’t been too much trouble, but then again I’m very good at Excel formula’s and scripting, so not a “normal user.”

I once showed my wife how to set up an OR in RM and she just walked off…so you are correct.

2 Likes

Yeah I installed your code and I pretty quickly got lost … but I assume that’s because I’m doing something totally wrong and I don’t understand your system yet. There’s a learning curve to any app, and it’s really hard for me to learn something in the abstract. I can’t wait to take another look once the app has some basic functionality!

1 Like

Working on getting a minimal set of conditions and make the conditions themselves user readable so that you can read them.

For example, to add the rule:

(Front Door opens AND Front Porch Motion sensed) OR (Backyard motion sensed) you’d have to follow these steps:

  1. go to If
  2. Add a condition group
  3. Add a condition in that group and set it to Frond Door = open
  4. Add a second condition in that group and set it to Front Porch Motion = active
  5. Go back out of the group
  6. Add a condition and set it to Backyard motion = active
  7. Under advanced options set the Logical condition to OR

Like I said, you have to look beyond the unfinished details :slight_smile:
Done.

1 Like

I do this all of the time. But I’m really good at logic programming.