[gelöst] structure regiert auf jede Änderung jedes Readings des Ausgangsgerätes

Begonnen von drhirn, 25 Januar 2023, 18:23:55

Vorheriges Thema - Nächstes Thema

drhirn

Wie in dem Thread ersichtlich, habe ich ein structure Device, das mir mehrere physische Schalter zusammen fasst. Unter anderem einen ZigBee-Schalter, bei dem nur das Reading "action" für die Structure interessant ist.

Jetzt kann es passieren, dass andere Readings dieses Schalters aktualisiert werden. Dadurch löst aber die structure aus, was ich eigentlich nicht will.

Ist das ein gewolltes Verhalten? Bzw. kann ich die structure so definieren, dass sie nur auf ein bestimmtes Reading hört?

structure-Device:

defmod structLichtszenenWz structure lightSwitch enoSwitch05 enoSwitch03 MQTT2_zigbee_PTM215ZE01
attr structLichtszenenWz clientstate_behavior last


Schalter:

defmod MQTT2_zigbee_PTM215ZE01 MQTT2_DEVICE zigbee_PTM215ZE01
attr MQTT2_zigbee_PTM215ZE01 userattr lightSwitch_map structexclude
attr MQTT2_zigbee_PTM215ZE01 lightSwitch_map action:press_1:BI action:press_2:B0 action:press_3:AI action:press_4:A0 action:release_1:BI action:release_2:B0 action:release_3:AI action:release_4:A0
attr MQTT2_zigbee_PTM215ZE01 readingList zigbee2mqtt/PTM215ZE01:.* { json2nameValue($EVENT) }\
zigbee2mqtt/PTM215ZE01/availability:.* availability


Danke!

betateilchen

Im jeweiligen device (nicht in der structure!) - siehe commandref.

<struct_type>_map
With this attribute, which has to specified for the structure- member, you can redefine the value reported by a specific structure-member for the structure value. The attribute has three variants:
readingName
take the value from readingName instead of state.

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

drhirn

Das hätte ich ja eh drinnen.

attr MQTT2_zigbee_PTM215ZE01 lightSwitch_map action:press_1:BI action:press_2:B0 action:press_3:AI action:press_4:A0 action:release_1:BI action:release_2:B0 action:release_3:AI action:release_4:A0

betateilchen

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

betateilchen

Vielleicht wäre es hilfreich, einmal einen Auszug aus dem EventMonitor zu haben oder Logeinträge, um nachzuvollziehen, was da genau passiert.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

drhirn

Pfuh, gerne. Aber sei gewarnt ;)
Das passiert, wenn ich den Zigbee2Mqtt Container neu starte.
MQTT2_zigbee_PTM215ZE01 ist der Schalter, der alles durcheinander bringt. Aktualisiert werden bei dem drei von sechs Readings (availability, linkqualitiy und last_seen). Nicht das Readings "action", welches für das Schalten zuständig wäre.

...

Code-Einträge wieder gelöscht. Sind wohl zu lange. Moment...

drhirn


