# Sonoff SNZB-01 Taster

**URL:** <https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812>\
**Category:** Configuration\
**Created:** [16. Januar 2022 um 17:53 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812 "2022-01-16T17:53:46Z")\
**Posts on this page:** 20\
**Page:** 3

<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:** [17. Mai 2022 um 08:23 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/42 "2022-05-17T08:23:46Z")

</div>

Für mich ist das codiert

> <https://github.com/GladysAssistant/Gladys/blob/master/server/services/zigbee2mqtt/exposes/enumType.js#L16>

Ich habe es nicht selbst getestet

---

<div class="post-metadata">

**Author:** ![Tlse-vins](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/tlse-vins/32/6054_2.png) [@Tlse-vins](https://community.gladysassistant.com/u/Tlse-vins)\
**Post date:** [17. Mai 2022 um 08:28 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/43 "2022-05-17T08:28:52Z")

</div>

Muss man keinen numerischen Wert angeben?  
Es wäre gut, diese Information irgendwo anzugeben, wenn ein Gerät von Gladys verwaltet wird. Airtable oder direkt in Gladys.

---

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [17. Mai 2022 um 09:21 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/44 "2022-05-17T09:21:25Z")

</div>

> [@Tlse-vins](#):
>
> Airtable oder direkt Gladys.

Airtable ist bereits enthalten (auch wenn eine Funktion fehlt) 😉  
Du kannst es testen und Feedback geben 🙂

---

<div class="post-metadata">

**Author:** ![Tlse-vins](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/tlse-vins/32/6054_2.png) [@Tlse-vins](https://community.gladysassistant.com/u/Tlse-vins)\
**Post date:** [17. Mai 2022 um 09:30 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/45 "2022-05-17T09:30:17Z")

</div>

Ich habe mich falsch ausgedrückt.  
Ich wollte sagen, dass man irgendwo erwähnen sollte:  
1 kurzer Druck = 1  
2 kurze Drücke = 2  
? langer Druck = ?

---

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [17. Mai 2022 um 09:31 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/46 "2022-05-17T09:31:21Z")

</div>

ich bestätige keinen langen Tastendruck auf Gladys, aber im Dashboard z2Mqtt OK

---

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [17. Mai 2022 um 09:40 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/47 "2022-05-17T09:40:01Z")

</div>

> [@VonOx](#):
>
> Für mich ist das codiert

Hallo @VonOx  
Für den Langdruck haben wir keine Umrechnung von „Langdruck“ in eine Zahl (z. B. 5, um mit Xiaomi übereinzustimmen)  
wie @Tlse-vins schreibt  
1 kurzer Druck = 1  
2 kurze Drücke = 2  
? langer Druck = ?

---

<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:** [17. Mai 2022 um 09:52 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/48 "2022-05-17T09:52:35Z")

</div>

Das sind dieselben Konstanten, um die Seite von Gladys zu vereinheitlichen

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

```

---

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [17. Mai 2022 um 10:21 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/49 "2022-05-17T10:21:48Z")

</div>

Super  
Aber beim Sonoff funktioniert der lange Klick nicht. Bei den Xiaomi-Knöpfen funktioniert es  
😃

---

<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:** [17. Mai 2022 um 14:56 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/50 "2022-05-17T14:56:18Z")

</div>

Okay, der Sonoff sendet „long“, ich weiß nicht, wie ich das mit den Switch-Cases handhaben soll (cc @AlexTrovato @pierre-gilles)

---

<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:** [17. Mai 2022 um 16:34 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/51 "2022-05-17T16:34:23Z")

</div>

> [@Tlse-vins](#):
>
> Ich wollte sagen, dass man irgendwo erwähnen sollte:  
> 1 kurzer Druck = 1  
> 2 kurze Drücke = 2  
> ? langer Druck = ?

Was ich immer gesagt habe, ist, dass diese Werte niemals dem Benutzer präsentiert werden sollten, das ist nicht die Philosophie dieser v4!

Statt manuell 1, 2, 3 oder 4 einzugeben, sollte der Benutzer einfach einen Selektor in den Szenen sehen, so etwas wie das:

 ![Screenshot 2022-05-17 at 17.30.25](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/c/c0d306505ef8fd6c485c4bdf5fa310477eb84862.png)

(ist nicht codiert, nur ein Mockup)

So muss sich niemand an diese Konstanten erinnern, die nur interne „Kochkunst“ sind 🙂

Ich wäre offen für einen PR zu diesem Thema 🙂

> [@VonOx](#):
>
> Okay, der Sonoff sendet „lang“, ich weiß nicht, wie ich das mit den Switch-Cases handhaben soll (cc @AlexTrovato @pierre-gilles)

Auf den ersten Blick denke ich, dass du den readValue ändern musst:

> <https://github.com/GladysAssistant/Gladys/blob/master/server/services/zigbee2mqtt/exposes/enumType.js#L31>

Ich überlasse es @AlexTrovato, das zu bestätigen.

---

<div class="post-metadata">

**Author:** ![Tlse-vins](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/tlse-vins/32/6054_2.png) [@Tlse-vins](https://community.gladysassistant.com/u/Tlse-vins)\
**Post date:** [17. Mai 2022 um 16:38 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/52 "2022-05-17T16:38:49Z")

</div>

> [@pierre-gilles](#):
>
> Das, was ich immer gesagt habe, ist, dass diese Werte dem Benutzer niemals angezeigt werden sollten, das ist nicht die Philosophie von dieser v4!

Ich bin deiner Meinung, wenn alle Klicks codiert sind, muss man die Werte nicht kennen.

---

<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:** [17. Mai 2022 um 16:39 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/53 "2022-05-17T16:39:05Z")

</div>

Alles klar, bei readValue gibt es kein Problem, also wird writeValue in diesem Fall bei den Schaltflächen nie verwendet?

Ich versuche zu verstehen 😅.

---

<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:** [17. Mai 2022 um 16:40 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/54 "2022-05-17T16:40:44Z")

</div>

Ich bin nicht der Autor des Codes, also kann ich es nicht genau sagen, aber ich denke tatsächlich, dass im Fall eines Sensors, der nie gesteuert wird, nur der readValue nützlich ist.

---

<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:** [17. Mai 2022 um 16:50 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/55 "2022-05-17T16:50:42Z")

</div>

> [@pierre-gilles](#):
>
> Das, was ich immer gesagt habe, ist, dass diese Werte dem Benutzer nie angezeigt werden sollten, das ist nicht die Philosophie von v4!
> 
> Statt manuell 1, 2, 3 oder 4 einzugeben, sollte der Benutzer einfach einen Selektor in den Szenen sehen, so etwas wie das:

+1

Ich würde mich gerne mit dem Thema beschäftigen, was wäre die Logik dahinter? Einfach eine Anzeige auf der Frontend-Seite oder etwas Komplexeres auf der Backend-Seite?

Ich habe auch den Fall beim Lixee Tic, er gibt die aktuelle Tarifierung zurück (Werttext HP HC usw.), also interessante Dinge, die in den Szenen genutzt werden können.

Es lohnt sich, ein eigenes Thema dafür zu erstellen.

---

<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:** [17. Mai 2022 um 16:56 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/56 "2022-05-17T16:56:28Z")

</div>

> [@VonOx](#):
>
> Das würde mich interessieren, die Logik wäre was? Einfach nur eine Anzeige auf der Frontend-Seite oder etwas Komplexeres auf der Backend-Seite?

Es geht nur um die Anzeige, ja! Danach nichts Neues, wir machen das schon für viele Typen:

Binär:

 ![Screenshot 2022-05-17 at 17.52.56](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/a/a6ad540094e7db5df04baef3b4d287a9f7827dfd.png)

Anwesenheitsgerät:

 ![Screenshot 2022-05-17 at 17.52.48](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/2/27a89eab85136b376718bedfb0d318c891650442.png)

Sensor mit Einheit:

 ![Screenshot 2022-05-17 at 17.53.13](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/a/a956523514f05556b2f5ca37d3dc5b393c5ea5f3.png)

Die Idee ist, dass wir in der UI niemals Werte anzeigen, die unsere interne „Küche“ sind. Wir zeigen immer ein schönes, übersetztes und leicht verständliches Component.

Es fehlt nur noch ein Component für Druckknöpfe wie die von Xiaomi.

Danach muss sichergestellt werden, dass nur dieser Knopf als solcher klassifiziert wird. Man muss wissen, woran man in der UI die Unterscheidung vornehmen muss.

---

<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:** [18. Mai 2022 um 07:36 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/57 "2022-05-18T07:36:13Z")

</div>

Zuerst ein Pull Request zur Verwaltung des Buttons

> <https://github.com/GladysAssistant/Gladys/pull/1525>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fa…st as possible, make sure to review and check all of these items:
> 
> \- \[X\] If your changes affects code, did your write the tests?
> \- \[X\] Are tests passing? (\`npm test\` on both front/server)
> \- \[X\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[X\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[\] If you are adding a new features/services, did you run integration comparator? (\`npm run compare-translations\` on front)
> \- \[\] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to \[the community\](https://community.gladysassistant.com/) for testing before merging.
> \- \[\] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
> \- \[\] If you are adding a new features/services which needs explanation, did you modify the user documentation? See \[the GitHub repo\](https://github.com/GladysAssistant/v4-website) and the \[website\](https://gladysassistant.com).
> \- \[\] Did you add fake requests data for the demo mode (\`front/src/config/demo.js\`) so that the demo website is working without a backend? (if needed) See \[https://demo.gladysassistant.com\](https://demo.gladysassistant.com).
> 
> NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
> 
> \### Description of change
> 
> This PR provide support for Sonoff SNZB-01 button
> https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/50?u=vonox
> 
> I've updated \`BUTTON\_STATUS\` constants to use the same wording of the feature 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:** [18. Mai 2022 um 16:20 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/58 "2022-05-18T16:20:52Z")

</div>

@VonOx der PR bricht die Abwärtskompatibilität für den LONG\_CLICK, der von 5 auf 6 wechselt

---

<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:** [18. Mai 2022 um 17:01 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/59 "2022-05-18T17:01:15Z")

</div>

Der alte Long wurde zu Hold, also nein (der Wert Hold z2m war auf Long gemappt, das ergab keinen Sinn) =\> Daher erschien es mir logisch

Soll ich trotzdem umkehren?

---

<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:** [18. Mai 2022 um 17:06 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/60 "2022-05-18T17:06:08Z")

</div>

Kein Problem mit dem Variablennamen (das ist unser interner Code), aber der numerische Wert muss gleich bleiben (außer bei einer Migration).

Wenn jemand eine Szene kaputt gemacht hätte, indem er manuell 5 eingegeben hat, weil er gemerkt hat, dass 5 funktioniert, dann ist diese Szene mit diesem PR kaputt, und das müssen wir auf jeden Fall vermeiden!

Es muss nur sichergestellt werden, dass das Verhalten von 5 gleich bleibt.

---

<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:** [18. Mai 2022 um 17:20 UTC](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812/61 "2022-05-18T17:20:57Z")

</div>

Vor meinem PR

Z2m sendet «&nbsp;hold&nbsp;» =\> Gladys LONG\_CLICK =\> 5

Mein PR:

Z2m sendet «&nbsp;hold&nbsp;» =\> Gladys HOLD\_CLICK =\> 5  
Z2m sendet «&nbsp;long&nbsp;» =\> Gladys LONG\_CLICK =\> 6

Eigentlich sehe ich nicht, was das kaputt macht, da  
Die Zuordnung hold = 5 bleibt dieselbe

[Vorherige Seite](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812.md?page=2)

[Nächste Seite](https://community.gladysassistant.com/t/bouton-sonoff-snzb-01/6812.md?page=4)
