@avantics/node-red-home-automation 6.0.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.
- package/README.md +276 -48
- package/dist/lib/cover-publishing.js +20 -6
- package/dist/lib/home-assistant-setting.d.ts +23 -0
- package/dist/lib/home-assistant-setting.js +39 -0
- package/dist/lib/motion-policy.d.ts +1 -0
- package/dist/lib/motion-policy.js +21 -1
- package/dist/lib/room-controller.d.ts +4 -0
- package/dist/lib/room-controller.js +122 -14
- package/dist/lib/room-holds.d.ts +34 -0
- package/dist/lib/room-holds.js +66 -0
- package/dist/lib/room-publishing.d.ts +1 -0
- package/dist/lib/room-publishing.js +11 -0
- package/dist/lib/scene-publishing.d.ts +30 -0
- package/dist/lib/scene-publishing.js +63 -0
- package/dist/lib/scene.d.ts +61 -0
- package/dist/lib/scene.js +170 -0
- package/dist/lib/shelly-cover.js +5 -0
- package/dist/lib/shelly-relay-light.d.ts +24 -0
- package/dist/lib/shelly-relay-light.js +93 -0
- package/dist/lib/shelly-switch.d.ts +8 -0
- package/dist/lib/shelly-switch.js +37 -8
- package/dist/lib/theatre-activity-controller.js +4 -0
- package/dist/lib/theatre-metrics.js +6 -4
- package/dist/lib/theatre-slo.js +3 -0
- package/dist/lib/theatre-state-contract.d.ts +4 -2
- package/dist/lib/theatre-state-contract.js +51 -8
- package/dist/lib/theatre-state.js +3 -0
- package/dist/nodes/activity-lighting-controller.html +1 -1
- package/dist/nodes/adapter.d.ts +5 -1
- package/dist/nodes/adapter.js +35 -2
- package/dist/nodes/avr-controller.html +86 -20
- package/dist/nodes/avr-controller.js +23 -11
- package/dist/nodes/circadian-policy.html +88 -19
- package/dist/nodes/circadian-policy.js +30 -11
- package/dist/nodes/cover-controller.html +91 -24
- package/dist/nodes/cover-controller.js +25 -12
- package/dist/nodes/device-side.d.ts +20 -0
- package/dist/nodes/device-side.js +72 -0
- package/dist/nodes/home-assistant-discovery.d.ts +26 -0
- package/dist/nodes/home-assistant-discovery.js +64 -0
- package/dist/nodes/house-schedule-mqtt.html +74 -4
- package/dist/nodes/house-schedule-mqtt.js +22 -8
- package/dist/nodes/motion-policy.html +91 -21
- package/dist/nodes/motion-policy.js +44 -11
- package/dist/nodes/mqtt-broker-link.d.ts +41 -0
- package/dist/nodes/mqtt-broker-link.js +91 -0
- package/dist/nodes/occupancy-fusion.html +87 -19
- package/dist/nodes/occupancy-fusion.js +23 -11
- package/dist/nodes/publishing-side.d.ts +20 -0
- package/dist/nodes/publishing-side.js +66 -0
- package/dist/nodes/room-controller.html +128 -43
- package/dist/nodes/room-controller.js +63 -16
- package/dist/nodes/scene.d.ts +3 -0
- package/dist/nodes/scene.html +226 -0
- package/dist/nodes/scene.js +121 -0
- package/dist/nodes/shelly-cover.html +46 -2
- package/dist/nodes/shelly-cover.js +19 -4
- package/dist/nodes/shelly-switch.html +80 -6
- package/dist/nodes/shelly-switch.js +32 -7
- package/dist/nodes/theatre-state-contract.html +76 -8
- package/dist/nodes/theatre-state-contract.js +33 -14
- package/dist/nodes/z2m-cover.html +46 -2
- package/dist/nodes/z2m-cover.js +21 -4
- package/dist/nodes/z2m-light.html +50 -2
- package/dist/nodes/z2m-light.js +26 -6
- package/examples/Cover control.json +38 -102
- package/examples/Cover pair.json +36 -3
- package/examples/Home theatre activity.json +46 -102
- package/examples/Home theatre equipment.json +34 -2
- package/examples/House schedule.json +58 -80
- package/examples/Room lighting.json +45 -55
- package/examples/Scene.json +215 -0
- package/examples/Shelly cover.json +36 -116
- package/examples/Shelly switch.json +52 -148
- package/package.json +2 -1
|
@@ -3,7 +3,21 @@
|
|
|
3
3
|
category: "home automation",
|
|
4
4
|
color: "#e2d96e",
|
|
5
5
|
defaults: {
|
|
6
|
-
|
|
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><base>/<friendly name></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><base>/<friendly name>/#</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
|
|
@@ -61,6 +105,10 @@
|
|
|
61
105
|
from what it sent and its members' reports, so a group's report follows a command at once. A group has no
|
|
62
106
|
availability and can't be asked to report, so at the room's startup the node sends nothing: the room waits for
|
|
63
107
|
Zigbee2MQTT's next state for the group. (Passing on an old state could settle a command still on its way.)</p>
|
|
108
|
+
<p>Switch on the group's <b>retain</b> in Zigbee2MQTT: <code>retain: true</code> under the group in Zigbee2MQTT's
|
|
109
|
+
<code>configuration.yaml</code> (it is off by default). Zigbee2MQTT doesn't retain a group's state by default, so after a restart the
|
|
110
|
+
room has no reading for the group until it changes, and an activity that holds it waits on it. With retain, the broker
|
|
111
|
+
gives this node the group's last state as soon as its MQTT in node subscribes.</p>
|
|
64
112
|
<h3>Settings</h3>
|
|
65
113
|
<dl class="message-properties">
|
|
66
114
|
<dt>Target</dt><dd>The light's id in the room controller's Targets JSON.</dd>
|
package/dist/nodes/z2m-light.js
CHANGED
|
@@ -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,18 +18,29 @@ 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
|
-
|
|
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
|
-
// Another light's command: nothing to keep or trace
|
|
22
|
-
|
|
34
|
+
// Another light's command: nothing to keep or trace, and the result
|
|
35
|
+
// still says it was ignored.
|
|
36
|
+
return decided.ignored ? { ...decided, state: saved ?? decided.state, traces: [] } : decided;
|
|
23
37
|
});
|
|
24
38
|
if (result.ignored)
|
|
25
39
|
return;
|
|
26
|
-
// MQTT publications for the device
|
|
27
|
-
// 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.
|
|
28
42
|
const outputs = [
|
|
29
|
-
|
|
43
|
+
side.publish(result.publications),
|
|
30
44
|
result.readings.length ? result.readings.map((reading) => ({ payload: undefined, light: reading })) : null
|
|
31
45
|
];
|
|
32
46
|
if (outputs.some((output) => output !== null))
|
|
@@ -42,6 +56,12 @@ const registerZ2mLight = (RED) => {
|
|
|
42
56
|
].filter(Boolean).join(" ");
|
|
43
57
|
node.status({ fill: state.report.on ? "green" : "grey", shape: "dot", text: (state.report.on ? "on" : "off") + (state.report.on && values ? " · " + values : "") });
|
|
44
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);
|
|
45
65
|
});
|
|
46
66
|
}
|
|
47
67
|
RED.nodes.registerType("home-z2m-light", HomeZ2mLight);
|
|
@@ -3,35 +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,
|
|
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-startup",
|
|
13
|
-
"type": "inject",
|
|
14
|
-
"name": "startup",
|
|
15
|
-
"props": [
|
|
16
|
-
{
|
|
17
|
-
"p": "cover",
|
|
18
|
-
"v": "{\"kind\":\"startup\"}",
|
|
19
|
-
"vt": "json"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"repeat": "",
|
|
23
|
-
"crontab": "",
|
|
24
|
-
"once": true,
|
|
25
|
-
"onceDelay": 3,
|
|
26
|
-
"topic": "",
|
|
27
|
-
"x": 130,
|
|
28
|
-
"y": 100,
|
|
29
|
-
"wires": [
|
|
30
|
-
[
|
|
31
|
-
"example-cover-control-cover"
|
|
32
|
-
]
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
11
|
{
|
|
36
12
|
"id": "example-cover-control-open",
|
|
37
13
|
"type": "inject",
|
|
@@ -133,34 +109,6 @@
|
|
|
133
109
|
]
|
|
134
110
|
]
|
|
135
111
|
},
|
|
136
|
-
{
|
|
137
|
-
"id": "example-cover-control-report",
|
|
138
|
-
"type": "inject",
|
|
139
|
-
"name": "state report from the cover (MQTT in)",
|
|
140
|
-
"props": [
|
|
141
|
-
{
|
|
142
|
-
"p": "payload",
|
|
143
|
-
"v": "{\"position\":60,\"motor_state\":\"stopped\",\"battery\":87,\"charging_status\":\"false\"}",
|
|
144
|
-
"vt": "json"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"p": "topic",
|
|
148
|
-
"vt": "str"
|
|
149
|
-
}
|
|
150
|
-
],
|
|
151
|
-
"repeat": "",
|
|
152
|
-
"crontab": "",
|
|
153
|
-
"once": false,
|
|
154
|
-
"onceDelay": 0.1,
|
|
155
|
-
"topic": "zigbee2mqtt/<your cover>",
|
|
156
|
-
"x": 180,
|
|
157
|
-
"y": 320,
|
|
158
|
-
"wires": [
|
|
159
|
-
[
|
|
160
|
-
"example-cover-control-adapter"
|
|
161
|
-
]
|
|
162
|
-
]
|
|
163
|
-
},
|
|
164
112
|
{
|
|
165
113
|
"id": "example-cover-control-adapter",
|
|
166
114
|
"type": "home-z2m-cover",
|
|
@@ -170,13 +118,13 @@
|
|
|
170
118
|
"x": 420,
|
|
171
119
|
"y": 320,
|
|
172
120
|
"wires": [
|
|
173
|
-
[
|
|
174
|
-
"example-cover-control-device-commands"
|
|
175
|
-
],
|
|
121
|
+
[],
|
|
176
122
|
[
|
|
177
123
|
"example-cover-control-cover"
|
|
178
124
|
]
|
|
179
|
-
]
|
|
125
|
+
],
|
|
126
|
+
"broker": "example-mqtt-broker",
|
|
127
|
+
"publishesThroughOutput": false
|
|
180
128
|
},
|
|
181
129
|
{
|
|
182
130
|
"id": "example-cover-control-cover",
|
|
@@ -203,23 +151,8 @@
|
|
|
203
151
|
"example-cover-control-moving",
|
|
204
152
|
"example-cover-control-pause-motion"
|
|
205
153
|
]
|
|
206
|
-
]
|
|
207
|
-
|
|
208
|
-
{
|
|
209
|
-
"id": "example-cover-control-device-commands",
|
|
210
|
-
"type": "debug",
|
|
211
|
-
"name": "to the MQTT out node",
|
|
212
|
-
"active": true,
|
|
213
|
-
"tosidebar": true,
|
|
214
|
-
"console": false,
|
|
215
|
-
"tostatus": false,
|
|
216
|
-
"complete": "true",
|
|
217
|
-
"targetType": "full",
|
|
218
|
-
"statusVal": "",
|
|
219
|
-
"statusType": "auto",
|
|
220
|
-
"x": 1110,
|
|
221
|
-
"y": 140,
|
|
222
|
-
"wires": []
|
|
154
|
+
],
|
|
155
|
+
"broker": "example-mqtt-broker"
|
|
223
156
|
},
|
|
224
157
|
{
|
|
225
158
|
"id": "example-cover-control-state",
|
|
@@ -266,34 +199,6 @@
|
|
|
266
199
|
]
|
|
267
200
|
]
|
|
268
201
|
},
|
|
269
|
-
{
|
|
270
|
-
"id": "example-cover-control-availability-report",
|
|
271
|
-
"type": "inject",
|
|
272
|
-
"name": "availability from the cover (MQTT in)",
|
|
273
|
-
"props": [
|
|
274
|
-
{
|
|
275
|
-
"p": "payload",
|
|
276
|
-
"v": "{\"state\":\"online\"}",
|
|
277
|
-
"vt": "json"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
"p": "topic",
|
|
281
|
-
"vt": "str"
|
|
282
|
-
}
|
|
283
|
-
],
|
|
284
|
-
"repeat": "",
|
|
285
|
-
"crontab": "",
|
|
286
|
-
"once": false,
|
|
287
|
-
"onceDelay": 0.1,
|
|
288
|
-
"topic": "zigbee2mqtt/<your cover>/availability",
|
|
289
|
-
"x": 200,
|
|
290
|
-
"y": 360,
|
|
291
|
-
"wires": [
|
|
292
|
-
[
|
|
293
|
-
"example-cover-control-adapter"
|
|
294
|
-
]
|
|
295
|
-
]
|
|
296
|
-
},
|
|
297
202
|
{
|
|
298
203
|
"id": "example-cover-control-moving",
|
|
299
204
|
"type": "debug",
|
|
@@ -344,5 +249,36 @@
|
|
|
344
249
|
"x": 1150,
|
|
345
250
|
"y": 300,
|
|
346
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": ""
|
|
347
283
|
}
|
|
348
284
|
]
|
package/examples/Cover pair.json
CHANGED
|
@@ -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": "
|
|
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,64 +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\".
|
|
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-startup",
|
|
42
|
-
"type": "inject",
|
|
43
|
-
"name": "contract startup",
|
|
44
|
-
"props": [
|
|
45
|
-
{
|
|
46
|
-
"p": "theatreStateContract",
|
|
47
|
-
"v": "{\"kind\":\"startup\"}",
|
|
48
|
-
"vt": "json"
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
"repeat": "",
|
|
52
|
-
"crontab": "",
|
|
53
|
-
"once": true,
|
|
54
|
-
"onceDelay": 3,
|
|
55
|
-
"topic": "",
|
|
56
|
-
"x": 170,
|
|
57
|
-
"y": 140,
|
|
58
|
-
"wires": [
|
|
59
|
-
[
|
|
60
|
-
"example-home-theatre-activity-theatre-state-contract"
|
|
61
|
-
]
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
11
|
{
|
|
65
12
|
"id": "example-home-theatre-activity-theatre-state-contract",
|
|
66
13
|
"type": "home-theatre-state-contract",
|
|
@@ -80,28 +27,11 @@
|
|
|
80
27
|
[
|
|
81
28
|
"example-home-theatre-activity-theatre-activity-controller"
|
|
82
29
|
],
|
|
83
|
-
[
|
|
84
|
-
"example-home-theatre-activity-retained-state"
|
|
85
|
-
]
|
|
30
|
+
[]
|
|
86
31
|
],
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
"id": "example-home-theatre-activity-retained-state",
|
|
92
|
-
"type": "debug",
|
|
93
|
-
"name": "retained state",
|
|
94
|
-
"active": true,
|
|
95
|
-
"tosidebar": true,
|
|
96
|
-
"console": false,
|
|
97
|
-
"tostatus": false,
|
|
98
|
-
"complete": "true",
|
|
99
|
-
"targetType": "full",
|
|
100
|
-
"statusVal": "",
|
|
101
|
-
"statusType": "auto",
|
|
102
|
-
"x": 680,
|
|
103
|
-
"y": 60,
|
|
104
|
-
"wires": []
|
|
32
|
+
"idScheme": "node",
|
|
33
|
+
"broker": "example-mqtt-broker",
|
|
34
|
+
"homeAssistant": "state"
|
|
105
35
|
},
|
|
106
36
|
{
|
|
107
37
|
"id": "example-home-theatre-activity-theatre-activity-controller",
|
|
@@ -140,22 +70,6 @@
|
|
|
140
70
|
]
|
|
141
71
|
]
|
|
142
72
|
},
|
|
143
|
-
{
|
|
144
|
-
"id": "example-home-theatre-activity-room-lighting-intents",
|
|
145
|
-
"type": "debug",
|
|
146
|
-
"name": "room and light MQTT (MQTT out)",
|
|
147
|
-
"active": true,
|
|
148
|
-
"tosidebar": true,
|
|
149
|
-
"console": false,
|
|
150
|
-
"tostatus": false,
|
|
151
|
-
"complete": "true",
|
|
152
|
-
"targetType": "full",
|
|
153
|
-
"statusVal": "",
|
|
154
|
-
"statusType": "auto",
|
|
155
|
-
"x": 1880,
|
|
156
|
-
"y": 440,
|
|
157
|
-
"wires": []
|
|
158
|
-
},
|
|
159
73
|
{
|
|
160
74
|
"id": "example-home-theatre-activity-route-by-target",
|
|
161
75
|
"type": "switch",
|
|
@@ -323,7 +237,8 @@
|
|
|
323
237
|
[
|
|
324
238
|
"example-home-theatre-activity-theatre-activity-controller"
|
|
325
239
|
]
|
|
326
|
-
]
|
|
240
|
+
],
|
|
241
|
+
"broker": "example-mqtt-broker"
|
|
327
242
|
},
|
|
328
243
|
{
|
|
329
244
|
"id": "example-home-theatre-activity-avr-commands",
|
|
@@ -480,8 +395,6 @@
|
|
|
480
395
|
"type": "home-room-lighting-controller",
|
|
481
396
|
"name": "",
|
|
482
397
|
"area": "",
|
|
483
|
-
"publishState": false,
|
|
484
|
-
"discovery": false,
|
|
485
398
|
"idScheme": "node",
|
|
486
399
|
"displayName": "",
|
|
487
400
|
"discoveryPrefix": "homeassistant",
|
|
@@ -490,16 +403,16 @@
|
|
|
490
403
|
"x": 1630,
|
|
491
404
|
"y": 440,
|
|
492
405
|
"wires": [
|
|
493
|
-
[
|
|
494
|
-
"example-home-theatre-activity-room-lighting-intents"
|
|
495
|
-
],
|
|
406
|
+
[],
|
|
496
407
|
[
|
|
497
408
|
"example-home-theatre-activity-room-light-main"
|
|
498
409
|
],
|
|
499
410
|
[
|
|
500
411
|
"example-home-theatre-activity-activity-lighting-controller"
|
|
501
412
|
]
|
|
502
|
-
]
|
|
413
|
+
],
|
|
414
|
+
"broker": "example-mqtt-broker",
|
|
415
|
+
"homeAssistant": "off"
|
|
503
416
|
},
|
|
504
417
|
{
|
|
505
418
|
"id": "example-home-theatre-activity-room-light-main",
|
|
@@ -512,12 +425,43 @@
|
|
|
512
425
|
"x": 1630,
|
|
513
426
|
"y": 520,
|
|
514
427
|
"wires": [
|
|
515
|
-
[
|
|
516
|
-
"example-home-theatre-activity-room-lighting-intents"
|
|
517
|
-
],
|
|
428
|
+
[],
|
|
518
429
|
[
|
|
519
430
|
"example-home-theatre-activity-room"
|
|
520
431
|
]
|
|
521
|
-
]
|
|
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": ""
|
|
522
466
|
}
|
|
523
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": "
|
|
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
|
]
|