Show generated code in rule machine et al

I'd really like the ability to see the code that RM generates, and optionally turn it into a custom app.

Great way for newbies to get a taste, and for us experienced hands get a jump start on the API.

1 Like

AFAIK, it doesn't generate groovy code.

2 Likes

Yeah, it will be typical generated syntax, but there's a lot of benefit being able to see what's happening and optionally go ahead and use it as the basis for a custom app.

I doubt they will ever release this exact code. However, there are examples of other apps in the Hubitat Github.

1 Like

With the caveat that I know basically nothing about coding, so may have entirely misunderstood, I think this thread might be relevant.

If I’m not mistaken, what you’re asking for doesn’t exist. Rule Machine is itself just another groovy app, like all others (whether built-in or written by a community developer).

2 Likes

Your understanding is exactly the same as mine.

Rules created in RM are not mini applets in Groovy. Rules generate data structures that are interpreted by the RM Groovy code.

This part is unlikely, unless that custom app had a shared Groovy codebase with Rule Machine.

3 Likes

As mentioned above, Rule Machine does not generate Groovy code; Rule Machine itself is a Groovy app that is designed to prevent you from needing to write custom code if you don't want to, and because it's generalized rule engine rather than an app aimed at one specific purpose (e.g., the Notifications app), its UI is quite complex and so are the options you can choose in it. What you see is displayed as a sort of pseudo-code, but that's just a summary of the options you made (presumably because they decided that would be the most concise way to display it), not actual code. It ultimately works the same as any app you could write yourself. In fact, it originated as a custom app on SmartThings, which has a similar Groovy app execution environment--or did at the time when Hubitat was created.

If you want to write custom apps, you can. Rule Machine just isn't the way to do it. See the developer docs, including the new overview and "building a simple app" tutorial. Hubitat also has some examples published, as mentioned above, and the Community (here!) is a great resource if you get stuck.

If you don't want to write custom apps...then there are a lot options built-in, Rule Machine being one. :smiley:

4 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.