@avantics/node-red-home-automation 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +204 -42
  2. package/dist/lib/cover-publishing.js +20 -6
  3. package/dist/lib/home-assistant-setting.d.ts +23 -0
  4. package/dist/lib/home-assistant-setting.js +39 -0
  5. package/dist/lib/motion-policy.d.ts +1 -0
  6. package/dist/lib/motion-policy.js +21 -1
  7. package/dist/lib/room-controller.d.ts +1 -0
  8. package/dist/lib/room-controller.js +5 -0
  9. package/dist/lib/room-publishing.d.ts +1 -0
  10. package/dist/lib/room-publishing.js +11 -0
  11. package/dist/lib/scene-publishing.d.ts +30 -0
  12. package/dist/lib/scene-publishing.js +63 -0
  13. package/dist/lib/scene.d.ts +61 -0
  14. package/dist/lib/scene.js +170 -0
  15. package/dist/lib/shelly-cover.js +5 -0
  16. package/dist/lib/shelly-relay-light.d.ts +24 -0
  17. package/dist/lib/shelly-relay-light.js +93 -0
  18. package/dist/lib/shelly-switch.d.ts +8 -0
  19. package/dist/lib/shelly-switch.js +37 -8
  20. package/dist/lib/theatre-activity-controller.js +4 -0
  21. package/dist/lib/theatre-metrics.js +6 -4
  22. package/dist/lib/theatre-slo.js +3 -0
  23. package/dist/lib/theatre-state-contract.d.ts +4 -2
  24. package/dist/lib/theatre-state-contract.js +51 -8
  25. package/dist/lib/theatre-state.js +3 -0
  26. package/dist/nodes/avr-controller.html +82 -21
  27. package/dist/nodes/avr-controller.js +23 -11
  28. package/dist/nodes/circadian-policy.html +84 -20
  29. package/dist/nodes/circadian-policy.js +30 -11
  30. package/dist/nodes/cover-controller.html +87 -25
  31. package/dist/nodes/cover-controller.js +25 -12
  32. package/dist/nodes/device-side.d.ts +20 -0
  33. package/dist/nodes/device-side.js +72 -0
  34. package/dist/nodes/home-assistant-discovery.d.ts +26 -0
  35. package/dist/nodes/home-assistant-discovery.js +64 -0
  36. package/dist/nodes/house-schedule-mqtt.html +70 -5
  37. package/dist/nodes/house-schedule-mqtt.js +22 -8
  38. package/dist/nodes/motion-policy.html +87 -22
  39. package/dist/nodes/motion-policy.js +44 -11
  40. package/dist/nodes/mqtt-broker-link.d.ts +41 -0
  41. package/dist/nodes/mqtt-broker-link.js +91 -0
  42. package/dist/nodes/occupancy-fusion.html +83 -20
  43. package/dist/nodes/occupancy-fusion.js +23 -11
  44. package/dist/nodes/publishing-side.d.ts +20 -0
  45. package/dist/nodes/publishing-side.js +66 -0
  46. package/dist/nodes/room-controller.html +106 -35
  47. package/dist/nodes/room-controller.js +63 -16
  48. package/dist/nodes/scene.d.ts +3 -0
  49. package/dist/nodes/scene.html +226 -0
  50. package/dist/nodes/scene.js +121 -0
  51. package/dist/nodes/shelly-cover.html +46 -2
  52. package/dist/nodes/shelly-cover.js +19 -4
  53. package/dist/nodes/shelly-switch.html +75 -6
  54. package/dist/nodes/shelly-switch.js +32 -7
  55. package/dist/nodes/theatre-state-contract.html +72 -9
  56. package/dist/nodes/theatre-state-contract.js +33 -14
  57. package/dist/nodes/z2m-cover.html +46 -2
  58. package/dist/nodes/z2m-cover.js +21 -4
  59. package/dist/nodes/z2m-light.html +46 -2
  60. package/dist/nodes/z2m-light.js +23 -4
  61. package/examples/Cover control.json +38 -91
  62. package/examples/Cover pair.json +36 -3
  63. package/examples/Home theatre activity.json +46 -91
  64. package/examples/Home theatre equipment.json +34 -2
  65. package/examples/House schedule.json +58 -80
  66. package/examples/Room lighting.json +45 -44
  67. package/examples/Scene.json +215 -0
  68. package/examples/Shelly cover.json +36 -105
  69. package/examples/Shelly switch.json +52 -148
  70. package/package.json +2 -1
