Autor Thema: mqtt2.template: Contributing  (Gelesen 67139 mal)

Offline SamNitro

  • Sr. Member
  • ****
  • Beiträge: 928
Antw:mqtt2.template: Contributing
« Antwort #195 am: 09 September 2022, 17:10:44 »
Zitat von: Beta-User link=topic=[code
[/code]94495.msg1234300#msg1234300 date=1662734436]
Eigentlich ist das der falsche Thread, siehe den ersten Beitrag hier und die Links dort.

Sorry dafür.

Aber mit dem neuen Topic funktioniert es.
Danke

Edit: Doch leider nicht.

2022.09.09 17:10:22 1: PERL WARNING: Use of uninitialized value in lc at (eval 230682) line 1.
2022.09.09 17:10:22 3: eval: my $CID=   $evalSpecials->{'%CID'};my $DEVICETOPIC=   $evalSpecials->{'%DEVICETOPIC'};my $EVENT=   $evalSpecials->{'%EVENT'};my $EVTPART0=   $evalSpecials->{'%EVTPART0'};my $JSONMAP=   $evalSpecials->{'%JSONMAP'};my $NAME=   $evalSpecials->{'%NAME'};my $TOPIC=   $evalSpecials->{'%TOPIC'};{ my $ret=json2nameValue($EVENT,'',$JSONMAP);; $ret->{state}=lc($ret->{state});; return $ret }

« Letzte Änderung: 09 September 2022, 17:21:36 von SamNitro »
(Intel-Nuc Proxmox) (Homematic) (EnOcean) (CUL868) (CUL433) (Zigbee2MQTT) (ESP8266) (Echo) (DUOFERN)

Offline laberlaib

  • Full Member
  • ***
  • Beiträge: 246
Antw:mqtt2.template: Contributing
« Antwort #196 am: 07 Oktober 2022, 09:23:21 »
Hallo,
ich habe ein paar "Moes 3 Channel Schalter" und das zigbee2mqtt_3channel_split Template benutzt. Um es korrekt nutzen zu können musste ich etwas ergänzen, welches ich mir beim 2 Kanal schalter abgeguckt habe. Bei Bedarf bitte gerne im Git anpassen. Danke

For zigbee2mqtt 3 channel device like Silvercrest Steckerleiste »Zigbee Smart Home«.
NOTE: Two additional devices will be created for further channels.
NOTE: Untested updated version

attr DEVICE icon ICON
attr DEVICE eventMap { dev=>{ON=>'on',OFF=>'off'} }
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) }
attr DEVICE jsonMap state:availability state_l1:state state_l2:0 state_l3:0
attr DEVICE setList \
  on:noArg $\DEVICETOPIC/1/set {"state_l1":"ON"}\
  off:noArg $\DEVICETOPIC/1/set {"state_l1":"OFF"}\
  toggle:noArg $\DEVICETOPIC/1/set {"state_l1":"TOGGLE"}
attr DEVICE setStateList on off toggle
deletereading -q DEVICE (?!associatedWith|IODev).*
set DEVICE attrTemplate set_associatedWith \CHANNELS=3 \MAKECOPIES=1
attr DEVICE_CH2 setList \
  on:noArg $\DEVICETOPIC/2/set {"state_l2":"ON"}\
  off:noArg $\DEVICETOPIC/2/set {"state_l2":"OFF"}\
  toggle:noArg $\DEVICETOPIC/2/set {"state_l2":"TOGGLE"}
attr DEVICE_CH2 jsonMap state_l2:state state_l1:0 state_l3:0 state:0 consumption:0 linkquality:0 power:0 temperature:0
attr DEVICE_CH3 setList \
  on:noArg $\DEVICETOPIC/3/set {"state_l3":"ON"}\
  off:noArg $\DEVICETOPIC/3/set {"state_l3":"OFF"}\
  toggle:noArg $\DEVICETOPIC/3/set {"state_l3":"TOGGLE"}
attr DEVICE_CH2 jsonMap state_l3:state state_l1:0 state_l2:0 state:0 consumption:0 linkquality:0 power:0 temperature:0
set DEVICE,DEVICE_CH2,DEVICE_CH3 attrTemplate speechcontrol_type_switch
attr DEVICE,DEVICE_CH2,DEVICE_CH3 model zigbee2mqtt_3channel_split
setreading DEVICE,DEVICE_CH2,DEVICE_CH3 attrTemplateVersion 20211030

ändern in:
  on:noArg $\DEVICETOPIC/l2/set {"state_l2":"ON"}\
  off:noArg $\DEVICETOPIC/l2/set {"state_l2":"OFF"}\
  toggle:noArg $\DEVICETOPIC/l2/set {"state_l2":"TOGGLE"}
