diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index 560959a21..b63049547 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -137,14 +137,14 @@ attr DEVICE model L_05_zigbee2mqtt_smart+plug name:A_01a_tasmota_basic_state_power1 filter:TYPE=MQTT2_DEVICE desc:Applies to Sonoff Basic, S20 using POWER1-topic for relay state
Use this in case "SetOption26 1" was used as described in tasmota documentation
NOTE: This template is intended to configure also channel one of multi-channel tasmota devices -par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } +#par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef } attr DEVICE stateFormat POWER1 attr DEVICE eventMap { dev=>{'^(.*)POWER(.?): OFF$'=>'$1POWER$2: off', '^(.*)POWER(.?): ON$'=>'$1POWER$2: on'} } attr DEVICE setList \ - off:noArg COMMAND/POWER1 0\ - on:noArg COMMAND/POWER1 1\ - toggle:noArg COMMAND/POWER1 2 + off:noArg cmnd/DEVNAME/POWER1 0\ + on:noArg cmnd/DEVNAME/POWER1 1\ + toggle:noArg cmnd/DEVNAME/POWER1 2 attr DEVICE readingList \ tele/DEVNAME/LWT:.* LWT\ tele/DEVNAME/STATE:.* { json2nameValue($EVENT) }\ @@ -161,13 +161,18 @@ name:A_01_tasmota_basic filter:TYPE=MQTT2_DEVICE desc:Applies to Sonoff 1 Channel devices using POWER-topic for relay state set DEVICE attrTemplate A_01a_tasmota_basic_state_power1 +#par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } attr DEVICE stateFormat POWER +attr DEVICE setList \ + off:noArg cmnd/DEVNAME/POWER 0\ + on:noArg cmnd/DEVNAME/POWER 1\ + toggle:noArg cmnd/DEVNAME/POWER 2 attr DEVICE model A_01_tasmota_basic name:A_01x_tasmota_clear_readings_reset_readingsList_and_reboot filter:TYPE=MQTT2_DEVICE desc: replaces the readingList with defaults, clears the readingList and reboots to get all readings -par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } +#par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef } par:IO_DEV;Currently used IO;{ AttrVal("DEVICE","IODev","")} attr DEVICE readingList \ @@ -177,19 +182,19 @@ attr DEVICE readingList \ tele/DEVNAME/INFO.:.* { json2nameValue($EVENT) }\ stat/DEVNAME/RESULT:.* { json2nameValue($EVENT) } deletereading DEVICE .* -set IO_DEV publish COMMAND/Restart 1 +set IO_DEV publish cmnd/DEVNAME/Restart 1 attr DEVICE autocreate 0 name:A_01x_tasmota_prefix_clearing_and_reboot filter:TYPE=MQTT2_DEVICE desc:Applies to all tasmota devices
NOTE: This template will delete some readings and clear the readingList from prefix use when expanding json.
When applying the template the tasmota device is rebooted to get all readings -par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } +#par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef } par:IO_DEV;Currently used IO;{ AttrVal("DEVICE","IODev","")} par:READINGLISTCLEARED;cleared from prefixes;{ AttrVal("DEVICE","readingList","") =~ s/, '[^_]+[_]'/, ''/g, ? $1 : undef } attr DEVICE readingList READINGLISTCLEARED deletereading DEVICE .* -set IO_DEV publish COMMAND/Restart 1 +set IO_DEV publish cmnd/DEVNAME/Restart 1 attr DEVICE autocreate 0 # tasmota device with one relay, one motion sensor via switch @@ -241,16 +246,16 @@ name:A_02_tasmota_2channel_split filter:TYPE=MQTT2_DEVICE desc:sonoff 2 channel device flashed with Tasmota.
NOTE: a second device will be created for the second channel set DEVICE attrTemplate A_01a_tasmota_basic_state_power1 -par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } +#par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef } attr DEVICE comment Channel 1 for DEVICE, see also DEVICE_CH2 copy DEVICE DEVICE_CH2 attr DEVICE_CH2 stateFormat POWER2 attr DEVICE_CH2 comment Channel 2 for DEVICE setreading DEVICE_CH2 associatedWith DEVICE attr DEVICE_CH2 setList \ - off:noArg COMMAND/POWER2 0\ - on:noArg COMMAND/POWER2 1\ - toggle:noArg COMMAND/POWER2 2 + off:noArg cmnd/DEVNAME/POWER2 0\ + on:noArg cmnd/DEVNAME/POWER2 1\ + toggle:noArg cmnd/DEVNAME/POWER2 2 attr DEVICE model A_02_tasmota_2channel_split