From b3157af94ef49e3f1a23e9deda9f640541a0d6cd Mon Sep 17 00:00:00 2001
From: Beta-User <>
Date: Mon, 3 Feb 2020 15:03:07 +0000
Subject: [PATCH] mqtt2.template: add speech recognition extensions
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@21105 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
CHANGED | 1 +
FHEM/lib/AttrTemplate/mqtt2.template | 108 +++++++++++++++++++++++----
2 files changed, 96 insertions(+), 13 deletions(-)
diff --git a/CHANGED b/CHANGED
index 6650cf4e1..da800f392 100644
--- a/CHANGED
+++ b/CHANGED
@@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
+ - feature mqtt2.template: add speech recognition extensions
- bugfix: 73_AutoShuttersControl: fix AntiFreeze_Fn
- feature 14_SD_UT: new model remote control Novy_840039
- bugfix: 88_Timer: fix2 list "Probably associated with" Forum: #1015549
diff --git a/FHEM/lib/AttrTemplate/mqtt2.template b/FHEM/lib/AttrTemplate/mqtt2.template
index 6ede8c32f..f2490e1f1 100644
--- a/FHEM/lib/AttrTemplate/mqtt2.template
+++ b/FHEM/lib/AttrTemplate/mqtt2.template
@@ -51,6 +51,58 @@ setreading DEVCID associatedWith DEVICE
farewell:template has been applied successfully. Be carefull when extending the brigeRegexp!
attr DEVCID model MQTT2_CLIENT_general_bridge
+###########################################
+# speech recognition extensions
+# see forum thread here: https://forum.fhem.de/index.php/topic,99195.0.html
+name:mqtt2_speech_recognition_type_switch
+filter:TYPE=MQTT2_DEVICE:FILTER=CID=speechrecognTesting
+order:100001
+option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0}
+attr DEVICE genericDeviceType switch
+option:TYPE=siri
+option:TYPE=alexa
+option:TYPE=gassistant
+
+name:mqtt2_speech_recognition_type_light
+filter:TYPE=MQTT2_DEVICE:FILTER=CID=speechrecognTesting
+order:100002
+option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0}
+attr DEVICE genericDeviceType light
+option:TYPE=siri
+option:TYPE=alexa
+option:TYPE=gassistant
+
+name:mqtt2_speech_recognition_type_light_255
+filter:TYPE=MQTT2_DEVICE:FILTER=CID=speechrecognTesting
+order:100003
+option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light
+attr DEVICE genericDeviceType light
+attr DEVICE homebridgeMapping Brightness=brightness::brightness,minValue=0,maxValue=255
+option:TYPE=siri
+option:TYPE=alexa
+option:TYPE=gassistant
+
+name:mqtt2_speech_recognition_type_blind
+filter:TYPE=MQTT2_DEVICE:FILTER=CID=speechrecognTesting
+order:100004
+option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0}
+attr DEVICE genericDeviceType blind
+option:TYPE=siri
+option:TYPE=alexa
+option:TYPE=gassistant
+
+name:mqtt2_speech_recognition_type_thermostate
+filter:TYPE=MQTT2_DEVICE:FILTER=CID=speechrecognTesting
+order:100005
+option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0}
+attr DEVICE genericDeviceType thermostate
+option:TYPE=siri
+option:TYPE=alexa
+option:TYPE=gassistant
+
+
+
###########################################
# zigbee2mqtt
# The zigbee2mqtt bridge device (entire hex id of devices as bridgeRegexp)
@@ -136,6 +188,7 @@ attr DEVICE setList \
off:noArg BASE_TOPIC/DEV_ID/set {"state":"OFF"}\
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}
attr DEVICE setStateList on off
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_dimmer
# A dimmable color light connected via zigbee2mqtt
@@ -154,6 +207,7 @@ attr DEVICE setList \
off:noArg BASE_TOPIC/DEV_ID/set {"state":"OFF"}\
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
color_temp:colorpicker,CT,154,2,500 BASE_TOPIC/DEV_ID/set {"$EVTPART0":"$EVTPART1"}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_cct
#source post: https://forum.fhem.de/index.php/topic,97303.msg905935.html#msg905935
@@ -175,6 +229,7 @@ attr DEVICE setList \
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
hex:colorpicker,HEX,0,15,255 BASE_TOPIC/DEV_ID/set {"color":{"$EVTPART0":"#$EVTPART1"}}
attr DEVICE userReadings hex:color_y.* {Color::xyY2hex(ReadingsVal($name,"color_x",0),ReadingsVal($name,"color_y",0),ReadingsVal($name,"brightness",254))}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgb_hex
name:zigbee2mqtt_light_rgb_rgb
@@ -194,6 +249,7 @@ attr DEVICE setList \
off:noArg BASE_TOPIC/DEV_ID/set {"state":"OFF"}\
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
color:colorpicker,RGB {"BASE_TOPIC/DEV_ID/set ".zigbee2mqtt_RGB2JSON($EVTPART1)}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgb_rgb
#source post: https://forum.fhem.de/index.php/topic,97303.msg905935.html#msg905935
@@ -218,6 +274,7 @@ attr DEVICE setList \
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
hex:colorpicker,HEX,0,15,255 BASE_TOPIC/DEV_ID/set {"color":{"$EVTPART0":"#$EVTPART1"}}
attr DEVICE userReadings hex:color_y.* {Color::xyY2hex(ReadingsVal($name,"color_x",0),ReadingsVal($name,"color_y",0),ReadingsVal($name,"brightness",254))}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgbw_hex
#source post: https://forum.fhem.de/index.php/topic,97303.msg905935.html#msg905935
@@ -239,6 +296,7 @@ attr DEVICE setList \
white:noArg BASE_TOPIC/DEV_ID/set {"color_temp": 154 , "color_temp": 500}\
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
color:colorpicker,RGB {"BASE_TOPIC/DEV_ID/set ".zigbee2mqtt_RGB2JSON($EVTPART1)}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgbw_rgb
#source post: https://forum.fhem.de/index.php/topic,96985.msg902627.html#msg902627
@@ -260,6 +318,7 @@ attr DEVICE setList \
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
color_temp:colorpicker,CT,154,2,500 BASE_TOPIC/DEV_ID/set {"$EVTPART0":"$EVTPART1"}\
hex:colorpicker,HEX,0,15,255 BASE_TOPIC/DEV_ID/set {"color":{"$EVTPART0":"#$EVTPART1"}}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgbcct_hex
#source post: https://forum.fhem.de/index.php/topic,97303.msg905935.html#msg905935
@@ -281,6 +340,7 @@ attr DEVICE setList \
brightness:colorpicker,BRI,0,5,255 BASE_TOPIC/DEV_ID/set {"state":"on","$EVTPART0":"$EVTPART1"}\
color_temp:colorpicker,CT,154,2,500 BASE_TOPIC/DEV_ID/set {"$EVTPART0":"$EVTPART1"}\
color:colorpicker,RGB {"BASE_TOPIC/DEV_ID/set ".zigbee2mqtt_RGB2JSON($EVTPART1)}
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgbcct_rgb
name:zigbee2mqtt_smokeDetector
@@ -318,6 +378,7 @@ attr DEVICE setList \
on:noArg BASE_TOPIC/DEV_ID/set {"state":"ON"}\
off:noArg BASE_TOPIC/DEV_ID/set {"state":"OFF"}\
attr DEVICE setStateList on off
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_plug
name:zigbee2mqtt_plug_w_energy_measuring
@@ -331,6 +392,7 @@ attr DEVICE icon ICON
set DEVICE attrTemplate zigbee2mqtt_smart+plug
#missing readingList with sth. comparable to shellies/shellyplug-s-123456/relay/0/power:.* { my $limit = 100;; my $compare = $EVTPART0<$limit ? "off":"on";; ReadingsVal($NAME,"loadState","on") eq $compare ? undef: {loadState => $compare} }
#and additional devStateIcon
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_plug_w_energy_measuring
# zigbee2mqtt 2 channel device
@@ -352,6 +414,7 @@ attr DEVICE setStateList on off
deletereading -q DEVICE (?!associatedWith).*
attr DEVICE comment Channel 1 for DEVICE, see also DEVICE_CH2
setreading DEVICE associatedWith DEVICE_CH2
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_2channel_split
copy DEVICE DEVICE_CH2
attr DEVICE_CH2 comment Channel 2 for DEVICE
@@ -362,6 +425,7 @@ attr DEVICE_CH2 setList \
attr DEVICE_CH2 setStateList on off toggle
deletereading -q DEVICE_CH2 (?!associatedWith).*
attr DEVICE_CH2 jsonMap state_l1:0 state_l2:state state:0 consumption:0 linkquality:0 power:0 temperature:0
+set DEVICE_CH2 attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE_CH2 model zigbee2mqtt_2channel_split
# zigbee2mqtt 2 channel device with buttons, forum #102866
@@ -492,6 +556,7 @@ attr DEVICE icon ICON
attr DEVICE stateFormat click
attr DEVICE readingList BASE_TOPIC/DEV_ID:.* { json2nameValue($EVENT) }
deletereading -q DEVICE (?!associatedWith).*
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_Light_Switch
#source post: https://forum.fhem.de/index.php/topic,94495.msg916789.html#msg916789
@@ -583,6 +648,7 @@ deletereading -q DEVICE (?!associatedWith).*
attr DEVICE setStateList on off toggle
attr DEVICE comment NOTE: For on-for-timer SetExtensions are used. You may add on-for-timer option running on the device. The following is limited to 1h max duration, but will not affect future simple "on" commands:
on-for-timer {my $duration = $EVTPART1*10; 'cmnd/CMNDTOPIC/Backlog POWER1 1; delay '.$duration.'; POWER1 0'}
See the "Praxisbeispiele" in the wiki for "pulseTime1" alternative option and it's restrictions.
attr DEVICE autocreate 0
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
attr DEVICE model tasmota_basic_state_power1
# sonoff 1 channel device flashed with Tasmota.
@@ -699,8 +765,8 @@ attr DEVICE_CH2 comment Channel 2 (USB outlets) for DEVICE
setreading DEVICE_CH2 associatedWith DEVICE
attr DEVICE_CH2 devStateIcon on:usb:off off:usb@red:on
attr DEVICE_CH2 setStateList on off toggle
-attr DEVICE model tasmota_POW_USB_split
-attr DEVICE_CH2 model tasmota_POW_USB_split
+set DEVICE_CH2 attrTemplate mqtt2_speech_recognition_type_switch
+attr DEVICE,DEVICE_CH2 model tasmota_POW_USB_split
# plug with LED flashed with Tasmota.
name:tasmota_plug_with_rgbw_split
@@ -738,8 +804,8 @@ attr DEVICE_CH2 webCmdLabel Helligkeit\
attr DEVICE_CH2 devStateIcon {Color::devStateIcon($name,"rgb","Color","pct","state")}
attr DEVICE_CH2 setStateList on off toggle
deletereading -q DEVICE_CH2 (?!associatedWith).*
-attr DEVICE model tasmota_plug_with_rgbw_split
-attr DEVICE_CH2 model tasmota_plug_with_rgbw_split
+set DEVICE_CH2 attrTemplate mqtt2_speech_recognition_type_light_255
+attr DEVICE,DEVICE_CH2 model tasmota_plug_with_rgbw_split
#tasmota device with Infrared-circuit
name:tasmota_ir
@@ -847,6 +913,7 @@ set DEVICE attrTemplate tasmota_basic_state_power1
par:CMNDTOPIC;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}cmnd$3" : undef }
attr DEVICE comment Channel 1 for DEVICE, see also DEVICE_CH2
setreading DEVICE associatedWith DEVICE_CH2
+set DEVICE attrTemplate mqtt2_speech_recognition_type_switch
copy DEVICE DEVICE_CH2
attr DEVICE_CH2 readingList \
STATTOPIC/POWER2:.* state
@@ -858,8 +925,7 @@ attr DEVICE_CH2 setList \
on:noArg CMNDTOPIC/POWER2 1\
toggle:noArg CMNDTOPIC/POWER2 2
attr DEVICE_CH2 setStateList on off toggle
-attr DEVICE model tasmota_2channel_split
-attr DEVICE_CH2 model tasmota_2channel_split
+attr DEVICE,DEVICE_CH2 model tasmota_2channel_split
#contributed by 87insane
# tasmota 2ch as shutter device.
@@ -911,6 +977,7 @@ Use the "set x_configuration" Option. Example: "set x_configuration ShutterOpenD
Shutter specific commands available: ShutterOpenDuration1, ShutterCloseDuration1, ShutterRelay1, ShutterSetHalfway1, ShutterSetClose1, ShutterInvert1, ShutterMotordelay1, ShutterCalibration1; you may use this for general setOptions in tasmota also.\
commands may need restart to take effect.\
For calibration, use of more than one shutter device and further information on the available commands see Tasmota wiki.
+set DEVICE attrTemplate mqtt2_speech_recognition_type_blind
farewell:template has been applied successfully. Now it's recommended to set shutter's open and close duration and 50% position, see short instruction in comment attribute or the
Tasmota wiki.
attr DEVICE model tasmota_2ch_shutter_invert_1
@@ -963,10 +1030,7 @@ attr DEVICE_CH4 readingList \
STATTOPIC/POWER4:.* state
attr DEVICE_CH4 setStateList on off toggle
#set the model attr for all new devices
-attr DEVICE model tasmota_4channel_split
-attr DEVICE_CH2 model tasmota_4channel_split
-attr DEVICE_CH3 model tasmota_4channel_split
-attr DEVICE_CH4 model tasmota_4channel_split
+attr DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 model tasmota_4channel_split
# tasmota 4ch as one FHEM device.
name:tasmota_4ch_unified_icon
@@ -1050,6 +1114,7 @@ deletereading -q DEVICE (?!associatedWith).*
attr DEVICE autocreate 0
attr DEVICE devStateIcon {Color::devStateIcon($name,"rgb","Color","Dimmer","state")}
attr DEVICE webCmd Color:Color ff0000:Color 00ff00:Color 0000ff:toggle:on:off
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light
attr DEVICE model tasmota_rgb_led_controller
name:tasmota_rgbw_led
@@ -1085,6 +1150,7 @@ attr DEVICE webCmdLabel Helligkeit\
:Farbe:
attr DEVICE devStateIcon {Color::devStateIcon($name,"rgb","Color","pct","state")}
attr DEVICE setStateList on off toggle
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light
attr DEVICE model tasmota_rgbw_led
name:tasmota_rgbwct_led
@@ -1110,6 +1176,7 @@ attr DEVICE webCmdLabel Helligkeit\
:Weiss\
:Farbe\
:Temp
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light
attr DEVICE model tasmota_rgbwct_led
#source post: https://forum.fhem.de/index.php/topic,105364.0.html
@@ -1134,6 +1201,7 @@ attr DEVICE devStateIcon off:light_light_dim_00:on on:light_light_dim_90:off
attr DEVICE webCmd Dimmer
attr DEVICE comment After applying the template, the device to be controlled needs further configuration. For the necessary steps see Tasmota wiki instructions.
farewell:template has been applied successfully. Now it's recommended to do some configruation, see Tasmota wiki instructions.
+set DEVICE attrTemplate mqtt2_speech_recognition_type_light
attr DEVICE model tasmota_TuyaMCU_dimmer
name:tasmota_set_lowercase_texts_and_state1
@@ -1185,6 +1253,7 @@ attr DEVICE readingList \
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,"online","false") eq "false" ? "rot" : ReadingsVal($name,"new_fw","false") eq "true" ? "gelb" : "gruen";; my $light = ReadingsVal($name,"state","off");; my $show = '" : "http://".ReadingsVal($name,"ip","none").' "target="_blank">';;$show .= FW_makeImage("10px-kreis-".$onl)."";; "