MQTT2_DEVICE zigbee2mqttBridge bridgeState: online
LightScene lsWohnzimmer z2mWzSofa.availability: <html><div id="z2mWzSofa"  title="off" class="col2"><a href="/fhem?cmd.z2mWzSofa=set z2mWzSofa toggle&room=BeleuchtungSystem->Devices"><svg class=" off" data-txt="off" version="1.0" xmlns="http://www.w3.org/2000/svg"  width="468pt" height="617pt" viewBox="0 0 468 617"  preserveAspectRatio="xMidYMid meet"> <metadata> Created by potrace 1.8, written by Peter Selinger 2001-2007 </metadata> <g transform="translate(0,617) scale(0.221801,-0.221801)"  stroke="none"> <path d="M756 2765 c-9 -25 -7 -128 3 -144 5 -8 16 -11 25 -8 24 10 19 160 -5 165 -9 2 -19 -4 -23 -13z"/> <path d="M1310 2695 c0 -77 2 -86 18 -83 14 3 17 15 17 83 0 68 -3 80 -17 83 -16 3 -18 -6 -18 -83z"/> <path d="M1806 2581 c-47 -47 -67 -74 -63 -85 4 -9 10 -16 14 -16 17 0 155 148 149 159 -14 21 -32 10 -100 -58z"/> <path d="M220 2622 c0 -23 125 -147 139 -138 21 13 11 32 -52 94 -64 64 -87 75 -87 44z"/> <path d="M809 2257 c-70 -20 -136 -63 -174 -115 -65 -87 -65 -91 -65 -643 0 -479 1 -500 21 -553 25 -67 87 -134 160 -173 l54 -28 250 0 c235 0 253 1 296 21 63 29 125 94 158 163 l26 56 0 520 0 520 -28 56 c-32 66 -99 132 -165 162 -43 20 -65 22 -267 24 -153 2 -234 -2 -266 -10z m486 -146 c48 -22 69 -44 90 -94 13 -31 15 -107 15 -517 0 -526 0 -523 -59 -573 -48 -40 -90 -47 -299 -47 -205 0 -226 4 -280 54 -51 46 -50 40 -53 567 l-3 495 23 40 c24 43 64 72 115 85 17 4 117 7 221 8 164 0 195 -2 230 -18z"/> <path d="M13 2065 c-11 -29 12 -36 118 -33 96 3 104 4 104 23 0 19 -8 20 -108 23 -91 2 -108 0 -114 -13z"/> <path d="M1877 2066 c-11 -27 17 -36 113 -36 100 0 127 8 117 34 -5 13 -25 16 -116 16 -83 0 -110 -3 -114 -14z"/> <path d="M10 1510 c0 -19 6 -20 116 -20 105 0 115 2 112 18 -3 15 -18 17 -116 20 -107 3 -112 2 -112 -18z"/> <path d="M1876 1522 c-2 -4 -1 -14 3 -20 5 -9 38 -12 117 -10 89 2 109 6 109 18 0 12 -20 16 -112 18 -61 1 -114 -1 -117 -6z"/> <path d="M21 981 c-8 -5 -11 -16 -8 -25 5 -13 24 -16 112 -16 88 0 107 3 112 16 10 26 -16 34 -112 34 -50 0 -96 -4 -104 -9z"/> <path d="M1882 978 c-8 -8 -9 -15 -1 -25 8 -9 40 -13 108 -13 101 0 128 8 118 34 -5 13 -24 16 -110 16 -66 0 -107 -4 -115 -12z"/> <path d="M768 693 c-36 -41 -30 -95 11 -108 60 -19 520 -91 539 -84 53 20 66 99 19 119 -28 12 -482 90 -524 90 -16 0 -37 -8 -45 -17z"/> <path d="M793 530 c-41 -17 -58 -85 -28 -110 15 -12 492 -100 543 -100 33 0 62 34 62 74 0 18 -6 38 -13 44 -6 6 -120 29 -252 51 -132 23 -251 43 -265 46 -14 2 -35 0 -47 -5z"/> <path d="M793 360 c-46 -18 -59 -90 -20 -114 21 -13 478 -96 531 -96 14 0 35 9 46 20 26 26 27 85 2 99 -10 5 -126 28 -258 51 -131 22 -248 42 -259 44 -11 2 -30 0 -42 -4z"/> <path d="M871 154 c-26 -33 -27 -55 -3 -82 13 -16 51 -26 176 -47 158 -27 159 -27 185 -7 31 22 41 81 18 101 -16 13 -271 61 -323 61 -23 0 -39 -8 -53 -26z"/> </g> </svg></a></div></html>
MQTT2_DEVICE z2mWzSofa availability: online
LightScene lsWohnzimmer z2mWzSchrank.availability: <html>[...]</html>
MQTT2_DEVICE z2mWzSchrank availability: online
LightScene lsWohnzimmer z2mWzBulb03.availability: <html>[...]</html>
MQTT2_DEVICE z2mWzBulb03 availability: online
MQTT2_DEVICE MQTT2_zigbee_PTM215ZE01 availability: online
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer availability: online
MQTT2_DEVICE MQTT2_zigbee_testlampe ON
MQTT2_DEVICE MQTT2_zigbee_testlampe update_state: idle
MQTT2_DEVICE MQTT2_zigbee_testlampe linkquality: 236
MQTT2_DEVICE MQTT2_zigbee_testlampe brightness: 254
MQTT2_DEVICE MQTT2_zigbee_testlampe last_seen: 2023-01-23T16:48:20+01:00
MQTT2_DEVICE MQTT2_zigbee_testlampe update_available: false
LightScene lsWohnzimmer z2mWzSofa.color_x: <html>[...]</html>
LightScene lsWohnzimmer z2mWzSofa.color_y: <html>[...]</html>
[...]
LightScene lsWohnzimmer z2mWzSofa.color_temp: <html>[...]</html>
MQTT2_DEVICE z2mWzSofa color_x: 0.7006
MQTT2_DEVICE z2mWzSofa color_y: 0.2993
MQTT2_DEVICE z2mWzSofa color_saturation: 100
MQTT2_DEVICE z2mWzSofa off
MQTT2_DEVICE z2mWzSofa color_mode: xy
MQTT2_DEVICE z2mWzSofa last_seen: 2023-01-25T19:02:53+01:00
MQTT2_DEVICE z2mWzSofa color_hue: 0
MQTT2_DEVICE z2mWzSofa brightness: 254
MQTT2_DEVICE z2mWzSofa linkquality: 255
MQTT2_DEVICE z2mWzSofa color_temp: 160
LightScene lsWohnzimmer z2mWzSchrank.color_mode: <html>[...]</html>
[...]
LightScene lsWohnzimmer z2mWzSchrank.rgb: <html>[...]</html>
MQTT2_DEVICE z2mWzSchrank color_mode: xy
MQTT2_DEVICE z2mWzSchrank color_saturation: 99
MQTT2_DEVICE z2mWzSchrank color_hue: 34
MQTT2_DEVICE z2mWzSchrank last_seen: 2023-01-25T19:02:55+01:00
MQTT2_DEVICE z2mWzSchrank brightness: 254
MQTT2_DEVICE z2mWzSchrank linkquality: 255
MQTT2_DEVICE z2mWzSchrank color_x: 0.5128
MQTT2_DEVICE z2mWzSchrank color_y: 0.4529
MQTT2_DEVICE z2mWzSchrank ct: 419
MQTT2_DEVICE z2mWzSchrank off
MQTT2_DEVICE z2mWzSchrank rgb: FFB614
LightScene lsWohnzimmer z2mWzBulb03.color_x: <html>[...]</html>
[...]
LightScene lsWohnzimmer z2mWzBulb03.brightness: <html>[...]</html>
MQTT2_DEVICE z2mWzBulb03 color_x: 0.7006
MQTT2_DEVICE z2mWzBulb03 color_y: 0.2993
MQTT2_DEVICE z2mWzBulb03 color_saturation: 100
MQTT2_DEVICE z2mWzBulb03 power_on_behavior: off
MQTT2_DEVICE z2mWzBulb03 update_available: false
MQTT2_DEVICE z2mWzBulb03 on
MQTT2_DEVICE z2mWzBulb03 color_hue: 0
MQTT2_DEVICE z2mWzBulb03 last_seen: 2023-01-25T19:02:06+01:00
MQTT2_DEVICE z2mWzBulb03 color_mode: xy
MQTT2_DEVICE z2mWzBulb03 color_temp: 160
MQTT2_DEVICE z2mWzBulb03 update_state: idle
MQTT2_DEVICE z2mWzBulb03 linkquality: 255
MQTT2_DEVICE z2mWzBulb03 brightness: 254
MQTT2_DEVICE MQTT2_zigbee_PTM215ZE01 linkquality: 127
MQTT2_DEVICE MQTT2_zigbee_PTM215ZE01 last_seen: 2023-01-25T19:02:06+01:00
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_mode: xy
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_hue: 34
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_saturation: 99
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer brightness: 254
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_temp: 419
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_x: 0.5128
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer color_y: 0.4529
MQTT2_DEVICE MQTT2_zigbee_wohnzimmer ON