.....
  on:noArg $\DEVICETOPIC/l3/set {"state_l3":"ON"}\
  off:noArg $\DEVICETOPIC/l3/set {"state_l3":"OFF"}\
  toggle:noArg $\DEVICETOPIC/l3/set {"state_l3":"TOGGLE"}
[/code]

Das "l" fehlte bei state_l2 und l3.

Ich habe daraus einen 5er-Split gebaut (getestet):
!Ich musste danach FHEM neu starten, damit die Dinger schalten; davor konnte nur das original Device schalten. Jetzt klappts.
# zigbee2mqtt 5 channel device
name:zigbee2mqtt_5channel_split
filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
desc:For zigbee2mqtt 5 channel device like UseeLink Steckerleiste SM-0306E-2W. <br>NOTE: Four additional devices will be created for further channels.<br>NOTE: Untested updated version
order:L_05g
par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
par:ICON;ICON as set, defaults to message_socket;{ AttrVal('DEVICE','icon','message_socket') }
attr DEVICE icon ICON
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE readingList $\DEVICETOPIC:.* { my $ret=json2nameValue($EVENT,'',$JSONMAP); $ret->{state}=lc($ret->{state}); return $ret }
attr DEVICE jsonMap state:availability state_l1:state state_l2:0 state_l3:0 state_l4:0 state_l5:0
attr DEVICE setList \
  on:noArg $\DEVICETOPIC/set {"state_l1":"ON"}\
  off:noArg $\DEVICETOPIC/set {"state_l1":"OFF"}\
  toggle:noArg $\DEVICETOPIC/set {"state_l1":"TOGGLE"}
attr DEVICE setStateList on off toggle
deletereading -q DEVICE (?!associatedWith|IODev).*
set DEVICE attrTemplate set_associatedWith \CHANNELS=5 \MAKECOPIES=1
loop:#:2:3:4:5
defmod DEVICE_CH# MQTT2_\DEVICE
attr DEVICE_CH# setList \
  on:noArg $\DEVICETOPIC/set {"state_l#":"ON"}\
  off:noArg $\DEVICETOPIC/set {"state_l#":"OFF"}\
  toggle:noArg $\DEVICETOPIC/set {"state_l#":"TOGGLE"}
loop:END
attr DEVICE_CH2 jsonMap state_l2:state state_l1:0 state_l3:0 state_l4:0 state_l5:0 state:0
attr DEVICE_CH3 jsonMap state_l3:state state_l1:0 state_l2:0 state_l4:0 state_l5:0 state:0
attr DEVICE_CH4 jsonMap state_l4:state state_l1:0 state_l2:0 state_l3:0 state_l5:0 state:0
attr DEVICE_CH5 jsonMap state_l5:state state_l1:0 state_l2:0 state_l3:0 state_l4:0 state:0
set DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4,DEVICE_CH5 attrTemplate speechcontrol_type_switch
attr DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4,DEVICE_CH5 model zigbee2mqtt_5channel_split
setreading DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4,DEVICE_CH5 attrTemplateVersion 20221007
Für z.B. das hier:
https://smile.amazon.de/UseeLink-Steckdosenleiste-erforderlich-Einzelschalter-USB-Verl%C3%A4ngerungskabel-Wei%C3%9F/dp/B093HG7LTB/
Funktioniert mit zigbee2mqtt (evtl. vorher updaten); USB schaltbar; leider keine Schalter an der Leiste selbst.
Endlich die ganzen Zwischenstecker weg.
--
Proxmox, Homematic, G-Tags, Zigbee2MQTT, Rhasspy Sprachsteuerung im Aufbau (beta)

Offline drhirn

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1975
Antw:mqtt2.template: Contributing
« Antwort #197 am: 28 Oktober 2022, 10:46:04 »
Ich hätte da ein Template für den Aqara Curtain Driver E1

Index: mqtt2.template
===================================================================
--- mqtt2.template (revision 26604)
+++ mqtt2.template (working copy)
@@ -912,6 +912,28 @@
 attr DEVICE model zigbee2mqtt_aqara_cube
 setreading DEVICE attrTemplateVersion 20210226
 
