From f02e6296d1ff0332fa3eb27083c6c55affe02a87 Mon Sep 17 00:00:00 2001
From: Beta-User <>
Date: Sat, 15 Dec 2018 14:19:09 +0000
Subject: [PATCH] mqtt2.template: change basis to A_01_tasmota_basic_noprefix
and always use STATE1 for stateFormat; forum #872269
git-svn-id: https://svn.fhem.de/fhem/trunk@17980 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/lib/AttrTemplate/mqtt2.template | 41 ++++++++++++-----------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template
index 689ae5439..0aa785c65 100644
--- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template
+++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template
@@ -113,28 +113,36 @@ attr DEVICE setList \
# - DVES_XXXXXX:/SmartHome/Esszimmer/Stehlampe/tele/LWT: => /SmartHome/Esszimmer/Stehlampe/cmnd/
name:A_01_tasmota_basic_noprefix
filter:TYPE=MQTT2_DEVICE
-desc:Applies to Sonoff Basic, S20 using POWER-topic for relay state
+desc:Applies to Sonoff Basic, S20 using POWER1-topic for relay state
par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef }
set DEVICE attrTemplate A_09x_tasmota_pure_base_noprefix
-attr DEVICE stateFormat {lc ReadingsVal("$name","POWER","") }
+attr DEVICE stateFormat {lc ReadingsVal("$name","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
+attr DEVICE readingList \
+ tele/DEVNAME/LWT:.* LWT\
+ tele/DEVNAME/STATE:.* { json2nameValue($EVENT) }\
+ tele/DEVNAME/SENSOR:.* { json2nameValue($EVENT) }\
+ tele/DEVNAME/INFO.:.* { json2nameValue($EVENT) }\
+ stat/DEVNAME/RESULT:.* { json2nameValue($EVENT) }
+deleteReading DEVICE .*
+attr DEVICE autocreate 0
# sonoff 1 channel device flashed with Tasmota.
-name:A_01x_tasmota_1channel_noprefix
-filter:TYPE=MQTT2_DEVICE
-desc:Applies to Sonoff 1 Channel devices using POWER1-topic for relay state
NOTE: This template is intended to configure also channel one of multi-channel tasmota devices
-set DEVICE attrTemplate A_01_tasmota_basic
-attr DEVICE stateFormat {lc ReadingsVal("$name","POWER1","") }
+#name:A_01x_tasmota_1channel_noprefix
+#filter:TYPE=MQTT2_DEVICE
+#desc:Applies to Sonoff 1 Channel devices using POWER1-topic for relay state
NOTE: This template is intended to configure also channel one of multi-channel tasmota #devices
+#set DEVICE attrTemplate A_01_tasmota_basic
+#attr DEVICE stateFormat {lc ReadingsVal("$name","POWER1","") }
# tasmota device with one relay, one motion sensor via switch
name:A_01b_tasmota_1ch+motion+SI7021_noprefix
desc:tasmota device with one relay, one motion sensor via switch and one SI7021 combined temperature and humidity sensor.
Configures a single device including all readings
filter:TYPE=MQTT2_DEVICE
-set DEVICE attrTemplate A_01x_tasmota_1channel_noprefix
+set DEVICE attrTemplate A_01_tasmota_basic_noprefix
par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef }
attr DEVICE setList \
on:noArg cmnd/DEVNAME/POWER1 on\
@@ -159,7 +167,7 @@ name:A_02a_tasmota_2channel_2devices_noprefix
filter:TYPE=MQTT2_DEVICE
desc:sonoff 2 channel device flashed with Tasmota.
NOTE: a second device will be created for the second channel
par:COMMAND;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\btele(/.*)?/LWT:, ? "${1}cmnd$2" : undef }
-set DEVICE attrTemplate A_01x_tasmota_1channel_noprefix
+set DEVICE attrTemplate A_01_tasmota_basic_noprefix
attr DEVICE comment Channel 1 for DEVICE, see also DEVICE_CH2
copy DEVICE DEVICE_CH2
attr DEVICE_CH2 stateFormat {lc ReadingsVal("$name","POWER2","")}
@@ -170,17 +178,10 @@ attr DEVICE_CH2 setList \
toggle:noArg COMMAND/POWER2 2
# basic tasmota device with unprefixed readings
-name:A_09x_tasmota_pure_base_noprefix
-filter:TYPE=MQTT2_DEVICE
-par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef }
-attr DEVICE readingList \
- tele/DEVNAME/LWT:.* LWT\
- tele/DEVNAME/STATE:.* { json2nameValue($EVENT) }\
- tele/DEVNAME/SENSOR:.* { json2nameValue($EVENT) }\
- tele/DEVNAME/INFO.:.* { json2nameValue($EVENT) }\
- stat/DEVNAME/RESULT:.* { json2nameValue($EVENT) }
-deleteReading DEVICE .*
-attr DEVICE autocreate 0
+#name:A_09x_tasmota_pure_base_noprefix
+#filter:TYPE=MQTT2_DEVICE
+#par:DEVNAME;ESP's name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,tele/([^/]*)/, ? $1 : undef }
+
# tasmota 4ch as one FHEM device.
name:A_04a_tasmota_sonoff_4ch_noprefix