From 8afc43622f22c614b49f2adf62d4c3fba933e1b6 Mon Sep 17 00:00:00 2001
From: Beta-User <>
Date: Fri, 28 Feb 2020 14:33:32 +0000
Subject: [PATCH] speechrecogn.template: add new attrTemplate file for general
speech recognition, forum #99195
git-svn-id: https://svn.fhem.de/fhem/trunk@21306 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/FHEM/lib/AttrTemplate/mqtt2.template | 142 ++++++------------
.../lib/AttrTemplate/speechrecogn.template | 65 ++++++++
3 files changed, 110 insertions(+), 98 deletions(-)
create mode 100644 fhem/FHEM/lib/AttrTemplate/speechrecogn.template
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 0c078d40a..2b6aa69e9 100644
--- a/fhem/CHANGED
+++ b/fhem/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: Add new AttrTemplate file for speech recognition
- change: 70_DENON_AVR: improved soundMode readings (thx Shadow3561)
- bugfix: 21_HEOSMaster: fix rename passwordstore bug
- bugfix: 73_GardenaSmartBridge: fix rename passwordstore bug
diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template
index 4d303b093..d7f41510a 100644
--- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template
+++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template
@@ -51,60 +51,6 @@ 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
-#par:NEWUSERREADINGS;NEWUSERREADINGS as set if sr_brightness is included, otherwise it will be added;{ my $old = AttrVal("DEVICE","userReadings",undef);; !defined $old ? 'sr_brightness:brightness.* {sprintf("%.0f", ReadingsNum("$name","brightness",0)/255*100)}' : $old =~ m,sr_brightness:brightness.*, ? $old : $old.', sr_brightness:brightness.* {sprintf("%.0f", ReadingsNum("$name","brightness",0)/255*100)}' }
-attr DEVICE genericDeviceType light
-attr DEVICE homebridgeMapping Brightness=brightness::brightness,maxValue=100,factor=0.39216,delay=true
-#attr DEVICE userReadings NEWUSERREADINGS
-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)
@@ -190,7 +136,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
+set DEVICE attrTemplate speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_dimmer
# A dimmable color light connected via zigbee2mqtt
@@ -209,7 +155,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
+set DEVICE attrTemplate speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_cct
#source post: https://forum.fhem.de/index.php/topic,97303.msg905935.html#msg905935
@@ -231,7 +177,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
+set DEVICE attrTemplate speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgb_hex
name:zigbee2mqtt_light_rgb_rgb
@@ -251,7 +197,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
+set DEVICE attrTemplate 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
@@ -276,7 +222,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
+set DEVICE attrTemplate 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
@@ -298,7 +244,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
+set DEVICE attrTemplate 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
@@ -320,7 +266,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
+set DEVICE attrTemplate 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
@@ -342,7 +288,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
+set DEVICE attrTemplate speech_recognition_type_light_255
attr DEVICE model zigbee2mqtt_light_rgbcct_rgb
name:zigbee2mqtt_smokeDetector
@@ -380,7 +326,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
+set DEVICE attrTemplate speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_plug
name:zigbee2mqtt_plug_w_energy_measuring
@@ -394,7 +340,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
+set DEVICE attrTemplate speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_plug_w_energy_measuring
# zigbee2mqtt 2 channel device
@@ -416,7 +362,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
+set DEVICE attrTemplate speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_2channel_split
copy DEVICE DEVICE_CH2
attr DEVICE_CH2 comment Channel 2 for DEVICE
@@ -427,7 +373,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
+set DEVICE_CH2 attrTemplate speech_recognition_type_switch
attr DEVICE_CH2 model zigbee2mqtt_2channel_split
# zigbee2mqtt 2 channel device with buttons, forum #102866
@@ -558,7 +504,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
+set DEVICE attrTemplate speech_recognition_type_switch
attr DEVICE model zigbee2mqtt_Light_Switch
#source post: https://forum.fhem.de/index.php/topic,94495.msg916789.html#msg916789
@@ -650,7 +596,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
+set DEVICE attrTemplate speech_recognition_type_switch
attr DEVICE model tasmota_basic_state_power1
# sonoff 1 channel device flashed with Tasmota.
@@ -767,7 +713,7 @@ 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
-set DEVICE_CH2 attrTemplate mqtt2_speech_recognition_type_switch
+set DEVICE_CH2 attrTemplate speech_recognition_type_switch
attr DEVICE,DEVICE_CH2 model tasmota_POW_USB_split
# plug with LED flashed with Tasmota.
@@ -806,7 +752,7 @@ 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).*
-set DEVICE_CH2 attrTemplate mqtt2_speech_recognition_type_light_255
+set DEVICE_CH2 attrTemplate speech_recognition_type_light_255
attr DEVICE,DEVICE_CH2 model tasmota_plug_with_rgbw_split
#tasmota device with Infrared-circuit
@@ -915,7 +861,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
+set DEVICE attrTemplate speech_recognition_type_switch
copy DEVICE DEVICE_CH2
attr DEVICE_CH2 readingList \
STATTOPIC/POWER2:.* state
@@ -979,7 +925,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
+# set DEVICE attrTemplate 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
@@ -993,7 +939,7 @@ par:IO_DEV;Currently used IO;{ AttrVal("DEVICE","IODev",undef)}
set DEVICE attrTemplate tasmota_2ch_shutter_invert_1
defmod configure_DEVICEattrTemplate_at at +00:00:20 set IO_DEV publish CMNDTOPIC/Backlog ShutterOpenDuration1 20;; ShutterCloseDuration1 20;; ShutterInvert1 0;; SaveData 1;;
attr DEVICE devStateIcon opening:fts_shutter_up@red closing:fts_shutter_down@red Online:10px-kreis-gruen Offline:10px-kreis-rot 100:fts_shutter_10 0:fts_shutter_100 9\d.*:fts_shutter_10 8\d.*:fts_shutter_20 7\d.*:fts_shutter_30 6\d.*:fts_shutter_40 5\d.*:fts_shutter_50 4\d.*:fts_shutter_60 3\d.*:fts_shutter_70 2\d.*:fts_shutter_80 1\d.*:fts_shutter_90 \b\d\b.*:fts_shutter_90
-set DEVICE attrTemplate mqtt2_speech_recognition_type_blind
+set DEVICE attrTemplate speech_recognition_type_blind
attr DEVICE model tasmota_2ch_shutter_invert_0
# sonoff 4 channel device flashed with Tasmota.
@@ -1167,7 +1113,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
+set DEVICE attrTemplate speech_recognition_type_light
attr DEVICE model tasmota_rgb_led_controller
name:tasmota_rgbw_led
@@ -1203,7 +1149,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
+set DEVICE attrTemplate speech_recognition_type_light
attr DEVICE model tasmota_rgbw_led
name:tasmota_rgbwct_led
@@ -1229,7 +1175,7 @@ attr DEVICE webCmdLabel Helligkeit\
:Weiss\
:Farbe\
:Temp
-set DEVICE attrTemplate mqtt2_speech_recognition_type_light
+set DEVICE attrTemplate speech_recognition_type_light
attr DEVICE model tasmota_rgbwct_led
#source post: https://forum.fhem.de/index.php/topic,105364.0.html
@@ -1254,7 +1200,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
+set DEVICE attrTemplate speech_recognition_type_light
attr DEVICE model tasmota_TuyaMCU_dimmer
name:tasmota_set_lowercase_texts_and_state1
@@ -1306,7 +1252,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)."";; "