Skip to content

Yaml rules and rule templates documentation#2737

Merged
florian-h05 merged 6 commits into
openhab:mainfrom
Nadahar:yaml-rules
Jul 5, 2026
Merged

Yaml rules and rule templates documentation#2737
florian-h05 merged 6 commits into
openhab:mainfrom
Nadahar:yaml-rules

Conversation

@Nadahar

@Nadahar Nadahar commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

I'm working on creating corresponding sections for rules and rule templates that exist for other YAML definitions.

@netlify

netlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Thanks for your pull request to the openHAB documentation! The result can be previewed at the URL below (this comment and the preview will be updated if you add more commits).

Built without sensitive environment variables

Name Link
🔨 Latest commit 96fa3da
🔍 Latest deploy log https://app.netlify.com/projects/openhab-docs-preview/deploys/6a48fe1e534cac000843d267
😎 Deploy Preview https://deploy-preview-2737--openhab-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Nadahar

Nadahar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

I can't find any documentation for the different triggers, conditions and actions. It would have been nice to be able to link directly to the documentation for the specific type, but as I can't find them, I can't do that. I'm not going to make documentation for all of those in this PR.

Is it really the case that they aren't documented?

@rkoshak

rkoshak commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Is it really the case that they aren't documented?

Do you mean something like https://next.openhab.org/docs/configuration/jsr223.html#triggertype-objects or are you looking for different documentation. That's the only rules language neutral set of docs I'm aware of. Indeed they are not super user friendly.

