前言

环境

实操

  1. 小爱必然是过云的,所以不用纠结本不本地的问题,先用 Xiaomi Miot Auto 通过「账号集成」的方式把小爱音箱接入
  2. events: state 节点获取我们给音箱发的语音指令,实体得选择 sensor.xiaomi_..._conversation,记得取消勾选 当前状态等于先前状态
  3. 后面跟个 switch 节点,判断关键词
  4. 最后用 call service 节点执行相应的操作

示例

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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
[
{
"id": "ab383f6267c791e8",
"type": "group",
"z": "e1cf8dd280bc6b96",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"6ee090206f8fcf12",
"8112234f9ca242ba",
"bd1916acacd2b239",
"384b06c0bf925073",
"59be4271bdd01b85"
],
"x": 14,
"y": 19,
"w": 492,
"h": 182
},
{
"id": "6ee090206f8fcf12",
"type": "server-state-changed",
"z": "e1cf8dd280bc6b96",
"g": "ab383f6267c791e8",
"name": "小爱音箱",
"server": "e5039dd6495bc2e1",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": [
"sensor.xiaomi_lx06_1a35_conversation",
"sensor.xiaomi_lx06_4142_conversation",
"sensor.xiaomi_lx06_ca6e_conversation"
],
"entityIdType": "list",
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": false,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 100,
"y": 120,
"wires": [
[
"bd1916acacd2b239"
]
]
},
{
"id": "8112234f9ca242ba",
"type": "api-call-service",
"z": "e1cf8dd280bc6b96",
"g": "ab383f6267c791e8",
"name": "上班",
"server": "e5039dd6495bc2e1",
"version": 5,
"debugenabled": false,
"domain": "script",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"script.work_on"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 430,
"y": 100,
"wires": [
[]
]
},
{
"id": "bd1916acacd2b239",
"type": "switch",
"z": "e1cf8dd280bc6b96",
"g": "ab383f6267c791e8",
"name": "判断关键词",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "上班",
"vt": "str"
},
{
"t": "eq",
"v": "下班",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 270,
"y": 120,
"wires": [
[
"8112234f9ca242ba"
],
[
"384b06c0bf925073"
]
]
},
{
"id": "384b06c0bf925073",
"type": "api-call-service",
"z": "e1cf8dd280bc6b96",
"g": "ab383f6267c791e8",
"name": "上班",
"server": "e5039dd6495bc2e1",
"version": 5,
"debugenabled": false,
"domain": "script",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"script.work_off"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 430,
"y": 160,
"wires": [
[]
]
},
{
"id": "59be4271bdd01b85",
"type": "comment",
"z": "e1cf8dd280bc6b96",
"g": "ab383f6267c791e8",
"name": "上下班",
"info": "",
"x": 90,
"y": 60,
"wires": []
},
{
"id": "e5039dd6495bc2e1",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]

另外

顺便再给个利用小爱查询节假日并根据结果执行相应操作的流

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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
[
{
"id": "208694991fb4a817",
"type": "group",
"z": "21fcc3325e38513a",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"1bf3224c1f5f138d",
"d5c16660e2198a90",
"6eb6d82691b6c966",
"1a6ce88905a34dc5",
"e4a4cdc12cb0e43d",
"1428e53e3614cdb7",
"6961c50ced91ec5b",
"701646e7a60c01fa",
"1309da9a20055aa2"
],
"x": 14,
"y": 19,
"w": 1052,
"h": 142
},
{
"id": "1bf3224c1f5f138d",
"type": "comment",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "工作日空调提前制冷",
"info": "",
"x": 130,
"y": 60,
"wires": []
},
{
"id": "d5c16660e2198a90",
"type": "inject",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "每天 11:00",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "00 11 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 120,
"wires": [
[
"6eb6d82691b6c966",
"1a6ce88905a34dc5"
]
]
},
{
"id": "6eb6d82691b6c966",
"type": "delay",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "minutes",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 300,
"y": 120,
"wires": [
[
"e4a4cdc12cb0e43d"
]
]
},
{
"id": "1a6ce88905a34dc5",
"type": "api-call-service",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "问办公小爱",
"server": "e5039dd6495bc2e1",
"version": 5,
"debugenabled": false,
"domain": "xiaomi_miot",
"service": "intelligent_speaker",
"areaId": [],
"deviceId": [],
"entityId": [
"text.xiaomi_lx06_4142_execute_text_directive"
],
"data": "{\"text\":\"今天是工作日吗\",\"execute\":true}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 330,
"y": 60,
"wires": [
[]
]
},
{
"id": "e4a4cdc12cb0e43d",
"type": "api-current-state",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "办公小爱",
"server": "e5039dd6495bc2e1",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sensor.xiaomi_lx06_4142_conversation",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 460,
"y": 120,
"wires": [
[
"701646e7a60c01fa",
"1428e53e3614cdb7"
]
]
},
{
"id": "1428e53e3614cdb7",
"type": "switch",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "问工作日",
"property": "data.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "今天是工作日吗",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 640,
"y": 120,
"wires": [
[
"6961c50ced91ec5b"
]
]
},
{
"id": "6961c50ced91ec5b",
"type": "switch",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "判断是不是",
"property": "data.attributes.answers[0].tts.text",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "不是",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 810,
"y": 120,
"wires": [
[],
[
"1309da9a20055aa2"
]
]
},
{
"id": "701646e7a60c01fa",
"type": "debug",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "data.attributes.answers[0].tts.text",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 60,
"wires": []
},
{
"id": "1309da9a20055aa2",
"type": "api-call-service",
"z": "21fcc3325e38513a",
"g": "208694991fb4a817",
"name": "执行脚本",
"server": "e5039dd6495bc2e1",
"version": 5,
"debugenabled": false,
"domain": "script",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"script.climate_summer"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 980,
"y": 120,
"wires": [
[]
]
},
{
"id": "e5039dd6495bc2e1",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]