-
Notifications
You must be signed in to change notification settings - Fork 1
/
speechcontrol.template
185 lines (167 loc) · 11 KB
/
speechcontrol.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
###########################################
# $Id: speechcontrol.template 26764 2022-12-02 17:52:52Z 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
#
# 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:speechcontrol_type_switch
filter:NAME=speechrecognTesting
order:100001
desc:template to set speech speechcontrol attributes for genericDeviceType switch
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
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
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_light_254
filter:NAME=speechrecognTesting
order:100003a
desc:template to set speech speechcontrol attributes for genericDeviceType light - brightness in 254 steps
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,max=100,factor=0.39371,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
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
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 <xy> attrTemplate speechcontrol_gdt_only GENERICDEVTYPE=Security
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 <genericDeviceType>, 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"
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 <genericDeviceType>, 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}
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 }
#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}
#######
# alexa specials
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: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_Delete_gDT;Discard genericDeviceType attribute;{ undef }
par:RADIO_SKIPP_SCONTROLL;Skipp setting speech controll specific attributes;{ undef }
option:{ RADIO_KEEPalexaNAME }
set DEVICE attrTemplate speechcontrol_siri_specials CHECKGDTDONE=1
option:{ RADIO_Delete_gDT }
deleteAttr DEVICE genericDeviceType
option:{ RADIO_DoNotSetalexaName }
deleteAttr DEVICE alexaName #optional falls Name zuvor vorhanden
set DEVICE attrTemplate speechcontrol_siri_specials CHECKGDTDONE=1
option:{ RADIO_SETalexaNAME }
set DEVICE attrTemplate speechcontrol_request_alexaName
option:{ RADIO_SKIPP_SCONTROLL }
set DEVICE attrTemplate speechcontrol_siri_specials CHECKGDTDONE=1 SKIPSCONTROLL=1
name:speechcontrol_request_alexaName
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}
attr DEVICE alexaName ALEXANAME
option:{my @devices=devspec2array('TYPE=siri'); $devices[0] ? return 1 : return 0}
set DEVICE attrTemplate speechcontrol_siri_specials CHECKGDTDONE=1
####
#siri specials
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}
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 }
par:RADIO_SETsiriNAME;Set a new siriName;{ SKIPSCONTROLL ? undef : 0 }
par:RADIO_DoNotSetsiriName;Leave siriName attribute empty;{ SKIPSCONTROLL ? undef : 0 }
par:RADIO_Delete_gDT;Discard genericDeviceType attribute;{ CHECKGDTDONE ? undef : 0 }
option:{ RADIO_KEEPsiriNAME }
option:{ RADIO_Delete_gDT }
deleteAttr DEVICE genericDeviceType
option:{ RADIO_DoNotSetsiriName }
deleteAttr DEVICE siriName
option:{ RADIO_SETsiriNAME }
set DEVICE attrTemplate speechcontrol_request_siriName
name:speechcontrol_request_siriName
filter:NAME=speechrecognTesting
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}
attr DEVICE siriName SIRINAME
#option:{my @devices=devspec2array('TYPE=RHASSPY'); $devices[0] ? return 1 : return 0}
#set DEVICE attrTemplate speechcontrol_rhasspy_specials CHECKGDTDONE=1