@@ -3,7 +3,21 @@
3
3
  category: "home automation",
4
4
  color: "#e2d96e",
5
5
  defaults: {
6
- name: {value: ""},
6
+ // A marker only a node new from the palette has, as core nodes do: import
7
+ // and paste keep the saved name, so onadd leaves a saved node's settings.
8
+ name: {value: "_DEFAULT_"},
9
+ // Node-RED's MQTT broker node, through which it subscribes to its device's
10
+ // topics and publishes on them itself. The editor offers the first broker
11
+ // when the dialog is opened and saved, not when the node is dropped.
12
+ broker: {value: "", type: "mqtt-broker", required: false, validate: function (v) {
13
+ return (Boolean(v) && v !== "_ADD_") || this.publishesThroughOutput !== false ? true : "choose a broker";
14
+ }},
15
+ // Whether it reaches its device through MQTT in and out nodes, as before
16
+ // 6.2, and so needs no broker until one is chosen. A node saved before
17
+ // this setting loads without it (the editor applies no defaults to the
18
+ // deployed flows), which counts as true; a new node sets false (onadd).
19
+ // No row.
20
+ publishesThroughOutput: {value: false},
7
21
  // The room's id for this light: no default, it names the user's own.
8
22
  target: {value: "", required: true, validate: function (v) { return String(v || "").trim() !== ""; }},
9
23
  baseTopic: {value: "zigbee2mqtt", required: true, validate: function (v) {
@@ -17,9 +31,31 @@
17
31
  }},
18
32
  group: {value: false}
19
33
  },
34
+ onadd: function () {
35
+ if (this.name !== "_DEFAULT_") return;
36
+ this.name = "";
37
+ this.publishesThroughOutput = false;
38
+ },
39
+ oneditprepare: function () {
40
+ var node = this;
41
+ // While it reaches its device through MQTT in and out nodes, that it does
42
+ // until given a broker.
43
+ function rows() {
44
+ var broker = $("#node-input-broker").val();
45
+ $(".device-through-output").toggle(node.publishesThroughOutput !== false && (!broker || broker === "_ADD_"));
46
+ }
47
+ $("#node-input-broker").on("change", rows);
48
+ rows();
49
+ },
50
+ oneditsave: function () {
51
+ // A broker chosen: it publishes itself from now on.
52
+ var broker = $("#node-input-broker").val();
53
+ if (broker && broker !== "_ADD_") this.publishesThroughOutput = false;
54
+ else if (this.publishesThroughOutput !== false) this.publishesThroughOutput = true;
55
+ },
20
56
  inputs: 1,
21
57
  outputs: 2,
22
- outputLabels: ["to the light (MQTT out)", "to the room lighting controller"],
58
+ outputLabels: ["to the light (MQTT out, without a broker)", "to the room lighting controller"],
23
59
  icon: "font-awesome/fa-lightbulb-o",
24
60
  label: function () { return this.name || this.friendlyName || "zigbee2mqtt light"; },
25
61
  paletteLabel: "zigbee2mqtt light"
@@ -28,6 +64,11 @@
28
64
 
29
65
  <script type="text/html" data-template-name="home-z2m-light">
30
66
  <div class="form-row"><label for="node-input-name">Name</label><input type="text" id="node-input-name"></div>
67
+ <div class="form-row"><label for="node-input-broker">Broker</label><input type="text" id="node-input-broker"></div>
68
+ <div class="form-tips">With a broker, it subscribes to its device's topics and publishes on them itself: the MQTT in and
69
+ MQTT out nodes around it are no longer needed and can be deleted.</div>
70
+ <div class="form-tips device-through-output">This node reaches its device through MQTT in and out nodes, as before 6.2,
71
+ and keeps working that way. Choose a Broker to let it do so itself.</div>
31
72
  <div class="form-row"><label for="node-input-target">Target</label><input type="text" id="node-input-target" placeholder="the room's id for this light"></div>
32
73
  <div class="form-row"><label for="node-input-baseTopic">Base topic</label><input type="text" id="node-input-baseTopic"></div>
33
74
  <div class="form-row"><label for="node-input-friendlyName">Friendly name</label><input type="text" id="node-input-friendlyName" placeholder="the light's or group's name in Zigbee2MQTT"></div>
@@ -38,6 +79,9 @@
38
79
  <p>Connects one Zigbee2MQTT light, or a Zigbee2MQTT group of lights, to a <b>room lighting controller</b>, over
