diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index 78cf41d38..b2d2dcf4a 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -544,19 +544,20 @@ par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devi par:ICON;ICON as set, defaults to fts_shutter_100;{ AttrVal("DEVICE","icon","fts_shutter_100") } attr DEVICE icon ICON attr DEVICE devStateIcon 0:fts_shutter_100 100:fts_shutter_10 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 0\d.*:fts_shutter_100 -attr DEVICE webCmd open:close:pct:speed +attr DEVICE webCmd open:close:stop:pct:speed attr DEVICE devicetopic BASE_TOPIC/DEV_ID attr DEVICE jsonMap position:pct motor_speed:speed attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) } attr DEVICE setList \ open:noArg $\DEVICETOPIC/set {"state":"OPEN"}\ close:noArg $\DEVICETOPIC/set {"state":"CLOSE"}\ + stop:noArg $\DEVICETOPIC/set {"state":"STOP"}\ pct:slider,0,1,100 $\DEVICETOPIC/set {"position":"$EVTPART1"}\ speed:colorpicker,BRI,0,1,255 $\DEVICETOPIC/set {"options": {"motor_speed":"$EVTPART1"}} attr DEVICE stateFormat pct set DEVICE attrTemplate speechcontrol_type_blind attr DEVICE model zigbee2mqtt_blind_drive -setreading DEVICE attrTemplateVersion 20210222 +setreading DEVICE attrTemplateVersion 20210902 name:zigbee2mqtt_ContactSensor @@ -1040,7 +1041,8 @@ filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*(tele|cmnd|stat).* desc:Applies to Sonoff POW devices and other Tasmota flashed devices with power measuring abilities.
NOTE: Power topic will be set to POWER1; the format the device is sending data will also be changed to lowercase! order:A_01c par:CMNDTOPIC;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}cmnd$3" : undef } -set DEVICE attrTemplate tasmota_basic_state_power1 CALLSPEECHRECOGN=1 +par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 } +set DEVICE attrTemplate tasmota_basic_state_power1 \CALLSPEECHRECOGN=CALLSPEECHRECOGN attr DEVICE setList \ off:noArg CMNDTOPIC/POWER1 0\ on:noArg CMNDTOPIC/POWER1 1\ @@ -1051,7 +1053,7 @@ deletereading -q DEVICE (?!associatedWith|IODev).* attr DEVICE setStateList on off toggle attr DEVICE webCmd : attr DEVICE model tasmota_POW -setreading DEVICE attrTemplateVersion 20210526 +setreading DEVICE attrTemplateVersion 20210903 # sonoff 1 channel + USB device flashed with Tasmota. @@ -1059,17 +1061,18 @@ name:tasmota_POW_USB_split filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*(tele|cmnd|stat).* desc:Plug with additional USB outlet flashed with Tasmota.
For use e.g. with Gosund SP112 or Blitzwolf SH5
NOTE: a second device will be created for the USB channel.
NOTE: still untested template, feedback is welcome! order:A_01c1 -set DEVICE attrTemplate tasmota_2channel_split CALLSPEECHRECOGN=0 -set DEVICE attrTemplate tasmota_POW -par:CMNDTOPIC;Command topic prefix, without trailing /;{ AttrVal("DEVICE","readingList","") =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}cmnd$3" : undef } -par:ICON;ICON as set, defaults to usb;{ AttrVal("DEVICE_CH2","icon","usb") } +set DEVICE attrTemplate tasmota_2channel_split \CALLSPEECHRECOGN=0 +set DEVICE attrTemplate tasmota_POW \CALLSPEECHRECOGN=0 +par:CMNDTOPIC;Command topic prefix, without trailing /;{ AttrVal('DEVICE','readingList','') =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}cmnd$3" : undef } +par:ICON;ICON as set, defaults to usb;{ AttrVal('DEVICE_CH2','icon','usb') } attr DEVICE_CH2 icon ICON attr DEVICE_CH2 comment Channel 2 (USB outlets) for DEVICE attr DEVICE_CH2 devStateIcon on:usb:off off:usb@red:on attr DEVICE_CH2 setStateList on off toggle -set DEVICE_CH2 attrTemplate speechcontrol_type_switch +set DEVICE attrTemplate speechcontrol_type_switch +set DEVICE_CH2 attrTemplate speechcontrol_type_switch \NOTDELAYED=0 attr DEVICE,DEVICE_CH2 model tasmota_POW_USB_split -setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20200529 +setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20210903 # plug with LED flashed with Tasmota. name:tasmota_plug_with_rgbw_split @@ -1110,9 +1113,9 @@ attr DEVICE_CH2 devStateIcon {Color::devStateIcon($name,"rgb","Color","pct","sta attr DEVICE_CH2 setStateList on off toggle deletereading -q DEVICE_CH2 (?!associatedWith|IODev).* set DEVICE attrTemplate speechcontrol_type_switch -set DEVICE_CH2 attrTemplate speechcontrol_type_light_255 +set DEVICE_CH2 attrTemplate speechcontrol_type_light_255 \NOTDELAYED=0 attr DEVICE,DEVICE_CH2 model tasmota_plug_with_rgbw_split -setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20200828 +setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20210903 #tasmota device with Infrared-circuit name:tasmota_ir @@ -1273,7 +1276,8 @@ setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20200529 option:{SETCHANNELINFO} set DEVICE attrTemplate set_associatedWith \CHANNELS=2 option:{ CALLSPEECHRECOGN } -set DEVICE,DEVICE_CH2 attrTemplate speechcontrol_type_switch +set DEVICE attrTemplate speechcontrol_type_switch +set DEVICE_CH2 attrTemplate speechcontrol_type_switch \NOTDELAYED=0 # sonoff 2 channel device flashed with Tasmota with dual energy meassuring. Source: https://forum.fhem.de/index.php/topic,122231.0.html @@ -1312,7 +1316,8 @@ setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20210728 option:{SETCHANNELINFO} set DEVICE attrTemplate set_associatedWith \CHANNELS=2 option:{ CALLSPEECHRECOGN } -set DEVICE,DEVICE_CH2 attrTemplate speechcontrol_type_switch +set DEVICE attrTemplate speechcontrol_type_switch +set DEVICE_CH2 attrTemplate speechcontrol_type_switch \NOTDELAYED=0 #contributed by 87insane diff --git a/fhem/FHEM/lib/AttrTemplate/speechcontrol.template b/fhem/FHEM/lib/AttrTemplate/speechcontrol.template index c69355425..9dc0a2f59 100644 --- a/fhem/FHEM/lib/AttrTemplate/speechcontrol.template +++ b/fhem/FHEM/lib/AttrTemplate/speechcontrol.template @@ -1,4 +1,3 @@ - ########################################### # $Id$ # @@ -20,76 +19,88 @@ name:speechcontrol_type_switch filter:NAME=speechrecognTesting order:100001 desc:template to set speech speechcontrol attributes for genericDeviceType switch -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} attr DEVICE genericDeviceType switch +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template name:speechcontrol_type_light filter:NAME=speechrecognTesting order:100002 desc:template to set speech speechcontrol attributes for genericDeviceType light -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} attr DEVICE genericDeviceType light +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template name:speechcontrol_type_light_255 filter:NAME=speechrecognTesting order:100003 desc:template to set speech speechcontrol attributes for genericDeviceType light - brightness in 255 steps -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} -set DEVICE attrTemplate speechcontrol_type_light +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} attr DEVICE genericDeviceType light attr DEVICE homebridgeMapping Brightness=brightness::brightness,maxValue=100,factor=0.39216,delay=true +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template name:speechcontrol_type_blind filter:NAME=speechrecognTesting order:100004 desc:template to set speech speechcontrol attributes for genericDeviceType blind -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} attr DEVICE genericDeviceType blind +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template name:speechcontrol_type_thermostat filter:NAME=speechrecognTesting order:100005 desc:template to set speech speechcontrol attributes for genericDeviceType thermostat -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} attr DEVICE genericDeviceType thermostat +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template - name:speechcontrol_gdt_only filter:filter:genericDeviceType=.+ order:100006 desc:template to set speech speechcontrol attributes for to any genericDeviceType; call e.g. with set attrTemplate speechcontrol_gdt_only GENERICDEVTYPE=Security -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} par:GENERICDEVTYPE;GENERICDEVTYPE , defaults to contact;{ "contact" } attr DEVICE genericDeviceType GENERICDEVTYPE +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template name:speechcontrol_gdt_and_mapping filter:filter:genericDeviceType=.+ order:100007 desc:generic template to set speech speechcontrol attributes for to any genericDeviceType including full mapping, call e.g. with set xy attrTemplate speechcontrol_gdt_and_mapping GENERICDEVTYPE=contact HOMEBRIDGEMAPPING= "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED" -option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant|RHASSPY)");;return 1 if $devices[0];;return 0} +par:NOTDELAYED;Set this to 0 to not apply naming template on first round;{ 1 } +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0];return 0} par:GENERICDEVTYPE;GENERICDEVTYPE , defaults to contact;{ "contact" } par:HOMEBRIDGEMAPPING;HOMEBRIDGEMAPPING, defaults to "some split-by-semicolon-compatible represantation or the expression to the right";{ 'ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED' } attr DEVICE genericDeviceType GENERICDEVTYPE attr DEVICE homebridgeMapping HOMEBRIDGEMAPPING +option:{my @devices=devspec2array('TYPE=(siri|alexa|gassistant|RHASSPY)');return 1 if $devices[0] && NOTDELAYED;return 0} set DEVICE attrTemplate speechcontrol_general_naming_master_template - name:speechcontrol_general_naming_master_template filter:genericDeviceType=.+ order:10000200 desc:generic template to set attributes for identifying this device by speech speechcontrol software. This template will call several sub-templates - dependent on the speech speechcontrol solutions which are in use in your installation. Pls. do not use one of the subtemplates directly. Call e.g. with set xy attrTemplate speechcontrol_general_naming_master_template -option:{my @devices=devspec2array("TYPE=alexa");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array("TYPE=alexa"); $devices[0] ? return 1 : return 0} set DEVICE attrTemplate speechcontrol_alexa_specials -option:{my @devices=devspec2array("TYPE=siri");; my @alexas=devspec2array("TYPE=alexa");; ($devices[0] && !$alexas[0]) ? AttrVal('DEVICE','genericDeviceType','none') eq 'none' ? 0 : 1 : 0 } +option:{my @devices=devspec2array('TYPE=siri'); my @alexas=devspec2array('TYPE=alexa'); ($devices[0] && !$alexas[0]) ? AttrVal('DEVICE','genericDeviceType','none') eq 'none' ? 0 : 1 : 0 } #set DEVICE attrTemplate speechcontrol_siri_specials -option:{my @devices=devspec2array("TYPE=gassistant");; $devices[0] ? return 1 : return 0} -option:{my @devices=devspec2array("TYPE=RHASSPY");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=gassistant'); $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=RHASSPY'); $devices[0] ? return 1 : return 0} + ####### # alexa specials @@ -98,12 +109,11 @@ name:speechcontrol_alexa_specials filter:NAME=speechrecognTesting order:1000020a desc:generic template to set speech speechcontrol attribute alexaName, call e.g. with set xy attrTemplate speechcontrol_alexa_specials ALEXANAME=myAlexaName -option:{my @devices=devspec2array("TYPE=(alexa)");; $devices[0] ? return 1 : return 0} -#par:ALEXANAME;Please enter alexaName. Pls. enter something, even if you do not want any name to be set, use the offered radio option to skip naming instead!;{ AttrVal("DEVICE","alexaName",undef) } -par:ALEXAISNAME;Current attribute value alexaName;{ AttrVal("DEVICE","alexaName","(not set)") } -par:RADIO_KEEPalexaNAME;Keep current attribute value;{ defined AttrVal("DEVICE","alexaName",undef) ? undef :0 } +option:{my @devices=devspec2array('TYPE=(alexa)'); $devices[0] ? return 1 : return 0} +par:ALEXAISNAME;Current attribute value alexaName;{ AttrVal('DEVICE','alexaName','(not set)') } +par:RADIO_KEEPalexaNAME;Keep current attribute value;{ defined AttrVal('DEVICE','alexaName',undef) ? undef :0 } par:RADIO_SETalexaNAME;Set a new alexaName;{ undef } -par:RADIO_DoNotSetalexaName;Leave alexaName attribute empty;{ defined AttrVal("DEVICE","alexaName",undef) ? 0 : undef } +par:RADIO_DoNotSetalexaName;Leave alexaName attribute empty;{ defined AttrVal('DEVICE','alexaName',undef) ? 0 : undef } par:RADIO_Delete_gDT;Discard genericDeviceType attribute;{ undef } par:RADIO_SKIPP_SCONTROLL;Skipp setting speech controll specific attributes;{ undef } option:{ RADIO_KEEPalexaNAME } @@ -124,9 +134,9 @@ filter:NAME=speechrecognTesting order:1000020b desc:generic template to ask for alexaName attribute setting. Only intented for internal use by speechcontrol_request_alexaName par:ALEXANAME;Please enter alexaName;{ undef } -option:{my @devices=devspec2array("TYPE=(alexa)");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=alexa'); $devices[0] ? return 1 : return 0} attr DEVICE alexaName ALEXANAME -option:{my @devices=devspec2array("TYPE=siri");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=siri'); $devices[0] ? return 1 : return 0} set DEVICE attrTemplate speechcontrol_siri_specials CHECKGDTDONE=1 #### @@ -136,7 +146,7 @@ name:speechcontrol_siri_specials filter:NAME=speechrecognTesting order:1000021a desc:generic template to set speech speechcontrol attribute alexaName, call e.g. with set xy attrTemplate speechcontrol_siri_specials ALEXANAME=myAlexaName -option:{my @devices=devspec2array("TYPE=(siri)");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=siri'); $devices[0] ? return 1 : return 0} par:CHECKGDTDONE;Set this to 1 if answer was no in previous template;{ 0 } par:SKIPSCONTROLL;Set this to 1 if answer was no in previous template;{ 0 } par:RADIO_KEEPsiriNAME;Keep current attribute value;{ defined AttrVal("DEVICE","siriName",undef) ? undef : SKIPSCONTROLL ? undef : 0 } @@ -157,8 +167,8 @@ order:1000021b desc:generic template to ask for siriName attribute setting. Only intented for internal use by speechcontrol_request_siriName #par:SIRIISNAME;Current attribute value alexaName;{ AttrVal("DEVICE","siriName","(not set)") } par:SIRINAME;Please enter siriName;{ undef } -option:{my @devices=devspec2array("TYPE=(siri)");; $devices[0] ? return 1 : return 0} +option:{my @devices=devspec2array('TYPE=siri'); $devices[0] ? return 1 : return 0} attr DEVICE siriName SIRINAME -#option:{my @devices=devspec2array("TYPE=RHASSPY");; $devices[0] ? return 1 : return 0} +#option:{my @devices=devspec2array('TYPE=RHASSPY'); $devices[0] ? return 1 : return 0} #set DEVICE attrTemplate speechcontrol_rhasspy_specials CHECKGDTDONE=1