rudolfkoenig

ZitatBzw. kann ich die structure so definieren, dass sie nur auf ein bestimmtes Reading hört?
Nein.
Und soweit ich sehe, ist ein Einbau relativ aufwendig, wenn man dabei alle Attribute beruecksichtigen will.

Was ich anbieten kann, ist ein (Attribut abhaengiges) unterdruecken des vom structure generierten Events, falls der Strukturwert sich nicht geaendert hat.

drhirn

Ich bin mit meinem Workaround eigentlich zufrieden. Man muss halt wissen, was zu tun ist.

Aber wenn man was verbessern kann, sage ich sicher nicht nein und stehe für Tests zur Verfügung.

rudolfkoenig

Nach nochmaligen durchlesen des verlinkten Threads: mein Vorschlag waere nur ein Nachbau von "event-on-change-reading .*" im Modul, und wuerde in diesem Fall (clientstate_behavior last) genausowenig helfen.

Ich habe jetzt ein filterEvents Attribut eingefuegt:
ZitatfilterEvents
falls gesetzt, und das Event auslösende Gerät über ein struct_type map verfügt, dann werden nur solche Events die Strukturberechnung auslösen, die in diesem map enthalten sind.
Achtung: in struct_type map werden nur die readingName und readingName:oldVal:newVal Einträge berücksichtigt.