39
80
  Zigbee2MQTT's MQTT messages: no function nodes, and never Home Assistant. Use one per light in the room's targets.</p>
40
81
  <h3>Wiring</h3>
82
+ <p>With a <b>Broker</b>, it subscribes to <code>&lt;base&gt;/&lt;friendly name&gt;</code>, its <code>/set</code> and its <code>/availability</code> (exactly these: a friendly name can contain <code>/</code>) and publishes on its device's topics itself: leave out the MQTT
83
+ in and MQTT out nodes below (still wired, they change nothing). Its first output then sends nothing. It reads its light on each connect (not a group, which Zigbee2MQTT can't be asked), as a Status node's startup did through the room. A node saved
84
+ before 6.2 keeps using them until you choose a broker.</p>
41
85
  <ol>
42
86
  <li>An <b>MQTT in</b> node subscribed to <code>&lt;base&gt;/&lt;friendly name&gt;/#</code> (output: auto-detect)
43
87
  → this node. That covers the light's state, its <code>/set</code> topic (to see other people's commands) and its
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  const z2m_light_adapter_1 = require("../lib/z2m-light-adapter");
3
3
  const adapter_1 = require("./adapter");
4
+ const device_side_1 = require("./device-side");
4
5
  const registerZ2mLight = (RED) => {
5
6
  function HomeZ2mLight(config) {
6
7
  RED.nodes.createNode(this, config);
7
8
  const node = this;
8
9
  let light;
10
+ let broker;
9
11
  try {
10
12
  light = (0, z2m_light_adapter_1.normaliseZ2mLightConfig)(config);
13
+ broker = (0, device_side_1.deviceBroker)(RED, config.broker);
11
14
  }
12
15
  catch (error) {
13
16
  (0, adapter_1.invalidConfig)(node, error);
@@ -15,7 +18,17 @@ const registerZ2mLight = (RED) => {
15
18
  }
16
19
  const trace = { area: "", component: "z2m-light" };
17
20
  node.status({ fill: "grey", shape: "ring", text: light.group ? "group · waiting for its state" : "waiting for the device" });
18
- (0, adapter_1.onInput)(node, (msg, send) => {
21
+ // With a broker, it reads its device on each connect, reconnects
22
+ // included, through its own observe: after a restart nothing reported it
23
+ // while it was away, and the controller acts on the reading as on one it
24
+ // asked for.
25
+ // Exactly its own topics: a friendly name can contain "/", so <name>/#
26
+ // would take in other devices' too.
27
+ const topics = (0, z2m_light_adapter_1.z2mLightTopics)(light);
28
+ const side = (0, device_side_1.deviceSide)(node, broker, topics.device, [topics.device, topics.set, ...(light.group ? [] : [topics.availability])], trace, (msg, send) => handle(msg, send),
29
+ // A group can't be asked (traced, as for the room's observe).
30
+ () => handle({ light: { kind: "observe", target: light.target } }, node.send.bind(node)));
31
+ function handle(msg, send) {
19
32
  const result = (0, adapter_1.runReducer)(node, trace, (saved, now) => {
20
33
  const decided = (0, z2m_light_adapter_1.transitionZ2mLight)(saved, msg, light, now);
21
34
  // Another light's command: nothing to keep or trace, and the result
@@ -24,10 +37,10 @@ const registerZ2mLight = (RED) => {
24
37
  });
25
38
  if (result.ignored)
26
39
  return;
27
- // MQTT publications for the device on output 1, for an MQTT out node;
28
- // readings for the room controller on output 2.
40
+ // MQTT publications for the device: to the broker, or on output 1 for
41
+ // an MQTT out node; readings for the room controller on output 2.
29
42
  const outputs = [
30
- result.publications.length ? result.publications.map((publication) => ({ ...publication })) : null,
43
+ side.publish(result.publications),
31
44
  result.readings.length ? result.readings.map((reading) => ({ payload: undefined, light: reading })) : null
32
45
  ];
33
46
  if (outputs.some((output) => output !== null))
@@ -43,6 +56,12 @@ const registerZ2mLight = (RED) => {
43
56
  ].filter(Boolean).join(" ");
44
57
  node.status({ fill: state.report.on ? "green" : "grey", shape: "dot", text: (state.report.on ? "on" : "off") + (state.report.on && values ? " · " + values : "") });
45
58
  }
59
+ }
60
+ (0, adapter_1.onInput)(node, (msg, send) => {
61
+ // With a broker, its device's messages come from the broker: an MQTT
62
+ // in or a Status node still wired in changes nothing.
63
+ if (!side.fromBroker(msg))
64
+ handle(msg, send);
46
65
  });
47
66
  }
48
67
  RED.nodes.registerType("home-z2m-light", HomeZ2mLight);
@@ -3,24 +3,11 @@
3
3
  "id": "example-cover-control-cover-control-example",
4
4
  "type": "comment",
5
5
  "name": "Cover control example",
6
- "info": "A position cover (blind, shutter or curtain motor) owned by the cover controller. Requests go in as \"open\", \"close\", \"stop\", a position from 0 to 100, or a preset name; an automatic target sets respectManual so a person's move holds. The Zigbee2MQTT cover adapter maps to and from a Zigbee2MQTT cover: set its friendly name, feed it from MQTT in nodes on the cover's topic and its availability topic, and wire its first output to an MQTT out node. A button can stop the cover if it is moving and open it otherwise, and the cover's availability report keeps requests from going to an offline device. Output 3 says whether the cover is moving, for other policies to react to. Here it pauses motion lighting while the cover moves, through the motion policy's pause input, which never touches the user's own enable.\n\nThe \"MQTT out connected\" status node sends the cover controller its startup message each time an MQTT out node connects to the broker, so what it announces reaches it: the broker drops anything sent before it connects. It watches every node on this flow, and the nodes act only on an MQTT out node's connected status; you can scope it to your MQTT out node instead.",
6
+ "info": "Needs: A Zigbee2MQTT cover on your broker.\n\nA position cover (blind, shutter or curtain motor) owned by the cover controller. Requests go in as \"open\", \"close\", \"stop\", a position from 0 to 100, or a preset name; an automatic target sets respectManual so a person's move holds. The Zigbee2MQTT cover adapter maps to and from a Zigbee2MQTT cover: set its friendly name, and it reads the cover's state and availability from the broker and sends it the controller's commands. A button can stop the cover if it is moving and open it otherwise, and the cover's availability keeps requests from going to an offline device. Output 3 says whether the cover is moving, for other policies to react to. Here it pauses motion lighting while the cover moves, through the motion policy's pause input, which never touches the user's own enable.\n\nBefore deploying, open the \"your MQTT broker\" config node (any node's Broker setting) and set your broker's host: every node here that talks MQTT subscribes and publishes through it, with no MQTT in, MQTT out or status nodes. Give the cover controller an area and choose what it publishes to show the cover in Home Assistant.",
7
7
  "x": 170,
8
8
  "y": 40,
9
9
  "wires": []
10
10
  },
11
- {
12
- "id": "example-cover-control-mqtt-connected",
13
- "type": "status",
14
- "name": "MQTT out connected",
15
- "scope": null,
16
- "x": 130,
17
- "y": 100,
18
- "wires": [
19
- [
20
- "example-cover-control-cover"
21
- ]
22
- ]
23
- },
24
11
  {
25
12
  "id": "example-cover-control-open",
26
13
  "type": "inject",
@@ -122,34 +109,6 @@
122
109
  ]
123
110
  ]
124
111
  },
125
- {
126
- "id": "example-cover-control-report",
127
- "type": "inject",
128
- "name": "state report from the cover (MQTT in)",
129
- "props": [
130
- {
131
- "p": "payload",
132
- "v": "{\"position\":60,\"motor_state\":\"stopped\",\"battery\":87,\"charging_status\":\"false\"}",
133
- "vt": "json"
134
- },
135
- {
136
- "p": "topic",
137
- "vt": "str"
138
- }
139
- ],
140
- "repeat": "",
141
- "crontab": "",
142
- "once": false,
143
- "onceDelay": 0.1,
144
- "topic": "zigbee2mqtt/<your cover>",
145
- "x": 180,
146
- "y": 320,
147
- "wires": [
148
- [
149
- "example-cover-control-adapter"
150
- ]
151
- ]
152
- },
153
112
  {
154
113
  "id": "example-cover-control-adapter",
155
114
  "type": "home-z2m-cover",
@@ -159,13 +118,13 @@
159
118
  "x": 420,
160
119
  "y": 320,
161
120
  "wires": [
162
- [
163
- "example-cover-control-device-commands"
164
- ],
121
+ [],
165
122
  [
166
123
  "example-cover-control-cover"
167
124
  ]
168
- ]
125
+ ],
126
+ "broker": "example-mqtt-broker",
127
+ "publishesThroughOutput": false
169
128
  },
