########################################### # $Id$ # # 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 # # Big thanks to user TomLee for extensive testing on the first sets of templates! # # 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) name:speech_recognition_type_switch filter:NAME=speechrecognTesting order:100001 desc:template to set speech recognition attributes for genericDeviceType switch option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType switch set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_type_light filter:NAME=speechrecognTesting order:100002 desc:template to set speech recognition attributes for genericDeviceType light option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType light set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_type_light_255 filter:NAME=speechrecognTesting order:100003 desc:template to set speech recognition attributes for genericDeviceType light - brightness in 255 steps option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} set DEVICE attrTemplate speech_recognition_type_light attr DEVICE genericDeviceType light attr DEVICE homebridgeMapping Brightness=brightness::brightness,maxValue=100,factor=0.39216,delay=true set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_type_blind filter:NAME=speechrecognTesting order:100004 desc:template to set speech recognition attributes for genericDeviceType blind option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType blind set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_type_thermostat filter:NAME=speechrecognTesting order:100005 desc:template to set speech recognition attributes for genericDeviceType thermostat option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType thermostat set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_gdt_only filter:filter:genericDeviceType=.+ order:100006 desc:template to set speech recognition attributes for to any genericDeviceType; call e.g. with set attrTemplate speech_recognition_gdt_only GENERICDEVTYPE=Security option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} par:GENERICDEVTYPE;GENERICDEVTYPE , defaults to contact;{ "contact" } attr DEVICE genericDeviceType GENERICDEVTYPE set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_gdt_and_mapping filter:filter:genericDeviceType=.+ order:100007 desc:generic template to set speech recognition attributes for to any genericDeviceType including full mapping, call e.g. with set xy attrTemplate speech_recognition_gdt_and_mapping GENERICDEVTYPE=contact HOMEBRIDGEMAPPING= "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED" option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;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 set DEVICE attrTemplate speech_recognition_general_naming_master_template name:speech_recognition_general_naming_master_template filter:genericDeviceType=.+ order:10000200 desc:generic template to set attributes for identifying this device by speech recognition software. This template will call several sub-templates - dependent on the speech recognition solutions which are in use in your installation. Pls. do not use one of the subtemplates directly. Call e.g. with set xy attrTemplate speech_recognition_general_naming_master_template option:{my @devices=devspec2array("TYPE=siri");; $devices[0] ? return 1 : return 0} option:{my @devices=devspec2array("TYPE=alexa");; $devices[0] ? return 1 : return 0} #set DEVICE attrTemplate speech_recognition_alaxaName_firstrun option:{my @devices=devspec2array("TYPE=gassistant");; $devices[0] ? return 1 : return 0} name:speech_recognition_alaxaName_firstrun filter:NAME=speechrecognTesting order:1000020a desc:generic template to set speech recognition attribute alexaName, call e.g. with set xy attrTemplate speech_recognition_alaxaName_firstrun ALEXANAME=myAlexaName option:{my @devices=devspec2array("TYPE=(alexa)");; $devices[0] ? return 1 : return 0} par:ALEXANAME;Please enter alexaName;{ AttrVal("DEVICE","alexaName",undef) } attr DEVICE alexaName ALEXANAME set DEVICE attrTemplate speech_recognition_alaxaName_secondrun ALEXAISNAME=ALEXANAME name:speech_recognition_alaxaName_secondrun filter:NAME=speechrecognTesting order:1000020b desc:generic template to doublecheck alexaName attribute setting to avoid doubletes. Only intented for internal use by speech_recognition_alaxaName_firstrun and -ask_different_name, called e.g. with set xy attrTemplate speech_recognition_alaxaName_secondrun ALEXAISNAME=myAlexaName option:{my @devices=devspec2array("TYPE=(alexa)");; $devices[0] ? return 1 : return 0} par:ALEXAISNAME;Please enter alexaName;{ AttrVal("DEVICE","alexaName",undef) } option:{my @devices=devspec2array("alexaName=ALEXAISNAME");; $devices[1] ? return 1 : return 0} deleteattr DEVICE alexaName set DEVICE attrTemplate speech_recognition_alaxaName_ask_different_name name:speech_recognition_alaxaName_ask_different_name filter:NAME=speechrecognTesting order:1000020c desc:generic template to set speech recognition attribute alexaName; only intented for internal use by speech_recognition_alaxaName_secondrun, called e.g. with set xy attrTemplate speech_recognition_alaxaName_ask_different_name ALEXANAME=myAlexaName option:{my @devices=devspec2array("TYPE=(alexa)");; $devices[0] ? return 1 : return 0} par:ALEXANAME;Please enter alexaName (the one provided last time seem to exist already);{ undef } attr DEVICE alexaName ALEXANAME set DEVICE attrTemplate speech_recognition_alaxaName_secondrun ALEXAISNAME=ALEXANAME