Rules with tag "Script" vanish in UI

  • Platform information:
    • Hardware: Synology DS920+
    • OS: DSM7 wiht Docker
    • Java Runtime Environment: Unknown - whatever the official Openhab docker image contains.
    • openHAB version: .latest - 3.3.0
  • Issue of the topic: Add tag “Script” to a rule, it then vanishes from the UI

As soon as I add the tag “Script” to a rule, it vanishes from the UI. The automation_rules.json contains the right tags, and if I remove the “Script” tag from there, it reappears in the UI. Anybody an explanation for that?

I would really like to tag my rules depending on their category - trigger, schedule, command, script. Quite annoying :slight_smile:

They do not disappear; they move to the Script page. In MainUI “scripts” are just rules that have the “script” tag. This tag is applied automatically if you create the script via the Script page, but manually adding the tag to any rule will also result in the script being moved over. This is one of a suite of unfortunate side effects of the overuse of the word ‘script’.

Just choose a slightly different tag “Scripts” or “MyScript” etc.

1 Like

LOL - super intuitive behavior… :smiley: thx anyways.
Software should not make decisions based on user defned tags. IMHO at least. Tags are owned by me, not by the software.

In addition: I have a perfectly working script rule. I can edit everything as long as it is in the rules folder. After adding the script tag and navigating to Scripts, I see a blank page with
and nothing else. So there definitely is something going wrong. After removing the “Script” tag in the json and restarting OH, I can again access it as intended through the rules folder.

But a “script” in the UI scheme does not have triggers etc., so if you create your perfect rule and then claim it to be a script by tag … it’s invalid as a “script”.

I’ve no doubt if you create a script using UI and tag it “rule” it will go a bit funny too.

I would argue that in this case “Script” is not a user defined tag; it is reserved for this purpose. Just as all the semantic tags are reserved in the item tag system. But in both cases you can apply those tags via some UI method (Model page/Script page) or manually on the details page for items/rules. It would be a waste of developer time to create a whole secondary system for classifying these things just so that a few additional words are available as custom user tags.

For rules the only two reserved tags are “Script” and “Schedule”. All other tags are ignored and the default will be to list the rule under the Rules menu.

Also, a rule with just a single Script Action is a valid rule. So even that would be fine.

The purpose of the tags is to provide a UI for editing and managing the rules tailored for a specific purpose. If you have a rule tagged with “Script” when you open the rule it will jump straight to the code editor on the Script Action. Why show or mess with triggers, conditions, or additional actions when only the one Script Action is allowed?

The “Schedule” tag and menu is a little less constrained. It shows when your rules will run on a calendar but otherwise has the same features as a generic rule.

MainUI expects rules tagged with “Script” to consist of only a single Script Action; no triggers, no conditions. I would not be surprised if it messes up if you tag a rule tagged with “Script” that has more than just the single Script Action.

Note that all of this is strictly something related to MainUI. openHAB core doesn’t use tags on rules for anything at this time.

I agree that it would be some work to change the MainUI behavior.

My point of view: As soon as I am editing code, I am responsible to enter correct values. As long as I am using an UI, I expect this UI to prevent “common mistakes”. For the semantic tags, I can only select predefined values. So a completely user definable tag in the UI should not be used internally for any purpose. That’s kinda the same if you offer a “description” field and the code acts upon special words in the description.

And after all, it’s unexpected behavior :slight_smile: And I stick to my opinion - user defined tags are owned by me, not by the software. If the software needs tags, too, it should use a different piece of data. jm2c.

Anyway, no need to waste more time on that topic - I’ll use other tags then. thx for all responses :+1:

You’re not gonna be happy when you get into Item metadata.

Elmer Fudd Whatever GIF by Looney Tunes

Anyway, if you feel strongly about this, please do file an issue, in this case on the MainUI repo. But also keep in mind that add some new property or way to represent this data will also impact openhab-core and perhaps other repos as well.

1 Like

You make me fear :smiley: I won’t file an issue. It’ s not worth it, seems my opinion is not the broad one, so I will accept the given workarounds. And as you say, it would require changes that go far beyond MainUI.

Perhaps, but MainUI could possibly prevent you from applying the Script tag to a rule that is invalid to have that tag. That shouldn’t take too much, mitigates the problem a little and doesn’t require inventing a whole new system for “official tags”.

1 Like