Use script as a scene

All,

I like the concept of scenes.
With the new semanticHomeUI there is a nice wizards to activate them.
However I want to use scenes that have some logic, so therefore I created a blockly script and added the scene tag to this script.
This works perfectly fine with semanticHomeUI, but I cannot edit the script anymore, since it disappeared from script list in the mainUI and also does not show up in the scene list.

Any ideas how solve this?

Herman

Your best bet is going to be to use the API explorer.

Put the ID of the rule into the GET /rules/{ruleUID} endpoint viewer. That will give you the JSON object for the rule. Copy that object text to an editor and manually edit the tags array. For example:

  "tags": [
    "Scene"
  ],

becomes

  "tags": [],

Then with the same rule UID paste the new JSON text into the PUT /rules/{ruleUID} endpoint viewer.

Thanks for the quick reply.
I checked with API explorer and that is possible, but a bit cumbersome.
Would be nice to be able to edit the Scripts in the Blockly editor.
So not filter out these scripts in script editor of the MainUI since the scripts contain still contain the “Script” tag to.

The problem is that you are going against the design expectations. The Scene tag is specifically reserved for rules of a particular format: only item state commands and no additional script actions. The Scene editor is not built to handle rules with script actions.

A scene-like rule with internal script-based logic is not discouraged at all, in fact, it is encouraged; that’s the whole point of rules to being with. Just don’t add the Scene tag to it, because it is not actually a “scene” as the UI defines them. If you must have a tag on this sort of rule for some reason, then just use a slightly different tag such as Custom Scene or Logical Scene. Those will not cause the rule to be filtered out of the other lists.

2 Likes

I think the root problem here is that fancy Semantic Home UI Widget @hmerk and others have been working on probably only looks for the “Scene” tag. @hmerk, I suspect the answer is “no”, but would it be possible to adapt that widget to look for another tag in addition to the “Scene” tag? Then users could create scenes that are more than just “command Item X with Y” type scenes and apply that other tag.

@hermanvh, a way you can have-your-cake-and-eat-it-too for this use case is to create an Item that triggers your rule on commands (could be a Switch, doesn’t matter what command). Then put that Item into your Scene. When the scene is executed it will command the Item and trigger your Rule with the Blockly Script Action.

1 Like

Good catch. I missed that OP was trying to make this work with that.

I haven’t looked at the home widget code in a while, but I would think it would be doable, given the constraints of the widgets to still get a list of any tags that include “Scene” instead of just equal “Scene” . That would then still work with tags similar to what I suggested above and be fairly user friendly.

No😉, anything possible if I get a feature request

2 Likes

@rlkoshak, i like your creative solution and will start using that.

Thanks a lot

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