In general each rules language ends up documenting these all separately (e.g. https://next.openhab.org/docs/configuration/rules-dsl.html#rule-triggers, https://next.openhab.org/addons/automation/jsscripting/#jsrule, etc.). Non one has really documented the UI rules stuff before now as the UI does an OK job of being self documenting. But with the new YAML format this is probably a gap in the docs that needs to be filled.

@rkoshak rkoshak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I at least have all the information I would need to write a rule or rule template with what's here. I intend to watch this with interest and will try to apply them by converting some of my rule tempaltes to YAML in the coming days.

Comment thread configuration/yaml/rules.md
@Nadahar

Nadahar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Do you mean something like https://next.openhab.org/docs/configuration/jsr223.html#triggertype-objects or are you looking for different documentation. That's the only rules language neutral set of docs I'm aware of. Indeed they are not super user friendly.

Yes, that's spot on. That seems to only cover triggers though, not conditions and actions. I think that when I tried to search, I searched for "condition codes", not "trigger codes", which is why I found nothing. I imagined that they should all be there somewhere. It's a bit strange that these are placed under JSR223, since they apply system-wide and aren't really affiliated specifically with JSR223, but I guess that's where the need arose?

Ideally, I think they should all be documented like that, for all module types, in a "neutral place" that more specialized documentation can then link to.

It seems that there's no way to link to a specific type, which I would have preferred from the table of types - but I'll have to find a way to reference that "table" for triggers.

@Nadahar

Nadahar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

In general each rules language ends up documenting these all separately (e.g. https://next.openhab.org/docs/configuration/rules-dsl.html#rule-triggers, https://next.openhab.org/addons/automation/jsscripting/#jsrule, etc.). Non one has really documented the UI rules stuff before now as the UI does an OK job of being self documenting. But with the new YAML format this is probably a gap in the docs that needs to be filled.

I've linked to the various sections of the DSL documentation, but it's not really a good fit. Not everything is covered in the DSL documentation, and the names of the properties aren't mentioned at all, since you use the DSL syntax to set them, not the names of the properties.

Even if each language document things individually, I think that a "core documentation" of the basic functionality of the module and the name and syntax of the parameters/properties would be helpful. Otherwise, those will just have to be repeated "everywhere", and the chance that they are maintained are even slimmer.

@rkoshak

rkoshak commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

It's a bit strange that these are placed under JSR223, since they apply system-wide and aren't really affiliated specifically with JSR223, but I guess that's where the need arose?

Probably because of history. All the triggers were originally documented in the Rules DSL docs. Then when JSR223 was documented there needed to be a lower level set of information (audience was primarily automation add-on developers I think) so they got documented there. And then each individualindividual automation add-on documetns how they expose the JSR223 stuff.

Since conditions and the non-script actions were only supported in MainUI until very recently, I think they never got documented at all anywhere else.

Ideally, I think they should all be documented like that, for all module types, in a "neutral place" that more specialized documentation can then link to.

I agree. I'm not sure the best place though, JSR223 has served as that place up until now.

@Nadahar

Nadahar commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I just found that when serializing to YAML, the order of modules is either random, or "condition-action-trigger". That needs to be looked at later.

I also noticed that there seems to be a regression when creating a new rule from scratch in YAML view, the UID is overwritten by the autogenerated one. I know that this worked previously during development, so some other change must have clobbered it.

@rkoshak

rkoshak commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

I'm not as concerned about that, though the order there would be nice if the order were consistent across the boardtoo. I'm more concerned that the examples in the docs maintain the same order. I wouldn't hold up this PR by a change to the serialization.

@Nadahar

Nadahar commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I wouldn't hold up this PR by a change to the serialization.

I didn't intend to. I just noted some things I discovered while tinkering. The order of serialization will have to be changed post 5.2.0, but it's probably not very hard to fix, and I think it would be better if they appeared in a more "logical" order than "condition-action-trigger".

@Nadahar

Nadahar commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

What is "holding up" this PR at the moment is rather that I've gotten the idea that I should use local AI for proofreading/consistency checks into my head, and I have a problem to admit defeat and just give up. The tools (the VS code extensions primarily) are mostly completely useless and broken, and the ability to do these things are mostly theoretical, even if the local model seems to handle the tasks reasonably, I can't find any extensions that can actually manage the formatting/data exchange correctly, so they end up completely breaking the document.

I must soon accept that I'm beating a dead horse, and just get on with it, relying on humans to catch my mistakes instead 😉

@Nadahar

Nadahar commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I agree. I'm not sure the best place though, JSR223 has served as that place up until now.

Looking at the documentation, I think "Concepts -> Rules" would be where it would fit the best. Despite the section being called concepts, the documentation goes into some considerable details about triggers, conditions and actions - but I must say that I find it somewhat confusing and incomplete. Still, judging by the content found there, I'd say that's where it would fit.

More ideally, I think I could have been under "Configuration Guide -> Rules" (doesn't exist, but could/should, just like it does for Things and Items). It would "fit" better to do that kind of details there, but I think that would also mean that a lot of the details from the "Concepts" section should also be moved there, and "Concepts" should only describe the overarching structure. That would mean a somewhat larger refactoring/restructuring though, so it's probably not viable to do short-term.

@rkoshak

rkoshak commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I've had some luck with Open Web UI as the interface to my local LLMs. It presents an OpenAI compatable API so anything that can connect to OpenAI can use my local LLMs instead. That opens up a whole range of capabilities. You can also add in stuff like websearch, MCP and the like. I don't know if that can help at all but it's made it a lot easier for me to integrate local LLMs into various services. I haven't tried VSCode yet (maybe not ever) though.

@Nadahar

Nadahar commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I don't know if that can help at all but it's made it a lot easier for me to integrate local LLMs into various services. I haven't tried VSCode yet (maybe not ever) though.

The needs vary depending on what you want to do, the reason I'm so "insistent" on VS Code (or one of its alternatives like VSCodium or Eclipse Theia) is that I primarily want it for "review"/improvement suggestions for documents I write myself. To make that useful, there has to be some integration with the editor.

I guess that if you want the model to generate content, integration might not be that important, but as I see it, AI generated content is mostly "slop" and not of much interest to me, except for filling in boilerplate code that I can use as a starting point. Which leads back to why I keep focusing on VS Code. I know that there are Eclipse plugins available too, but I haven't looked at them at all for two reasons:

  • I expect them to have come even shorter than the VS Code extensions, and they are probably pretty much useless at this point.
  • I use Eclipse for Java, not for other languages, and I don't really need much "help" with Java. Boilerplate population is the exception, but that can be arranged outside the IDE/editor.

VS Code is where I mess with all the stuff I don't really know that well, so that's where it's most useful.

@Nadahar

Nadahar commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

I gave OpenWebUI a try, but it wasn't easy to even get to where I could configure the Ollama connection. Once I finally did, I get "communications problems" similar to what I've seen from some of the VS Code extensions. I don't get what this is about, but there clearly is some fundamental issue with communication protocols that means that the JSON they are supposed to be exchanging ends up in the chat:

image

edit: Something changed without me doing anything, and it actually started replying sensibly to questions. Since it's very slow, I don't have much more to say other than it seems to be working.

@Nadahar Nadahar force-pushed the yaml-rules branch 5 times, most recently from 40133f8 to a250477 Compare July 2, 2026 17:15
@Nadahar

Nadahar commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I've added brand-new sections for standard triggers, conditions and actions under "Concepts -> Rules". I don't really feel that it fits under concepts, it's too specific for that, but it's the only place I could find to "integrate it" without rewriting a whole lot. The rule concept description seems very dated as well, there are things that are plain wrong there (like that "some rule engines" supports conditions), and other things that just don't describe the current situation very well IMO.

If the rest of the rules documentation is refactored/restructured in the future, these pages could be moved to a more suitable location, but I think it's better to have them here, somewhat misplaced, than to not have them at all.

I'll update the YAML documentation to reference these new pages for rule modules, so that each type can have explicit documentation.

@rkoshak Can you see what you think about what I've done under "Concepts -> Rules"?

@Nadahar

Nadahar commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

This has been quite some extra work, that I wasn't really prepared for, so I might have been a bit "fast and loose" at times, so there's the potential for some "human slop" in there. I've used a local LLM to review it, but there might still be things that should be rephrased or changed in there.

@Nadahar Nadahar force-pushed the yaml-rules branch 2 times, most recently from 9ded7f5 to b960b89 Compare July 2, 2026 22:05
@Nadahar

Nadahar commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

When working with this, I come across some "challenges" that I can't fix. Among them are configuration parameter context. I can only find it somewhat covered in the add-ons developer section, so all I can do is link there, even though a user looking to use a rule template shouldn't have to understand anything about add-on development. The filterCriteria is part of the same "challenge", the information about how exactly to use it is very sparse. I've left things where I'm very uncertain intentionally vague.

Configuration parameter verify is another problematic one, I think it's supposed to make the UI ask for confirmation if you change it, but I'm not so sure that it works with MainUI.

Overall, I'd say that the documentation for configuration description parameters and their use is weak, and it should be improved and put in a dedicated location, outside add-on development documentation.

Ravi Nadahar added 2 commits July 3, 2026 19:15
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…actions

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Ravi Nadahar added 2 commits July 3, 2026 19:15
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@Nadahar Nadahar marked this pull request as ready for review July 3, 2026 17:15
@Nadahar

Nadahar commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@florian-h05 @lolodomo @rkoshak This is now ready for review, and should be a part of the 5.2.0 documentation. It's been quite a lot of work, and I've pushed myself quite a lot to get it done. I know that it's a lot to review, and I know that it's not the job of either of you, but I can't quite think of anybody else that can do it.

The upside is that we can easily correct mistakes later, without waiting for a new release.

@Nadahar Nadahar requested a review from rkoshak July 3, 2026 17:18
@openhab-bot

Copy link
Copy Markdown
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/help-making-a-javascript-example/169675/12

@florian-h05 florian-h05 requested review from Copilot and removed request for rkoshak July 3, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation pages to bring YAML rules and rule templates in line with other YAML-definition docs, and expands the rules concepts documentation with dedicated “standard triggers/conditions/actions” reference pages. Updates navigation (YAML index + sidebar) to surface the new content.

Changes:

  • Add new YAML documentation pages for rules and ruleTemplates, including examples.
  • Add new “Standard Triggers / Conditions / Actions” concept pages and link them from the rules concept page.
  • Update YAML index page and VuePress sidebar to include the new pages.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
configuration/yaml/ruletemplates.md New documentation for YAML rule templates, syntax and examples.
configuration/yaml/rules.md New documentation for YAML rules, including standard module type references.
configuration/yaml/index.md Adds rules / ruleTemplates to the YAML index navigation and examples.
concepts/standard-triggers.md New reference page describing standard trigger types and parameters.
concepts/standard-conditions.md New reference page describing standard condition types and parameters.
concepts/standard-actions.md New reference page describing standard action types and parameters.
concepts/rules.md Enhances rules concept docs with links to the new standard trigger/condition/action pages.
.vuepress/docs-sidebar.js Updates sidebar structure to include the new rules children and YAML pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread configuration/yaml/ruletemplates.md
Comment thread configuration/yaml/ruletemplates.md
Comment thread configuration/yaml/ruletemplates.md Outdated
Comment thread configuration/yaml/ruletemplates.md Outdated
Comment thread configuration/yaml/ruletemplates.md Outdated
Comment thread configuration/yaml/rules.md Outdated
Comment thread configuration/yaml/rules.md Outdated
Comment thread concepts/rules.md Outdated
Comment thread concepts/rules.md Outdated
Comment thread concepts/rules.md Outdated
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Comment thread concepts/standard-actions.md Outdated
Comment thread concepts/standard-conditions.md Outdated
Comment thread concepts/standard-triggers.md Outdated
Comment thread configuration/yaml/rules.md Outdated
@lolodomo

lolodomo commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

I have read everything except ruletemplates.md. Will try to finish today.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@florian-h05

Copy link
Copy Markdown
Contributor

@lolodomo Let me know when you are finished reading it - I'll then hava a swift look and merge it.

@lolodomo

lolodomo commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@lolodomo Let me know when you are finished reading it - I'll then hava a swift look and merge it.

Finished and no additional comment. You can merge.

| `label` | ☐ | The trigger label. |
| `description` | ☐ | The trigger description. |
| `type` | ☑ | The trigger type, which must be a valid/existing trigger type. This is what decides how the trigger works, what mechanism is in use, and which configuration properties must be present. |
| `config` | ▧ | A key-value map of the trigger's configuration. See the trigger type documentation for which keys exist, are mandatory, and what their values should be. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this checkbox signal?

From how it looks in the preview, I think Y / N entries might be "clearer" when skimming through.

@Nadahar Nadahar Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means "both", "neither" or "conditionally true" I guess. In this case it's because it depends on type. Some trigger types (most it fact) requires at least one configuration parameter to work, but some can do without (because of defaults mostly as far as I can remember for triggers). Some conditions, like "holiday condition", have no configuration at all.

I was looking for a checkbox with a filled square inside, which is the "standard" that I guess everybody will recognize from using UIs, but it seems that it doesn't exist in Unicode, and this one was the closest thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florian-h05 I'm not really sure what you're suggesting here, I don't think Y/N/Maybe would be better, I think it's much easier to "read" a checkbox, and I doubt that "unclear meaning" of ▧ will cause much of an issue, since the description text spells out that it depends on circumstances.

What is important is to get this in a part of the 5.2.0 documentation, especially since I've linked to it in my suggestion in the blog post.

@lolodomo

lolodomo commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Let's try to merge that before documentation for OH 5.2 is freezed.

@florian-h05 florian-h05 merged commit cc3a6cc into openhab:main Jul 5, 2026
5 checks passed
@florian-h05 florian-h05 added this to the 5.2 milestone Jul 5, 2026
@Nadahar Nadahar deleted the yaml-rules branch July 5, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants