# Scene with a button (double or single click)

**URL:** <https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167>\
**Category:** Développement\
**Created:** [March 10, 2021, 4:05pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167 "2021-03-10T16:05:02Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [March 15, 2021, 2:03pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/21 "2021-03-15T14:03:44Z")

</div>

OK, let’s go on that 😃

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [March 15, 2021, 2:48pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/22 "2021-03-15T14:48:41Z")

</div>

> [@cicoub13](#):
>
> I haven’t done anything so far.

Oh well, bravo, I thought you were working hard 😜

---

<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:** [March 22, 2021, 2:27am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/23 "2021-03-22T02:27:03Z")

</div>

Just a quick update, so the issue has been fixed on the Zigbee2mqtt PR?

@lmilcent did you manage to create your scenes? 🙂

---

<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:** [March 22, 2021, 6:25am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/24 "2021-03-22T06:25:10Z")

</div>

> [@pierre-gilles](#):
>
> @lmilcent Have you managed to do your scenes?

No, I have two problems:

1- My kitchen switch is recognized by Gladys as a power outlet.

2- My wireless switch is still impossible to control for the moment, even if I use 1 as a default value.

---

<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:** [March 22, 2021, 6:31am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/25 "2021-03-22T06:31:11Z")

</div>

Ok, @cicoub13 can you look at this together? 🙂

---

<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:** [March 22, 2021, 6:43am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/26 "2021-03-22T06:43:33Z")

</div>

I remember the issue: the «&nbsp;Switch&nbsp;» feature allows you to control the light from the dashboard with a button.  
But in the scenes, it is recognized as a socket.

The «&nbsp;light&nbsp;» feature allows you to control the scenes to turn on the lights but not to have the button on the dashboard.

Which is the correct feature to use in this case?

---

<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:** [March 22, 2021, 6:52am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/27 "2021-03-22T06:52:15Z")

</div>

> [@lmilcent](#):
>
> The «&nbsp;light&nbsp;» feature allows you to control lights in scenes to turn them on but not to have the button on the dashboard.

No button on the dashboard? Are you sure you have properly defined a feature type with the following characteristics:

- category: light
- type: binary

?

All other integrations that manage lamps (Philips Hue, MQTT, etc.) are controllable both in scenes and on the dashboard.

---

<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:** [March 22, 2021, 7:00am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/28 "2021-03-22T07:00:47Z")

</div>

> [@pierre-gilles](#):
>
> Are you sure you have properly defined a feature type with the following characteristics:
> 
> - category: light
> - type: binary

@cicoub13 I don’t remember which file handles the association, but that must be the error!

Regarding the models, you will also need to perform a verification. Typically, my switch is incorrectly declared (Switch instead of light).

---

<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:** [March 22, 2021, 10:02pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/29 "2021-03-22T22:02:34Z")

</div>

I think we’ve already had this debate but a switch is a switch 🙂 We can’t know what it controls (a lamp or something else).

If we’re talking about the WXKG06LM model, it is declared with:  
`category: DEVICE_FEATURE_CATEGORIES.BUTTON,`  
`type: DEVICE_FEATURE_TYPES.BUTTON.CLICK,`

I will unify the behavior for the values and propose a simpler UX in the scenes.

---

<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:** [March 23, 2021, 12:21am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/30 "2021-03-23T00:21:54Z")

</div>

> [@cicoub13](#):
>
> I think we’ve already had this debate, but a switch is a switch 🙂 We can’t know what it controls (a lamp or something else).

Is this really the case for this model?

I agree that in the case of a remote-controlled outlet, it could be anything behind it, but in this case, do people use it for anything other than a lamp?

Ideally, it would be possible to re-categorize in the UI if you think the usage is so «&nbsp;varied&nbsp;».

---

<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:** [March 23, 2021, 7:03am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/31 "2021-03-23T07:03:07Z")

</div>

I agree with @cicoub13, a switch should automatically offer a dedicated button in the interface, like the switches.

Even if it does not directly control a light.

---

<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:** [March 23, 2021, 8:53pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/32 "2021-03-23T20:53:44Z")

</div>

For now, I have added the management of the recovery of the value in the Zigbee PR.  
Instead of having the values `single`, `double` and `long`, the state will be 1, 2 or 5.

This allows you to use them in scenes 🚀 @lmilcent Can you test the new image?

As previously mentioned, I would be happy to work on the UX and propose a button that is easier to use in scenes (and for display in the boxes) + standardize between the Xiaomi service and Zigbee2Mqtt (the only services using this type of device `button`).

But I think it’s better to do this in another PR and above all, I would like to share specifications here before starting 😉  
To add a Light feature instead of a button, this seems too complex for now. I would need to keep the real Zigbee type and the Gladys type of each feature to be able to convert the values AND send actions to Zigbee (which is impossible for these devices).

---

<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:** [March 23, 2021, 9:11pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/33 "2021-03-23T21:11:19Z")

</div>

It works perfectly!!

---

<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:** [March 24, 2021, 12:25am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/34 "2021-03-24T00:25:33Z")

</div>

> [@cicoub13](#):
>
> Instead of having the values `single`, `double` and `long`, the state will be 1, 2 or 5.

Why 1, 2 or 5?

I thought we wanted it like the Xiaomi level?

const SWITCH\_STATUS = {  
NO\_CLICK: 0,  
CLICK: 1,  
DOUBLE\_CLICK: 2,  
LONG\_CLICK\_PRESS: 3,  
LONG\_CLICK\_RELEASE: 4,  
};

> [@cicoub13](#):
>
> But I think it’s better to do this in another PR and above all, I would like to share specifications here before getting started 😉

I agree! I think it’s another PR and indeed we need to discuss it!

---

<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:** [March 24, 2021, 7:30am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/35 "2021-03-24T07:30:50Z")

</div>

I removed the `NO_CLICK` (which made no sense) and the **WXKG06LM** switch sends a hold event in Zigbee (equivalent to a `LONG_CLICK`). It does not handle the press and release of the press.

I kept the values 3 and 4 to not break the Xiaomi service (case of other switches) and I have:

```javascript
const BUTTON_STATUS = {
  CLICK: 1,
  DOUBLE_CLICK: 2,
  LONG_CLICK_PRESS: 3,
  LONG_CLICK_RELEASE: 4,
  LONG_CLICK: 5,
};

```

---

<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:** [March 26, 2021, 1:22am UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/36 "2021-03-26T01:22:57Z")

</div>

@cicoub13 ok that sounds good to me 🙂

Perfect for backward compatibility

---

<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:** [April 4, 2021, 3:37pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/37 "2021-04-04T15:37:21Z")

</div>

Can these recent developments address my issue?

I want to use my Aqara switch to turn a bulb on/off with a single click.  
I create a scene of the type

```
Trigger: state change > switch = 1
Action: turn on light (currently recognized as a switch)

```

So I can turn on my light with a single click… but I can’t use a single click to turn it off, or maybe I didn’t understand.

---

<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:** [April 4, 2021, 5:10pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/38 "2021-04-04T17:10:12Z")

</div>

I have an Aqara button and a smart plug.

- scene 1: if single click, continue if it’s off, turn on the plug.
- scene 2: if single click, continue if it’s on, turn off.

Does that solve your problem?

---

<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:** [April 4, 2021, 6:09pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/39 "2021-04-04T18:09:09Z")

</div>

A priori it can solve it yes, but I have 2 remarks:

- In this part I don’t know what to mark at all:  

- Even if it works, I admit that it’s not very intuitive in my opinion.  
I would have rather seen an AND operation:  
`IF single click AND light off > Turn on light / outlet`

---

<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:** [April 4, 2021, 6:14pm UTC](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167/40 "2021-04-04T18:14:31Z")

</div>

> [@guim31](#):
>
> Even if it works, I admit that it’s not very intuitive in my opinion.  
> I would have rather seen a function AND:  
> `IF single click AND light off \u003e Turn on light / outlet`

Ah ah, that was the subject of an exchange with @pierre-gilles not long ago indeed 😆

Before each «&nbsp;continue if&nbsp;», you need to use a «&nbsp;retrieve the last value&nbsp;» block.  
Then you select your light, and 1 = on, 0 = off.

[Previous page](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167.md?page=1)

[Next page](https://community.gladysassistant.com/t/scene-avec-un-bouton-double-ou-simple-clic/6167.md?page=3)