170
129
  {
171
130
  "id": "example-cover-control-cover",
@@ -192,23 +151,8 @@
192
151
  "example-cover-control-moving",
193
152
  "example-cover-control-pause-motion"
194
153
  ]
195
- ]
196
- },
197
- {
198
- "id": "example-cover-control-device-commands",
199
- "type": "debug",
200
- "name": "to the MQTT out node",
201
- "active": true,
202
- "tosidebar": true,
203
- "console": false,
204
- "tostatus": false,
205
- "complete": "true",
206
- "targetType": "full",
207
- "statusVal": "",
208
- "statusType": "auto",
209
- "x": 1110,
210
- "y": 140,
211
- "wires": []
154
+ ],
155
+ "broker": "example-mqtt-broker"
212
156
  },
213
157
  {
214
158
  "id": "example-cover-control-state",
@@ -255,34 +199,6 @@
255
199
  ]
256
200
  ]
257
201
  },
258
- {
259
- "id": "example-cover-control-availability-report",
260
- "type": "inject",
261
- "name": "availability from the cover (MQTT in)",
262
- "props": [
263
- {
264
- "p": "payload",
265
- "v": "{\"state\":\"online\"}",
266
- "vt": "json"
267
- },
268
- {
269
- "p": "topic",
270
- "vt": "str"
271
- }
272
- ],
273
- "repeat": "",
274
- "crontab": "",
275
- "once": false,
276
- "onceDelay": 0.1,
277
- "topic": "zigbee2mqtt/<your cover>/availability",
278
- "x": 200,
279
- "y": 360,
280
- "wires": [
281
- [
282
- "example-cover-control-adapter"
283
- ]
284
- ]
285
- },
286
202
  {
287
203
  "id": "example-cover-control-moving",
288
204
  "type": "debug",
@@ -333,5 +249,36 @@
333
249
  "x": 1150,
334
250
  "y": 300,
335
251
  "wires": []
252
+ },
253
+ {
254
+ "id": "example-mqtt-broker",
255
+ "type": "mqtt-broker",
256
+ "name": "your MQTT broker",
257
+ "broker": "your-mqtt-broker",
258
+ "port": 1883,
259
+ "clientid": "",
260
+ "autoConnect": true,
261
+ "usetls": false,
262
+ "protocolVersion": 4,
263
+ "keepalive": 60,
264
+ "cleansession": true,
265
+ "autoUnsubscribe": true,
266
+ "birthTopic": "",
267
+ "birthQos": "0",
268
+ "birthRetain": "false",
269
+ "birthPayload": "",
270
+ "birthMsg": {},
271
+ "closeTopic": "",
272
+ "closeQos": "0",
273
+ "closeRetain": "false",
274
+ "closePayload": "",
275
+ "closeMsg": {},
276
+ "willTopic": "",
277
+ "willQos": "0",
278
+ "willRetain": "false",
279
+ "willPayload": "",
280
+ "willMsg": {},
281
+ "userProps": "",
282
+ "sessionExpiry": ""
336
283
  }