+# Aqara Curtain Driver E1
+name:zigbee2mqtt_aqara_curtain_driver
+desc:Aqara curtain driver E1 via zigbee2mqtt.<br>Tested with: <a href="https://www.zigbee2mqtt.io/devices/ZNCLBL01LM.html">ZNCLBL01LM</a>.
+filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
+order:L_18
+par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
+par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
+attr DEVICE devicetopic BASE_TOPIC/DEV_ID
+attr DEVICE readingList $\DEVICETOPIC/availability:.* availability\
+  $\DEVICETOPIC:.* { json2nameValue($EVENT) }
+attr DEVICE event-on-change-reading .*
+attr DEVICE setList open:noArg $\DEVICETOPIC/set {"state": "OPEN"}\
+  close:noArg $\DEVICETOPIC/set {"state": "CLOSE"}\
+  stop:noArg $\DEVICETOPIC/set {"state": "STOP"}\
+  position:slider,0,1,100 $\DEVICETOPIC/set {"position": "$EVTPART1"}
+attr DEVICE stateFormat position
+attr DEVICE devStateIcon 0:fts_shutter_100 (\d|1\d):fts_shutter_90 2\d:fts_shutter_80 3\d:fts_shutter_70 4\d:fts_shutter_60 5\d:fts_shutter_50 6\d:fts_shutter_40 7\d:fts_shutter:30 8\d:fts_shutter_20 9\d:fts_shutter_10 100:fts_window_2w
+attr DEVICE webCmd open:close:stop
+deletereading -q DEVICE (?!associatedWith|IODev).*
+attr DEVICE model zigbee2mqtt_aqara_curtain_driver
+setreading DEVICE attrTemplateVersion 20221028
+
 #source post: https://forum.fhem.de/index.php/topic,94494.msg983905.html#msg983905
 name:zigbee2mqtt_AlarmSensor
 desc: Alarm  sensor via zigbee2mqtt <br>Can report actions drop, tilt or vibration as well as x,y,z coordinates of its movement.<br>Sensitivity can be set to low, medium or high.<br>Tested with: Xiaomi DJT11LM Vibration Sensor

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 19350
Antw:mqtt2.template: Contributing
« Antwort #198 am: 31 Oktober 2022, 06:57:29 »
THX. Hab's etwas verändert eingecheckt.
Vielleicht sollte man die Namen der beiden "Brüder" überdenken, es gab schon ein "blind"-template, das sehr ähnlich ist, bis auf die Option, die Laufgeschwindigkeit einzustellen.
Server: HP-T620@Debian 11, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

Offline drhirn

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1975
Antw:mqtt2.template: Contributing
« Antwort #199 am: 31 Oktober 2022, 10:00:44 »
Klar. Warum nicht. Spart ein paar Zeilen Code.

Offline drhirn

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1975
Antw:mqtt2.template: Contributing
« Antwort #200 am: 31 Oktober 2022, 10:04:19 »
Zeile 698 hat sich leider ein Fehler eingeschlichen:
$\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP)) }Das ist eine schließende Klammer zu viel

Offline JJ_Pamoux

  • New Member
  • *
  • Beiträge: 4
Antw:mqtt2.template: Contributing
« Antwort #201 am: 05 November 2022, 21:25:40 »
Ich habe einen Neo AB02B2 "Alarm-Gong" https://www.zigbee2mqtt.io/devices/NAS-AB02B2.html angebunden.

Habe dafür folgendes Template genutzt:
# NEO AB02B2 Alarm Sound
name:zigbee2mqtt_alarm_sound
desc: Alarm sound controller via zigbee2mqtt <br>Tested with: Tuya Neo NAS-AB02B2 sound device
filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
par:ICON;ICON as set, defaults to it_remote;{ AttrVal("DEVICE","icon","audio_volume_mid") }
attr DEVICE icon ICON
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE stateFormat Alarm: alarm  Volume: volume  Duration: duration  Melody: melody  Batterie: battpercentage %  Linkquality: linkquality
attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT) }
attr DEVICE setList \
  alarm:true,false $\DEVICETOPIC/set {"alarm": "$EVTPART1"}\
  volume:low,medium,high $\DEVICETOPIC/set {"volume": "$EVTPART1"}\
  duration:slider,0,1,1800 $\DEVICETOPIC/set {"duration": "$EVTPART1"}\
  melody:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 $\DEVICETOPIC/set {"melody": "$EVTPART1"}
attr DEVICE model zigbee2mqtt_alarm_sound
deletereading -q DEVICE (?!associatedWith|IODev).*
setreading DEVICE attrTemplateVersion 20200904

Wenigstens noch kurz die Warnung, dass das Gerät wohl nicht immer zuverlässig ist: https://github.com/Koenkk/zigbee2mqtt/issues/12542

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 19350
Antw:mqtt2.template: Contributing
« Antwort #202 am: 06 November 2022, 10:29:25 »
THX, hab's eingecheckt.

(Das andere mit der Klammer ist schon länger gefixt)
Server: HP-T620@Debian 11, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

 

decade-submarginal