# Use script as a scene

**URL:** <https://community.openhab.org/t/use-script-as-a-scene/153183>\
**Category:** Off-Topic\
**Created:** [January 19, 2024, 2:03pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183 "2024-01-19T14:03:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermanvh](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@hermanvh](https://community.openhab.org/u/hermanvh)\
**Post date:** [January 19, 2024, 2:03pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/1 "2024-01-19T14:03:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JustinG](https://community.openhab.org/user_avatar/community.openhab.org/justing/32/55948_2.png) [@JustinG](https://community.openhab.org/u/JustinG)\
**Post date:** [January 19, 2024, 2:49pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/2 "2024-01-19T14:49:15Z")

</div>

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:

```auto
  "tags": [
    "Scene"
  ],

```

becomes

```auto
  "tags": [],

```

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

---

<div class="post-metadata">

**Author:** ![hermanvh](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@hermanvh](https://community.openhab.org/u/hermanvh)\
**Post date:** [January 19, 2024, 3:21pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/3 "2024-01-19T15:21:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JustinG](https://community.openhab.org/user_avatar/community.openhab.org/justing/32/55948_2.png) [@JustinG](https://community.openhab.org/u/JustinG)\
**Post date:** [January 19, 2024, 3:27pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/4 "2024-01-19T15:27:58Z")

</div>

> [@hermanvh](#):
>
> Would be nice to be able to edit the Scripts in the Blockly editor.

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.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [January 19, 2024, 4:08pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/5 "2024-01-19T16:08:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JustinG](https://community.openhab.org/user_avatar/community.openhab.org/justing/32/55948_2.png) [@JustinG](https://community.openhab.org/u/JustinG)\
**Post date:** [January 19, 2024, 4:33pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/6 "2024-01-19T16:33:19Z")

</div>

> [@rlkoshak](#):
>
> Semantic Home UI Widget

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

> [@rlkoshak](#):
>
> but would it be possible to adapt that widget to look for another tag in addition to the “Scene” tag?

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.

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [January 19, 2024, 4:56pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/7 "2024-01-19T16:56:31Z")

</div>

> [@rlkoshak](#):
>
> 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?

No😉, anything possible if I get a feature request

---

<div class="post-metadata">

**Author:** ![hermanvh](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@hermanvh](https://community.openhab.org/u/hermanvh)\
**Post date:** [January 19, 2024, 4:36pm UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/8 "2024-01-19T16:36:49Z")

</div>

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

Thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/6/6a52f2ac5d00e4c7b50471a354b3a9221188be90.png) [@system](https://community.openhab.org/u/system)\
**Post date:** [March 1, 2024, 8:36am UTC](https://community.openhab.org/t/use-script-as-a-scene/153183/9 "2024-03-01T08:36:59Z")

</div>

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