337
284
  ]
@@ -3,7 +3,7 @@
3
3
  "id": "example-cover-pair-cover-pair-example",
4
4
  "type": "comment",
5
5
  "name": "Cover pair example",
6
- "info": "Two covers moved as one, such as the left and right of a curtain. The group sends each member the request, with its own request ID, on that member's own output (after the group's result on output 1); each member's second output comes back to the group, which reports ready only when both confirm, and otherwise which did what. Map each member's commands and reports to its device as in the Cover control example.",
6
+ "info": "Needs: No devices: injects stand in for the curtains' reports, and Debug nodes show the commands.\n\nTwo covers moved as one, such as the left and right of a curtain. The group sends each member the request, with its own request ID, on that member's own output (after the group's result on output 1); each member's second output comes back to the group, which reports ready only when both confirm, and otherwise which did what. Map each member's commands and reports to its device as in the Cover control example.",
7
7
  "x": 160,
8
8
  "y": 40,
9
9
  "wires": []
@@ -118,7 +118,8 @@
118
118
  "example-cover-pair-group"
119
119
  ],
120
120
  []
121
- ]
121
+ ],
122
+ "broker": "example-mqtt-broker"
122
123
  },
123
124
  {
124
125
  "id": "example-cover-pair-right",
@@ -145,7 +146,8 @@
145
146
  "example-cover-pair-group"
146
147
  ],
