openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
218 stars 238 forks source link

pages yaml code - reference rules by real name - not over a number #1363

Closed JoergLaub closed 2 months ago

JoergLaub commented 2 years ago

Why isn't possible to reference a rule (from .rules file) in the YAML code of widget with here real name? If I configure the widget over the web interface, it's possible to select the action rule from a list with the real name of the rule. Then the YAML code use the 'number' of this rule in the rulefile.... it works :-( Then I tryed to use the 'original' rule name in the YAML code - HHTP unknown error... I have over 100 rules in my 'old' OH2 configuration (.rules) and so it is not possible to use them usefully in the pages. Any correction in the *.rules destroy the main rule-system.

rkoshak commented 2 years ago

The answer to the "why" part of this is that the <name of .rules file>-N is the "real name" of the rule. It's the unique identifier. The stuff you put after rule "some description of the rule" is not guaranteed to be unique and therefore cannot be used to reference the rule.

I know that in JS Scripting and I think in jRuby and others as well, it's possible to define the UID of the rule when you define it in a text file (it's possible to define the UID for a rule in the UI no matter what rules language you are using).

So my recommendation would be to make it so users can define the UID for the rule in .rules file too.

In the mean time, as a work around, us an Item to trigger the rule instead of trying to call the rule directly from a UI widget, same as you'd have done with HABPanel or sitemaps.

JoergLaub commented 2 years ago

I don't understand. OH3-Doc: rule "" ... Each rule must have a unique name This means not "some description of the rule". Why ist ist not possible to use this unique name of the rule - for example as 'UID'. In all other configuration files (.items, .things) is it normal to define und use unique names as 'UID's. When I define a Widget with a rule over 'Administration-Pages' the selection-list for the rules present the rule-names not UIDs - that's ok and work - why not in the YAML-code?

florian-h05 commented 2 months ago

In all other configuration files (.items, .things) is it normal to define und use unique names as 'UID's.

Yeah, but in contrast to them rule names are allowed to contain spaces and other chars, so they are more like labels than unique identifiers.

When I define a Widget with a rule over 'Administration-Pages' the selection-list for the rules present the rule-names not UIDs - that's ok and work - why not in the YAML-code?

When you add a rule in the UI, it has a rule ID, which is the unque identifier and the label, which is what Main UI displays primarily. If you run such a rule from a page, it is referenced by its ID, the UI just displays the label when selecting the rule.

I will close this issue here, in case you still need to define the UID of a rule, please open an issue at the openhab-core repo.