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)."";; "
$show ".FW_makeImage($light)."
" } deletereading -q DEVICE (?!associatedWith).* set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch attr DEVICE model shelly1 name:shelly_announces @@ -1363,7 +1309,7 @@ attr DEVICE comment To get appropriate loadState values: Change the default limi attr DEVICE webCmd : deletereading -q DEVICE (?!associatedWith).* set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch attr DEVICE model shelly1_w_energy_meassuring name:shelly1_w_energy_meassuring_washer_example @@ -1406,7 +1352,7 @@ attr DEVICE stateFormat pct deletereading -q DEVICE (?!associatedWith).* attr DEVICE setStateList open close stop set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_blind +set DEVICE attrTemplate speech_recognition_type_blind attr DEVICE model shelly2_roller # shelly25 using original firmware in roller mode. @@ -1452,7 +1398,7 @@ state deletereading -q DEVICE (?!associatedWith).* attr DEVICE setStateList open close half stop pct set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_blind +set DEVICE attrTemplate speech_recognition_type_blind attr DEVICE model shelly25_roller_invert_0 name:shelly25_roller_invert_1 @@ -1496,7 +1442,7 @@ state deletereading -q DEVICE (?!associatedWith).* attr DEVICE setStateList open close half stop pct set DEVICE x_mqttcom announce -#set DEVICE attrTemplate mqtt2_speech_recognition_type_blind +#set DEVICE attrTemplate speech_recognition_type_blind attr DEVICE model shelly25_roller_invert_1 # shelly2 using original firmware. @@ -1681,7 +1627,7 @@ attr DEVICE webCmd on:off:pct:ct:rgb #attr DEVICE genericDeviceType light attr DEVICE jsonMap brightness:pct set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_light +set DEVICE attrTemplate speech_recognition_type_light attr DEVICE model shellybulb # shellyht using original firmware @@ -1750,7 +1696,7 @@ attr DEVICE webCmd on:off:white:gain:rgb:effect attr DEVICE setStateList on off attr DEVICE devStateIcon {my $onl = ReadingsVal($name,"online","false") eq "true"?"10px-kreis-gruen":"10px-kreis-rot";; my $light = ReadingsVal($name,"state","off");; my $cons = ReadingsVal($name,"power","unknown");; "".FW_makeImage($onl)." ".FW_makeImage($light)."
Verbrauch: $cons
"} set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_light +set DEVICE attrTemplate speech_recognition_type_light attr DEVICE model shelly2rgbw_color #contributed by user sledge @@ -1777,7 +1723,7 @@ setreading DEVICE associatedWith DEVICE_CH1,DEVICE_CH2,DEVICE_CH4 attr DEVICE webCmd on:off:pct set DEVICE x_mqttcom announce attr DEVICE jsonMap brightness:pct -set DEVICE attrTemplate mqtt2_speech_recognition_type_light +set DEVICE attrTemplate speech_recognition_type_light attr DEVICE model shelly2rgbw_4w_split attr DEVICE comment Channel 1 for DEVICE, see also DEVICE_CH2, DEVICE_CH3 and DEVICE_CH4 attr DEVICE autocreate 0 @@ -1843,7 +1789,7 @@ attr DEVICE webCmd pct:on:off attr DEVICE jsonMap brightness:pct attr DEVICE devStateIcon {my $lderr = ReadingsVal($name,"loaderror","true") eq "true"?"10px-kreis-rot":"10px-kreis-gruen";; my $light = ReadingsVal($name,"ison","false") eq "true"?"on":"off";; my $cons = ReadingsVal($name,"light_0_power","unknown");; FW_makeImage($lderr)."".FW_makeImage($light)."
Leistung: $cons
"} set DEVICE x_mqttcom announce -set DEVICE attrTemplate mqtt2_speech_recognition_type_light +set DEVICE attrTemplate speech_recognition_type_light attr DEVICE model shellydimmer @@ -1878,7 +1824,7 @@ attr DEVICE setList on DEVNAME/relay/0/set 1\ toggle DEVNAME/relay/0/set 2 attr DEVICE setStateList on off toggle attr DEVICE event-on-change-reading .* -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch attr DEVICE model ESPurna_single_relay @@ -1929,7 +1875,7 @@ attr DEVICE stateFormat LWT\ 5:POWER5\
\ ip -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch attr DEVICE model ESPurna_4socketUSB_unified deletereading -q DEVICE relay_.* @@ -1942,7 +1888,7 @@ par:ICON;ICON as set, defaults to hue_filled_outlet;{ AttrVal("DEVICE","icon","h attr DEVICE icon ICON attr DEVICE event-on-change-reading .* attr DEVICE setStateList on off toggle -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch attr DEVICE model ESPurna_4socketUSB_split attr DEVICE devStateIcon Online:10px-kreis-gruen Offline:10px-kreis-rot attr DEVICE stateFormat ip\ @@ -2022,7 +1968,7 @@ par:ICON;ICON as set, defaults to on;{ AttrVal("DEVICE","icon","on") } attr DEVICE icon ICON attr DEVICE model 8channel_ethernet_board_split attr DEVICE setStateList on off -set DEVICE attrTemplate mqtt2_speech_recognition_type_switch +set DEVICE attrTemplate speech_recognition_type_switch deletereading -q DEVICE (?!associatedWith).* copy DEVICE DEVICE_CH2 copy DEVICE DEVICE_CH3 @@ -2197,7 +2143,7 @@ attr DEVICE setStateList on off attr DEVICE stateFormat mode\ desired-temp °C attr DEVICE webCmd mode:desired-temp -set DEVICE attrTemplate mqtt2_speech_recognition_type_thermostate +set DEVICE attrTemplate speech_recognition_type_thermostate attr DEVICE model ems-esp_thermostat_simple name:ems-esp_thermostat_RC35_type @@ -2211,7 +2157,7 @@ attr DEVICE setList mode:uzsuSelectRadio,auto,manual BASEPATH/thermostat_cmd_mod daytemp:slider,15.0,0.5,30.0,1 BASEPATH/thermostat_cmd_daytemp1 $EVTPART1\ nighttemp:slider,15.0,0.5,30.0,1 BASEPATH/thermostat_cmd_nighttemp1 $EVTPART1\ holidaytemp:slider,15.0,0.5,30.0,1 BASEPATH/thermostat_cmd_holidayttemp1 $EVTPART1 -set DEVICE attrTemplate mqtt2_speech_recognition_type_thermostate +set DEVICE attrTemplate speech_recognition_type_thermostate attr DEVICE model ems-esp_thermostat_RC35_type @@ -2273,7 +2219,7 @@ attr DEVICE userReadings hex:color_r.* {Color::rgb2hex(ReadingsVal($name,"color_ attr DEVICE setStateList on off attr DEVICE comment To switch device also on when changing brightness, change payload pattern to {"status":"ON","$EVTPART0":"$EVTPART1"} or add a new element to setList, similar to brightness, e.g.brightness_on and change payload pattern as described. attr DEVICE setExtensionsEvent 1 -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr DEVICE model esp_milight_hub_rgbw_bulb #rgbw-group @@ -2303,7 +2249,7 @@ attr milight_REMOTE_ID_0 setList\ attr milight_REMOTE_ID_0 setStateList on off #attr milight_REMOTE_ID_0 userReadings rgb:color_r.* {sprintf("%02X%02X%02X", ReadingsVal($name,"color_r",255), ReadingsVal($name,"color_g",255), ReadingsVal($name,"color_b",255))} modify milight_REMOTE_ID_0 milight_REMOTE_ID_0 -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr milight_REMOTE_ID_0 model esp_milight_hub_make_rgbw_group #rgbw_cct-bulb @@ -2346,7 +2292,7 @@ attr DEVICE webCmdLabel brightness:dim\ attr DEVICE setStateList on off # computed_color will send RGB = 255,255,255 when in white mode. This is useful for HomeAssistant where it always expects the color to be set. attr DEVICE comment To switch device also on when changing brightness, change payload pattern to {"status":"ON","$EVTPART0":"$EVTPART1"} or add a new element to setList, similar to brightness, e.g.brightness_on and change payload pattern as described. -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr DEVICE model esp_milight_hub_rgb_cct_bulb #cct-only-bulb @@ -2382,7 +2328,7 @@ attr DEVICE webCmdLabel :dim\ ::: attr DEVICE setStateList on off attr DEVICE comment To switch device also on when changing brightness, change payload pattern to {"status":"ON","$EVTPART0":"$EVTPART1"} or add a new element to setList, similar to brightness, e.g.brightness_on and change payload pattern as described. -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr DEVICE model esp_milight_hub_cct_only_bulb #rgbw-bulb @@ -2425,7 +2371,7 @@ attr DEVICE webCmdLabel An:Aus\ :Sättigung:Modus attr DEVICE eventMap /set_white:Weiss/night_mode:Nacht/white_mode:white/on:on/off:off/ON:on/OFF:off/next_mode:Mode/mode_speed_up:Faster/mode_speed_down:Slower/level_up:Up/level_down:Down/ attr DEVICE comment To switch device also on when changing brightness, change payload pattern to {"status":"ON","$EVTPART0":"$EVTPART1"} or add a new element to setList, similar to brightness, e.g.brightness_on and change payload pattern as described. -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr DEVICE model esp_milight_hub_max_features_bulb #remote for event generation only @@ -2759,7 +2705,7 @@ deletereading -q DEVICE (?!associatedWith).* attr DEVICE devStateIcon {Color::devStateIcon( $name, "rgb", "rgb", "brightness", "state" )} attr DEVICE webCmd rgb:brightness attr DEVICE comment For questions about the use of different widgets for color selection see discussion at https://forum.fhem.de/index.php/topic,98880.msg995308.html -set DEVICE attrTemplate mqtt2_speech_recognition_type_light_255 +set DEVICE attrTemplate speech_recognition_type_light_255 attr DEVICE model wled_controller #source post: https://forum.fhem.de/index.php/topic,105457.msg993924.html#msg993924 diff --git a/fhem/FHEM/lib/AttrTemplate/speechrecogn.template b/fhem/FHEM/lib/AttrTemplate/speechrecogn.template new file mode 100644 index 000000000..bed91b511 --- /dev/null +++ b/fhem/FHEM/lib/AttrTemplate/speechrecogn.template @@ -0,0 +1,65 @@ +########################################### +# $Id: speechrecogn.template first version 2020-02-28 Beta-User $ +# +# This file provides add-on templates for use with speech recognistion modules +# Originally developped for mqtt2-device, see forum thread here: https://forum.fhem.de/index.php/topic,99195.0.html +# +# NOTE: one of the following modules must be installed as a prerequisite for this set of templates to work: siri, alexa, gassistant +# +# Comments start with #. Empty lines are ignored. +# Syntax of one entry: name: line, one optional filter: line, zero or more par: lines, FHEM-Commands +# filter:INTERNAL=VALUE (optional) +# par: name of the parameter; comment; perl_code (optional) +# perl_code returns a value for the parameter, or undef. +# If undef, the user has to specify them (the comment is shown to the user) + +#original name:speech_recognition_type_switch +name:speech_recognition_type_switch +filter:NAME=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:speech_recognition_type_light +filter:NAME=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:speech_recognition_type_light_255 +filter:NAME=speechrecognTesting +order:100003 +option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} +set DEVICE attrTemplate 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:speech_recognition_type_blind +filter:NAME=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:speech_recognition_type_thermostate +filter:NAME=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 +