147
148
  []
148
- ]
149
+ ],
150
+ "broker": "example-mqtt-broker"
149
151
  },
150
152
  {
151
153
  "id": "example-cover-pair-left-commands",
@@ -226,5 +228,36 @@
226
228
  "example-cover-pair-right"
227
229
  ]
228
230
  ]
231
+ },
232
+ {
233
+ "id": "example-mqtt-broker",
234
+ "type": "mqtt-broker",
235
+ "name": "your MQTT broker",
236
+ "broker": "your-mqtt-broker",
237
+ "port": 1883,
238
+ "clientid": "",
239
+ "autoConnect": true,
240
+ "usetls": false,
241
+ "protocolVersion": 4,
242
+ "keepalive": 60,
243
+ "cleansession": true,
244
+ "autoUnsubscribe": true,
245
+ "birthTopic": "",
246
+ "birthQos": "0",
247
+ "birthRetain": "false",
248
+ "birthPayload": "",
249
+ "birthMsg": {},
250
+ "closeTopic": "",
251
+ "closeQos": "0",
252
+ "closeRetain": "false",
253
+ "closePayload": "",
254
+ "closeMsg": {},
255
+ "willTopic": "",
256
+ "willQos": "0",
257
+ "willRetain": "false",
258
+ "willPayload": "",
259
+ "willMsg": {},
260
+ "userProps": "",
261
+ "sessionExpiry": ""
229
262
  }
230
263
  ]
@@ -3,53 +3,11 @@
3
3
  "id": "example-home-theatre-activity-home-theatre-activity-example",
4
4
  "type": "comment",
5
5
  "name": "Home theatre activity example",
6
- "info": "The state contract turns a request on home/<area>/theatre/request into an activity intent. The activity controller plans each target and sends msg.theatreCommand; the switch routes each command by its target, and a change node moves it onto that controller's input. Every controller reports msg.theatre target state on output 2, wired straight back to the activity controller, which publishes a complete snapshot through the contract.\n\nName the area on the state contract before deploying: it names the MQTT topics and Home Assistant entities, and until it is set the contract shows \"invalid configuration\". Put the same area in the \"request tv activity\" inject's topic. Set the display controller's device hosts and TV pre-shared key too; until then it shows \"invalid configuration\" and the activity waits for it. Wire the controllers' output 1 to your device transports and activity lighting to your room lighting controller. Activity lighting holds the room's lights through a room lighting controller, which reaches its light through a zigbee2mqtt light node and passes each light's reading back to activity lighting (its third output), so the lights confirm. Set the light's friendly name, wire the debug's place to MQTT out, and an MQTT in node on the light's topics (zigbee2mqtt/<your light>/#) into the light node.\n\nThe \"MQTT out connected\" status node sends the state contract its startup message each time an MQTT out node connects to the broker, so what it announces reaches it: the broker drops anything sent before it connects. It watches every node on this flow, and the nodes act only on an MQTT out node's connected status; you can scope it to your MQTT out node instead.",
6
+ "info": "Needs: The display controller's devices, as in Home theatre equipment, and a Zigbee2MQTT light, both on your broker or network. Requests come from your broker.\n\nThe state contract turns a request on home/<area>/theatre/request, which it reads from the broker, into an activity intent: publish {\"requestId\":\"1\",\"activity\":\"tv\"} there to try it. The activity controller plans each target and sends msg.theatreCommand; the switch routes each command by its target, and a change node moves it onto that controller's input. Every controller reports msg.theatre target state on output 2, wired straight back to the activity controller, which publishes a complete snapshot through the contract.\n\nName the area on the state contract before deploying: it names the MQTT topics and Home Assistant entities, and until it is set the contract shows \"invalid configuration\". Set the display controller's device hosts and TV pre-shared key too; until then it shows \"invalid configuration\" and the activity waits for it. Wire the controllers' output 1 to your device transports. Activity lighting holds the room's lights through a room lighting controller, which reaches its light through a zigbee2mqtt light node and passes each light's reading back to activity lighting (its third output), so the lights confirm. Set the light's friendly name.\n\nBefore deploying, open the \"your MQTT broker\" config node (any node's Broker setting) and set your broker's host: every node here that talks MQTT subscribes and publishes through it, with no MQTT in, MQTT out or status nodes.",
7
7
  "x": 190,
