# Trigger Scene

**URL:** <https://community.gladysassistant.com/t/scene-declencheur/8448>\
**Category:** Configuration\
**Tags:** scene\
**Created:** [November 1, 2023, 8:30pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448 "2023-11-01T20:30:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 1, 2023, 8:30pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/1 "2023-11-01T20:30:38Z")

</div>

It would be nice to have this toggle as shown below in scenes  
Depending on the choice, the next action

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [November 1, 2023, 8:43pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/2 "2023-11-01T20:43:28Z")

</div>

For me, you can already add multiple triggers that act with an OR (any one that triggers launches the scene).

And it doesn’t make sense to combine them with an AND because these are events and not states. You can’t say «&nbsp;the door opens and the temperature goes above 20°C&nbsp;» but rather «&nbsp;the door opens and the temperature is above 20°C&nbsp;».  
So, that’s already possible with the Continue only if function.

Do you have an example use case?

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 1, 2023, 8:53pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/3 "2023-11-01T20:53:57Z")

</div>

![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/f/f9ab2e2e8d20dcfd6cbaa0a4d9d3c15cddf7bdb9.png)  
For example :  
If I leave the house and the plug is plugged in the next action is activated  
In this case it’s one of the 2 triggers that activates the next action  
Unless I set up my scene incorrectly…  
It could also be, if I leave the house and the light sensor is low, turn on the outdoor light etc

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 1, 2023, 8:55pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/4 "2023-11-01T20:55:49Z")

</div>

In your example you should do:

- Trigger: when you leave the house
- Retrieve the state of your plug
- continue if and only if the plug is on
- desired action

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 1, 2023, 9:45pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/5 "2023-11-01T21:45:32Z")

</div>

a bit more complicated, isn’t it? Especially if we want to have multiple AND conditions — there we could do that just with a toggle!

On the programming side, set to ‹&nbsp;1&nbsp;› for each validated trigger, ‹&nbsp;0&nbsp;› otherwise; at the end of iterating through the triggers we count the number of triggers and the total of the trigger values — if the two are equal it’s an AND so we continue and the action is executed (in another language C or VB I would have coded it but not in JS!) ☹

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 2, 2023, 7:41am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/6 "2023-11-02T07:41:05Z")

</div>

Actually it’s not that much more complicated, it’s just a different logic.

You can have several AND conditions easily: you put several blocks side by side.  
To use my example, we could do:

1. `Trigger` : when you leave the house
2. `Get the state` of your plug, the brightness, the temperature
3. `continue only if` the plug is on / `continue only if` brightness \> 150 lumen / `continue only if` temperature \> 20°
4. desired action

In that case all conditions must be met in block 3 to trigger the action. And it’s not much extra configuration.

I think what surprises many people is having to retrieve a value before being able to use it (myself included, actually).  
There must surely be a technical reason for that - @pierre-gilles if you’re reading this ^^ - but it’s true that in my ideal world, I’d like my scene to be:

1. `Trigger` : when you leave the house
2. `continue only if` the plug is on / `continue only if` brightness \> 150 lumen / `continue only if` temperature \> 20°
3. desired action

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [November 2, 2023, 7:57am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/7 "2023-11-02T07:57:02Z")

</div>