Ob es effizienter ist, als ein readingsProxy, das weiss ich nicht, aber es ist wahrscheinlich einfacher zu handhaben.

drhirn


drhirn

Zitat von: drhirn am 30 Januar 2023, 14:22:39
Funktioniert einwandfrei. Danke!

Moment! Mein Fehler. Funktioniert doch nicht. Die structure reagiert überhaupt nicht auf den Schalter.

Schalter:

defmod MQTT2_zigbee_PTM215ZE01 MQTT2_DEVICE zigbee_PTM215ZE01
attr MQTT2_zigbee_PTM215ZE01 userattr lightSwitch lightSwitch_map structexclude
attr MQTT2_zigbee_PTM215ZE01 eventMap press_1:BI press_2:B0 press_3:AI press_4:A0 release_1:BI release_2:B0 release_3:AI release_4:A0
attr MQTT2_zigbee_PTM215ZE01 lightSwitch_map press_1:BI press_2:B0 press_3:AI press_4:A0 release_1:BI release_2:B0 release_3:AI release_4:A0
attr MQTT2_zigbee_PTM215ZE01 readingList zigbee2mqtt/PTM215ZE01:.* { json2nameValue($EVENT) }\
zigbee2mqtt/PTM215ZE01/availability:.* availability
attr MQTT2_zigbee_PTM215ZE01 stateFormat action


structure

defmod structLichtszenenWz structure lightSwitch enoSwitch05 enoSwitch03  MQTT2_zigbee_PTM215ZE01
attr structLichtszenenWz clientstate_behavior last
attr structLichtszenenWz filterEvents 1


Hab ich da irgendetwas falsch verstanden?

Danke!

rudolfkoenig

ZitatHab ich da irgendetwas falsch verstanden?
Vermutlich nur die letzte Zeile in der Doku uebersehen:
ZitatAchtung: in struct_type map werden nur die readingName und readingName:oldVal:newVal Einträge berücksichtigt.

drhirn

Überlesen nicht. Aber zu doof um darauf richtig zu reagieren ;D
Danke Rudi! Jetzt klappt's.