8
8
  "y": 40,
9
9
  "wires": []
10
10
  },
11
- {
12
- "id": "example-home-theatre-activity-request-tv-activity",
13
- "type": "inject",
14
- "name": "request tv activity",
15
- "props": [
16
- {
17
- "p": "topic",
18
- "v": "home/<area>/theatre/request",
19
- "vt": "str"
20
- },
21
- {
22
- "p": "payload",
23
- "v": "{\"requestId\":\"example-request-1\",\"activity\":\"tv\"}",
24
- "vt": "json"
25
- }
26
- ],
27
- "repeat": "",
28
- "crontab": "",
29
- "once": false,
30
- "onceDelay": 0.1,
31
- "topic": "",
32
- "x": 170,
33
- "y": 100,
34
- "wires": [
35
- [
36
- "example-home-theatre-activity-theatre-state-contract"
37
- ]
38
- ]
39
- },
40
- {
41
- "id": "example-home-theatre-activity-contract-mqtt-connected",
42
- "type": "status",
43
- "name": "MQTT out connected",
44
- "scope": null,
45
- "x": 170,
46
- "y": 140,
47
- "wires": [
48
- [
49
- "example-home-theatre-activity-theatre-state-contract"
50
- ]
51
- ]
52
- },
53
11
  {
54
12
  "id": "example-home-theatre-activity-theatre-state-contract",
55
13
  "type": "home-theatre-state-contract",
@@ -69,28 +27,11 @@
69
27
  [
70
28
  "example-home-theatre-activity-theatre-activity-controller"
71
29
  ],
72
- [
73
- "example-home-theatre-activity-retained-state"
74
- ]
30
+ []
75
31
  ],
76
- "discovery": false,
77
- "idScheme": "node"
78
- },
79
- {
80
- "id": "example-home-theatre-activity-retained-state",
81
- "type": "debug",
82
- "name": "retained state",
83
- "active": true,
84
- "tosidebar": true,
85
- "console": false,
86
- "tostatus": false,
87
- "complete": "true",
88
- "targetType": "full",
89
- "statusVal": "",
90
- "statusType": "auto",
91
- "x": 680,
92
- "y": 60,
93
- "wires": []
32
+ "idScheme": "node",
33
+ "broker": "example-mqtt-broker",
34
+ "homeAssistant": "state"
94
35
  },
95
36
  {
96
37
  "id": "example-home-theatre-activity-theatre-activity-controller",
@@ -129,22 +70,6 @@
129
70
  ]
130
71
  ]
131
72
  },
132
- {
133
- "id": "example-home-theatre-activity-room-lighting-intents",
134
- "type": "debug",
135
- "name": "room and light MQTT (MQTT out)",
136
- "active": true,
137
- "tosidebar": true,
138
- "console": false,
139
- "tostatus": false,
140
- "complete": "true",
141
- "targetType": "full",
142
- "statusVal": "",
143
- "statusType": "auto",
144
- "x": 1880,
145
- "y": 440,
146
- "wires": []
147
- },
148
73
  {
149
74
  "id": "example-home-theatre-activity-route-by-target",
150
75
  "type": "switch",
@@ -312,7 +237,8 @@
312
237
  [
313
238
  "example-home-theatre-activity-theatre-activity-controller"
314
239
  ]
315
- ]
240
+ ],
241
+ "broker": "example-mqtt-broker"
316
242
  },
317
243
  {
318
244
  "id": "example-home-theatre-activity-avr-commands",
@@ -469,8 +395,6 @@
469
395
  "type": "home-room-lighting-controller",
470
396
  "name": "",
471
397
  "area": "",
472
- "publishState": false,
473
- "discovery": false,
474
398
  "idScheme": "node",
475
399
  "displayName": "",
476
400
  "discoveryPrefix": "homeassistant",
@@ -479,16 +403,16 @@
479
403
  "x": 1630,
480
404
  "y": 440,
481
405
  "wires": [
482
- [
483
- "example-home-theatre-activity-room-lighting-intents"
484
- ],
406
+ [],
485
407
  [
486
408
  "example-home-theatre-activity-room-light-main"
487
409
  ],
488
410
  [
489
411
  "example-home-theatre-activity-activity-lighting-controller"
490
412
  ]
491
- ]
413
+ ],
414
+ "broker": "example-mqtt-broker",
415
+ "homeAssistant": "off"
492
416
  },