> [@guim31](#):
>
> I think what surprises quite a few people is having to retrieve a value before being able to use it (myself included, actually).

Well exactly — cast your vote:

> [@La box "Continuer seulement si" devrait proposer les valeurs instantanée des appareils par défaut](https://community.gladysassistant.com/t/la-box-continuer-seulement-si-devrait-proposer-les-valeurs-instantanee-des-appareils-par-defaut/6502?u=spenceur):
>
> En plus de laisser la possibilité de comparer des variables créé précédemment, laisser la possibilité de prendre une valeur instantanée sans devoir à créer une action «&nbsp;get device value&nbsp;» Demandée ici:

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 2, 2023, 8:01am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/8 "2023-11-02T08:01:58Z")

</div>

DAMN!!! I completely missed that!!!

I do think we should work on that; I’m convinced it’s a barrier to the adoption of Gladys.

We’ve already seen several people on the forum question how scenes work… this could help 😉

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [November 2, 2023, 8:03am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/9 "2023-11-02T08:03:25Z")

</div>

Same here! I’m voting right away!

---

<div class="post-metadata">

**Author:** ![Hizo](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Hizo](https://community.gladysassistant.com/u/Hizo)\
**Post date:** [November 2, 2023, 8:04am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/10 "2023-11-02T08:04:10Z")

</div>

EDIT : Actually it was following my very first remarks when I arrived 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [November 2, 2023, 8:04am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/11 "2023-11-02T08:04:30Z")

</div>

![](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/8/8a7c507f40a7c1bcff40a6ecc6cf06d3b70db15a.gif)

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 2, 2023, 9:10am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/12 "2023-11-02T09:10:08Z")

</div>

Let’s say the advantage here is being able to switch from a mode «&nbsp; **at least** one of the conditions met&nbsp;» to «&nbsp; **all** the conditions met&nbsp;» in a single block without having to redo the scene, it seems clearer in use and more practical to set up (at a glance you can see all the conditions)! After that nothing prevents having both modes; in the first we emphasize testing the primary condition before moving on to test the others with

> continue if and only if

, in the case I propose we test that at least one of the conditions is met (current behavior) OR we test that all the conditions are met

> [@guim31](#):
>
> - `Trigger` : when you leave the house
> - `continue if and only if` the outlet is on / `continue if and only if` brightness \> 150 lumens / `continue if and only if` temperature \> 20°
> - desired action

Here I agree it would be clearer than fetching states to use them later as you say if that’s a technical reason for it… 😉

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [November 2, 2023, 12:48pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/13 "2023-11-02T12:48:04Z")

</div>

> [@cce66](#):
>
> I’m in agreement here — it would be clearer than fetching states to use them afterwards, as you say, if that’s a technical reason for it… 😉

> [@Scène Déclencheur](https://community.gladysassistant.com/t/scene-declencheur/8448/7?u=spenceur):
>
> Beh justement a vos vote :

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 2, 2023, 2:43pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/14 "2023-11-02T14:43:22Z")

</div>

To add a reason for this feature and since I’ve just understood the usefulness of a virtual device (my god what’s happening to me? 🤣)  
So I create an MQTT «&nbsp;Switch&nbsp;» here called virtuel1 but which in my example should be called ‹&nbsp;All contact sensors are closed&nbsp;›

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/e/eae7d6016981e16b7608bda86ba6f45d76f7ee9d.png)

In a scene I create

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/4/43f1af30485a3f5fc64aa96a8fb944d3ffd46ea2.png)

Which activates/deactivates my virtual device here in the example if all my prises NOUS are not consuming (to transpose with the contact sensors), the problem is having to make an inverse scene «&nbsp;at least one plug consumes = at least one sensor is open&nbsp;» to invert the virtual device so we have it with the possibility to set the option to «&nbsp;At least one&nbsp;»

This virtual device could then be used in my scenes (it’s much more convenient!)  
So the advantage of this request is: I have 20 sensors and I consider the state ‹&nbsp;all sensors OK&nbsp;› if I’ve checked «&nbsp;all&nbsp;»…easier to configure, no?

Ideally it would be possible to create a device «&nbsp;Virtual device&nbsp;» on the MQTT integration page that would play this role!!!

And now that @pierre-gilles has developed the «&nbsp;alarm&nbsp;» integration it goes hand in hand I think!

I’ll make the request accordingly tonight 🤔

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [November 2, 2023, 3:16pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/15 "2023-11-02T15:16:38Z")

</div>

Can we close this feature request (or just convert it into a topic in #Configuration)?

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 2, 2023, 3:34pm UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/16 "2023-11-02T15:34:08Z")

</div>

Unless I’m mistaken, you can already do that, right?

You can create SCENE 1 which:

- tests all your sensors
- sets your switch to ON if everything is at zero

Then SCENE 2 (to save yourself the trouble you copy SCENE 1 and modify it as you wish) which:

- tests all your sensors
- sets your switch to OFF if one or more sensors are different from zero

Then you can retrieve the state value of your switch anywhere you want within the scenes.

Is that the goal?

---

<div class="post-metadata">

**Author:** ![cce66](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/8797f3/32.png) [@cce66](https://community.gladysassistant.com/u/cce66)\
**Post date:** [November 3, 2023, 1:15am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/17 "2023-11-03T01:15:26Z")

</div>

Yes, that’s exactly it in a simplified or clearer way: being able to put all the sensors in the 1st block and then have the choice thanks to that toggle I proposed avoids having a list of x «&nbsp;continue if&nbsp;» conditions etc!  
There, in 2 blocks we get the job done  
In the case of the alarm  
1st scene  
in the 1st triggers block, I put all my relevant sensors with the state «&nbsp;on&nbsp;», I check ‹&nbsp;all&nbsp;› and if they’re all OK I activate the alarm  
2nd scene  
in the 1st triggers block, I put all my relevant sensors, I check ‹&nbsp;at least one&nbsp;› and if one sensor is «&nbsp;off&nbsp;», I don’t activate the alarm and I send a message for example

It seems so much simpler and more logical to me… but oh well, if there’s no buy-in, too bad…

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 3, 2023, 6:25am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/18 "2023-11-03T06:25:00Z")

</div>

The basic problem in what you describe is that, however you turn the problem, a trigger cannot be the state of a device, but an event.  
So your ideal scene cannot exist as such.

That said, I’m the first to say that we can improve the creation of scenes; any idea is worth studying 👍👍

---

<div class="post-metadata">

**Author:** ![Hizo](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/h/51bf81/32.png) [@Hizo](https://community.gladysassistant.com/u/Hizo)\
**Post date:** [November 3, 2023, 8:00am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/19 "2023-11-03T08:00:20Z")

</div>

In my opinion, the best is a Node-RED-style visual 🙂

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [November 3, 2023, 8:44am UTC](https://community.gladysassistant.com/t/scene-declencheur/8448/20 "2023-11-03T08:44:14Z")

</div>

I pretty much agree with that, a good example being Homey (if I’m not mistaken) which developed a Node-RED-like interface to create scenes.

Except that would be a gigantic overhaul, which, even if it’s probably conceivable one day, doesn’t prevent tweaking existing scenes to improve the UX, because I’m convinced people aren’t using its capabilities 100%.

[Next page](https://community.gladysassistant.com/t/scene-declencheur/8448.md?page=2)