493
417
  {
494
418
  "id": "example-home-theatre-activity-room-light-main",
@@ -501,12 +425,43 @@
501
425
  "x": 1630,
502
426
  "y": 520,
503
427
  "wires": [
504
- [
505
- "example-home-theatre-activity-room-lighting-intents"
506
- ],
428
+ [],
507
429
  [
508
430
  "example-home-theatre-activity-room"
509
431
  ]
510
- ]
432
+ ],
433
+ "broker": "example-mqtt-broker",
434
+ "publishesThroughOutput": false
435
+ },
436
+ {
437
+ "id": "example-mqtt-broker",
438
+ "type": "mqtt-broker",
439
+ "name": "your MQTT broker",
440
+ "broker": "your-mqtt-broker",
441
+ "port": 1883,
442
+ "clientid": "",
443
+ "autoConnect": true,
444
+ "usetls": false,
445
+ "protocolVersion": 4,
446
+ "keepalive": 60,
447
+ "cleansession": true,
448
+ "autoUnsubscribe": true,
449
+ "birthTopic": "",
450
+ "birthQos": "0",
451
+ "birthRetain": "false",
452
+ "birthPayload": "",
453
+ "birthMsg": {},
454
+ "closeTopic": "",
455
+ "closeQos": "0",
456
+ "closeRetain": "false",
457
+ "closePayload": "",
458
+ "closeMsg": {},
459
+ "willTopic": "",
460
+ "willQos": "0",
461
+ "willRetain": "false",
462
+ "willPayload": "",
463
+ "willMsg": {},
464
+ "userProps": "",
465
+ "sessionExpiry": ""
511
466
  }
512
467
  ]
@@ -3,7 +3,7 @@
3
3
  "id": "example-home-theatre-equipment-home-theatre-equipment-example",
4
4
  "type": "comment",
5
5
  "name": "Home theatre equipment example",
6
- "info": "Each equipment controller accepts a generation-scoped intent and reports target state. Output 1 carries commands for your device transport; output 2 carries theatre target state.\n\nThe display controller talks to the TV, screen and projector relay directly: set their hosts and the TV pre-shared key before deploying. Until then it shows \"invalid configuration\".",
6
+ "info": "Needs: For the display controller, your TV, screen and projector power meter on the network (its device hosts). The other controllers' commands go to Debug nodes.\n\nEach equipment controller accepts a generation-scoped intent and reports target state. Output 1 carries commands for your device transport; output 2 carries theatre target state.\n\nThe display controller talks to the TV, screen and projector relay directly: set their hosts and the TV pre-shared key before deploying. Until then it shows \"invalid configuration\".",
7
7
  "x": 190,
8
8
  "y": 40,
9
9
  "wires": []
@@ -51,7 +51,8 @@
51
51
  [
52
52
  "example-home-theatre-equipment-receiver-state"
53
53
  ]
54
- ]
54
+ ],
55
+ "broker": "example-mqtt-broker"
55
56
  },
56
57
  {
57
58
  "id": "example-home-theatre-equipment-receiver-commands",
@@ -325,5 +326,36 @@
325
326
  "x": 660,
326
327
  "y": 420,
327
328
  "wires": []
329
+ },
330
+ {
331
+ "id": "example-mqtt-broker",
332
+ "type": "mqtt-broker",
333
+ "name": "your MQTT broker",
334
+ "broker": "your-mqtt-broker",
335
+ "port": 1883,
336
+ "clientid": "",
337
+ "autoConnect": true,
338
+ "usetls": false,
339
+ "protocolVersion": 4,
340
+ "keepalive": 60,
341
+ "cleansession": true,
342
+ "autoUnsubscribe": true,
343
+ "birthTopic": "",
344
+ "birthQos": "0",
345
+ "birthRetain": "false",
346
+ "birthPayload": "",
347
+ "birthMsg": {},
348
+ "closeTopic": "",
349
+ "closeQos": "0",
350
+ "closeRetain": "false",
351
+ "closePayload": "",
352
+ "closeMsg": {},
353
+ "willTopic": "",
354
+ "willQos": "0",
355
+ "willRetain": "false",
356
+ "willPayload": "",
357
+ "willMsg": {},
358
+ "userProps": "",
359
+ "sessionExpiry": ""
328
360
  }
329
361
  ]