@avantics/node-red-home-automation 4.0.3 → 6.0.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 +447 -64
- package/contract-examples/room-lighting.mjs +39 -27
- package/contract-examples/switch-gestures.mjs +1 -1
- package/contract-examples/volume-ownership.mjs +6 -5
- package/dist/lib/activity-lighting-controller.d.ts +9 -2
- package/dist/lib/activity-lighting-controller.js +107 -19
- package/dist/lib/adopted-request.d.ts +17 -0
- package/dist/lib/adopted-request.js +61 -7
- package/dist/lib/avr-controller.d.ts +9 -3
- package/dist/lib/avr-controller.js +71 -24
- package/dist/lib/avr-publishing.d.ts +3 -3
- package/dist/lib/avr-publishing.js +11 -5
- package/dist/lib/backlighting-controller.d.ts +2 -0
- package/dist/lib/backlighting-controller.js +27 -7
- package/dist/lib/circadian-policy.d.ts +47 -0
- package/dist/lib/circadian-policy.js +111 -0
- package/dist/lib/circadian-publishing.d.ts +33 -0
- package/dist/lib/circadian-publishing.js +154 -0
- package/dist/lib/circadian-schedule.d.ts +4 -0
- package/dist/lib/circadian-schedule.js +12 -0
- package/dist/lib/command-echo.d.ts +8 -1
- package/dist/lib/command-echo.js +37 -6
- package/dist/lib/cover-controller.js +4 -0
- package/dist/lib/cover-publishing.js +1 -1
- package/dist/lib/denon-protocol.d.ts +5 -1
- package/dist/lib/denon-protocol.js +27 -11
- package/dist/lib/display-mode-controller.d.ts +12 -5
- package/dist/lib/display-mode-controller.js +181 -87
- package/dist/lib/enable-input.d.ts +3 -0
- package/dist/lib/enable-input.js +18 -0
- package/dist/lib/house-schedule-publishing.js +1 -1
- package/dist/lib/house-schedule.js +2 -2
- package/dist/lib/light-contract.d.ts +53 -0
- package/dist/lib/light-contract.js +11 -0
- package/dist/lib/light-styling.d.ts +2 -2
- package/dist/lib/light-styling.js +5 -4
- package/dist/lib/motion-policy.d.ts +0 -1
- package/dist/lib/motion-policy.js +9 -8
- package/dist/lib/motion-publishing.js +3 -2
- package/dist/lib/mqtt-message.d.ts +6 -0
- package/dist/lib/mqtt-message.js +21 -0
- package/dist/lib/occupancy-publishing.js +1 -1
- package/dist/lib/power-reading.d.ts +5 -0
- package/dist/lib/power-reading.js +13 -0
- package/dist/lib/room-controller.d.ts +39 -29
- package/dist/lib/room-controller.js +314 -192
- package/dist/lib/room-lighting-discovery.d.ts +0 -14
- package/dist/lib/room-lighting-discovery.js +20 -126
- package/dist/lib/room-publishing.d.ts +10 -12
- package/dist/lib/room-publishing.js +65 -125
- package/dist/lib/shelly-cover.d.ts +44 -0
- package/dist/lib/shelly-cover.js +153 -0
- package/dist/lib/shelly-gen2.d.ts +25 -0
- package/dist/lib/shelly-gen2.js +58 -0
- package/dist/lib/shelly-switch.d.ts +95 -0
- package/dist/lib/shelly-switch.js +237 -0
- package/dist/lib/source-capability-controller.d.ts +2 -0
- package/dist/lib/source-capability-controller.js +27 -6
- package/dist/lib/switch-policy.d.ts +1 -1
- package/dist/lib/switch-policy.js +1 -1
- package/dist/lib/theatre-requests.d.ts +29 -0
- package/dist/lib/theatre-requests.js +89 -0
- package/dist/lib/theatre-state-contract.d.ts +5 -22
- package/dist/lib/theatre-state-contract.js +30 -77
- package/dist/lib/toggle-power.d.ts +41 -0
- package/dist/lib/toggle-power.js +74 -0
- package/dist/lib/topic-names.d.ts +1 -0
- package/dist/lib/topic-names.js +7 -0
- package/dist/lib/{display-transport.d.ts → transports/display-transport.d.ts} +1 -1
- package/dist/lib/{display-transport.js → transports/display-transport.js} +32 -7
- package/dist/lib/z2m-cover.d.ts +49 -0
- package/dist/lib/z2m-cover.js +120 -0
- package/dist/lib/z2m-light-adapter.d.ts +62 -0
- package/dist/lib/z2m-light-adapter.js +195 -0
- package/dist/lib/z2m-light.d.ts +8 -0
- package/dist/lib/z2m-light.js +61 -3
- package/dist/nodes/activity-lighting-controller.html +20 -3
- package/dist/nodes/activity-lighting-controller.js +21 -0
- package/dist/nodes/avr-controller.html +25 -6
- package/dist/nodes/avr-controller.js +16 -6
- package/dist/nodes/circadian-policy.d.ts +3 -0
- package/dist/nodes/circadian-policy.html +140 -0
- package/dist/nodes/circadian-policy.js +162 -0
- package/dist/nodes/cover-controller.html +4 -3
- package/dist/nodes/display-mode-controller.html +58 -11
- package/dist/nodes/display-mode-controller.js +19 -6
- package/dist/nodes/house-schedule.html +3 -3
- package/dist/nodes/motion-policy.html +5 -2
- package/dist/nodes/motion-policy.js +3 -0
- package/dist/nodes/refused-enable.d.ts +7 -0
- package/dist/nodes/refused-enable.js +24 -0
- package/dist/nodes/room-controller.html +215 -82
- package/dist/nodes/room-controller.js +71 -83
- package/dist/nodes/shelly-cover.d.ts +3 -0
- package/dist/nodes/shelly-cover.html +65 -0
- package/dist/nodes/shelly-cover.js +34 -0
- package/dist/nodes/shelly-switch.d.ts +3 -0
- package/dist/nodes/shelly-switch.html +82 -0
- package/dist/nodes/shelly-switch.js +48 -0
- package/dist/nodes/theatre-state-contract.html +4 -3
- package/dist/nodes/z2m-cover.d.ts +3 -0
- package/dist/nodes/z2m-cover.html +68 -0
- package/dist/nodes/z2m-cover.js +41 -0
- package/dist/nodes/z2m-light.d.ts +3 -0
- package/dist/nodes/z2m-light.html +72 -0
- package/dist/nodes/z2m-light.js +50 -0
- package/examples/Cover control.json +24 -56
- package/examples/Home theatre activity.json +54 -9
- package/examples/Home theatre equipment.json +4 -4
- package/examples/House schedule.json +106 -24
- package/examples/Room lighting.json +54 -11
- package/examples/Shelly cover.json +252 -0
- package/examples/Shelly switch.json +197 -0
- package/package.json +13 -4
- package/dist/lib/room-schedule.d.ts +0 -8
- package/dist/lib/room-schedule.js +0 -41
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "example-room-lighting-room-lighting-example",
|
|
4
4
|
"type": "comment",
|
|
5
5
|
"name": "Room lighting example",
|
|
6
|
-
"info": "Motion and illuminance feed occupancy fusion and the motion policy; a wall switch feeds the switch policy. Both send lighting intents to the room controller, which owns the light's commands.\n\nReplace the inject nodes with your sensors
|
|
6
|
+
"info": "Motion and illuminance feed occupancy fusion and the motion policy; a wall switch feeds the switch policy. Both send lighting intents to the room controller, which owns the light's commands. The circadian lighting policy sends the room how its lights should look over the day; the room uses it for lights nobody has set otherwise.\n\nReplace the inject nodes with your sensors. The room reaches its light through the zigbee2mqtt light node: set its friendly name, wire the room's first output and the light node's first output to MQTT out, and an MQTT in node on the light's topics (zigbee2mqtt/<your light>/#) into the light node. Set the circadian policy's wake and bed times (Node-RED host time) before deploying. Give the room controller an area to publish each light's control state and its Home Assistant discovery, and the circadian policy one to publish its circadian and sleep switches; without one they still control and style the lights.",
|
|
7
7
|
"x": 170,
|
|
8
8
|
"y": 40,
|
|
9
9
|
"wires": []
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
{
|
|
99
99
|
"id": "example-room-lighting-room-startup",
|
|
100
100
|
"type": "inject",
|
|
101
|
-
"name": "
|
|
101
|
+
"name": "startup",
|
|
102
102
|
"props": [
|
|
103
103
|
{
|
|
104
104
|
"p": "lighting",
|
|
@@ -115,7 +115,8 @@
|
|
|
115
115
|
"y": 280,
|
|
116
116
|
"wires": [
|
|
117
117
|
[
|
|
118
|
-
"example-room-lighting-room-lighting-controller"
|
|
118
|
+
"example-room-lighting-room-lighting-controller",
|
|
119
|
+
"example-room-lighting-circadian"
|
|
119
120
|
]
|
|
120
121
|
]
|
|
121
122
|
},
|
|
@@ -167,33 +168,75 @@
|
|
|
167
168
|
]
|
|
168
169
|
},
|
|
169
170
|
{
|
|
170
|
-
"id": "example-room-lighting-
|
|
171
|
-
"type": "home-
|
|
171
|
+
"id": "example-room-lighting-circadian",
|
|
172
|
+
"type": "home-circadian-lighting-policy",
|
|
172
173
|
"name": "",
|
|
173
174
|
"area": "",
|
|
174
|
-
"
|
|
175
|
-
"
|
|
175
|
+
"houseSchedule": "",
|
|
176
|
+
"wakeTime": "07:00",
|
|
177
|
+
"bedTime": "23:00",
|
|
176
178
|
"maxBrightnessPct": 100,
|
|
177
179
|
"maxColorTempKelvin": 6500,
|
|
178
180
|
"sleepBrightnessPct": 1,
|
|
179
181
|
"sleepColorTempKelvin": 2200,
|
|
180
|
-
"initialTransitionSeconds": 1,
|
|
181
182
|
"refreshTransitionSeconds": 60,
|
|
182
183
|
"refreshSeconds": 60,
|
|
183
184
|
"initialSleep": false,
|
|
185
|
+
"publishState": false,
|
|
186
|
+
"discovery": false,
|
|
187
|
+
"discoveryPrefix": "homeassistant",
|
|
188
|
+
"idScheme": "node",
|
|
189
|
+
"x": 620,
|
|
190
|
+
"y": 280,
|
|
191
|
+
"wires": [
|
|
192
|
+
[
|
|
193
|
+
"example-room-lighting-room-lighting-controller"
|
|
194
|
+
],
|
|
195
|
+
[]
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"id": "example-room-lighting-room-lighting-controller",
|
|
200
|
+
"type": "home-room-lighting-controller",
|
|
201
|
+
"name": "",
|
|
202
|
+
"area": "",
|
|
203
|
+
"displayName": "",
|
|
204
|
+
"targets": "[{\"id\":\"main\"}]",
|
|
205
|
+
"initialTransitionSeconds": 1,
|
|
184
206
|
"x": 880,
|
|
185
207
|
"y": 180,
|
|
186
208
|
"wires": [
|
|
187
209
|
[
|
|
188
210
|
"example-room-lighting-room-commands"
|
|
189
|
-
]
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
"example-room-lighting-room-lighting-controller-light-main"
|
|
214
|
+
],
|
|
215
|
+
[]
|
|
190
216
|
],
|
|
191
|
-
"wakeTime": "07:00",
|
|
192
|
-
"bedTime": "23:00",
|
|
193
217
|
"publishState": false,
|
|
194
218
|
"discovery": false,
|
|
195
219
|
"idScheme": "node"
|
|
196
220
|
},
|
|
221
|
+
{
|
|
222
|
+
"id": "example-room-lighting-room-lighting-controller-light-main",
|
|
223
|
+
"type": "home-z2m-light",
|
|
224
|
+
"name": "",
|
|
225
|
+
"target": "main",
|
|
226
|
+
"baseTopic": "zigbee2mqtt",
|
|
227
|
+
"friendlyName": "<your light>",
|
|
228
|
+
"group": false,
|
|
229
|
+
"x": 880,
|
|
230
|
+
"y": 240,
|
|
231
|
+
"wires": [
|
|
232
|
+
[
|
|
233
|
+
"example-room-lighting-room-commands"
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
"example-room-lighting-room-lighting-controller"
|
|
237
|
+
]
|
|
238
|
+
]
|
|
239
|
+
},
|
|
197
240
|
{
|
|
198
241
|
"id": "example-room-lighting-room-commands",
|
|
199
242
|
"type": "debug",
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "example-shelly-cover-comment",
|
|
4
|
+
"type": "comment",
|
|
5
|
+
"name": "Shelly cover example",
|
|
6
|
+
"info": "A Shelly Gen2 device in cover mode, owned by the cover controller, with no function nodes. In your flow, replace the injects marked 'from the device' with an MQTT in node subscribed to <prefix>/# (output: auto-detect), and the debug node with an MQTT out node, both on your broker. Set the adapter's MQTT topic prefix to your device's (its device ID unless you set one). The controller's device commands go to the adapter, which sends them to the device as its MQTT control commands; the device's status, change notifications and online state come back through the adapter as the controller's readings.",
|
|
7
|
+
"x": 150,
|
|
8
|
+
"y": 40,
|
|
9
|
+
"wires": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "example-shelly-cover-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-shelly-cover-cover"
|
|
32
|
+
]
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "example-shelly-cover-open",
|
|
37
|
+
"type": "inject",
|
|
38
|
+
"name": "open",
|
|
39
|
+
"props": [
|
|
40
|
+
{
|
|
41
|
+
"p": "payload",
|
|
42
|
+
"v": "open",
|
|
43
|
+
"vt": "str"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"repeat": "",
|
|
47
|
+
"crontab": "",
|
|
48
|
+
"once": false,
|
|
49
|
+
"onceDelay": 0.1,
|
|
50
|
+
"topic": "",
|
|
51
|
+
"x": 120,
|
|
52
|
+
"y": 140,
|
|
53
|
+
"wires": [
|
|
54
|
+
[
|
|
55
|
+
"example-shelly-cover-cover"
|
|
56
|
+
]
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "example-shelly-cover-close",
|
|
61
|
+
"type": "inject",
|
|
62
|
+
"name": "close",
|
|
63
|
+
"props": [
|
|
64
|
+
{
|
|
65
|
+
"p": "payload",
|
|
66
|
+
"v": "close",
|
|
67
|
+
"vt": "str"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"repeat": "",
|
|
71
|
+
"crontab": "",
|
|
72
|
+
"once": false,
|
|
73
|
+
"onceDelay": 0.1,
|
|
74
|
+
"topic": "",
|
|
75
|
+
"x": 120,
|
|
76
|
+
"y": 180,
|
|
77
|
+
"wires": [
|
|
78
|
+
[
|
|
79
|
+
"example-shelly-cover-cover"
|
|
80
|
+
]
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "example-shelly-cover-position",
|
|
85
|
+
"type": "inject",
|
|
86
|
+
"name": "set position 60",
|
|
87
|
+
"props": [
|
|
88
|
+
{
|
|
89
|
+
"p": "payload",
|
|
90
|
+
"v": "60",
|
|
91
|
+
"vt": "num"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"repeat": "",
|
|
95
|
+
"crontab": "",
|
|
96
|
+
"once": false,
|
|
97
|
+
"onceDelay": 0.1,
|
|
98
|
+
"topic": "",
|
|
99
|
+
"x": 140,
|
|
100
|
+
"y": 220,
|
|
101
|
+
"wires": [
|
|
102
|
+
[
|
|
103
|
+
"example-shelly-cover-cover"
|
|
104
|
+
]
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "example-shelly-cover-cover",
|
|
109
|
+
"type": "home-cover-controller",
|
|
110
|
+
"name": "",
|
|
111
|
+
"area": "",
|
|
112
|
+
"presets": "{}",
|
|
113
|
+
"positionTolerance": 2,
|
|
114
|
+
"invert": false,
|
|
115
|
+
"travelTimeoutMs": 90000,
|
|
116
|
+
"maxAttempts": 2,
|
|
117
|
+
"pollMs": 5000,
|
|
118
|
+
"settleMs": 5000,
|
|
119
|
+
"x": 380,
|
|
120
|
+
"y": 160,
|
|
121
|
+
"wires": [
|
|
122
|
+
[
|
|
123
|
+
"example-shelly-cover-adapter"
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
"example-shelly-cover-state"
|
|
127
|
+
],
|
|
128
|
+
[]
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "example-shelly-cover-adapter",
|
|
133
|
+
"type": "home-shelly-cover",
|
|
134
|
+
"name": "",
|
|
135
|
+
"topicPrefix": "shellyplus2pm-a8032ab12345",
|
|
136
|
+
"channel": 0,
|
|
137
|
+
"x": 640,
|
|
138
|
+
"y": 160,
|
|
139
|
+
"wires": [
|
|
140
|
+
[
|
|
141
|
+
"example-shelly-cover-to-device"
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
"example-shelly-cover-cover"
|
|
145
|
+
]
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"id": "example-shelly-cover-to-device",
|
|
150
|
+
"type": "debug",
|
|
151
|
+
"name": "to the MQTT out node",
|
|
152
|
+
"active": true,
|
|
153
|
+
"tosidebar": true,
|
|
154
|
+
"console": false,
|
|
155
|
+
"tostatus": false,
|
|
156
|
+
"complete": "true",
|
|
157
|
+
"targetType": "full",
|
|
158
|
+
"statusVal": "",
|
|
159
|
+
"statusType": "auto",
|
|
160
|
+
"x": 880,
|
|
161
|
+
"y": 140,
|
|
162
|
+
"wires": []
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"id": "example-shelly-cover-state",
|
|
166
|
+
"type": "debug",
|
|
167
|
+
"name": "state and results",
|
|
168
|
+
"active": true,
|
|
169
|
+
"tosidebar": true,
|
|
170
|
+
"console": false,
|
|
171
|
+
"tostatus": false,
|
|
172
|
+
"complete": "true",
|
|
173
|
+
"targetType": "full",
|
|
174
|
+
"statusVal": "",
|
|
175
|
+
"statusType": "auto",
|
|
176
|
+
"x": 640,
|
|
177
|
+
"y": 240,
|
|
178
|
+
"wires": []
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"id": "example-shelly-cover-online",
|
|
182
|
+
"type": "inject",
|
|
183
|
+
"name": "online, from the device",
|
|
184
|
+
"props": [
|
|
185
|
+
{
|
|
186
|
+
"p": "payload",
|
|
187
|
+
"v": "true",
|
|
188
|
+
"vt": "str"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"repeat": "",
|
|
192
|
+
"crontab": "",
|
|
193
|
+
"once": false,
|
|
194
|
+
"onceDelay": 0.1,
|
|
195
|
+
"topic": "shellyplus2pm-a8032ab12345/online",
|
|
196
|
+
"x": 180,
|
|
197
|
+
"y": 300,
|
|
198
|
+
"wires": [
|
|
199
|
+
[
|
|
200
|
+
"example-shelly-cover-adapter"
|
|
201
|
+
]
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"id": "example-shelly-cover-status",
|
|
206
|
+
"type": "inject",
|
|
207
|
+
"name": "cover status, from the device",
|
|
208
|
+
"props": [
|
|
209
|
+
{
|
|
210
|
+
"p": "payload",
|
|
211
|
+
"v": "{\"id\":0,\"state\":\"stopped\",\"current_pos\":40,\"pos_control\":true}",
|
|
212
|
+
"vt": "json"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"repeat": "",
|
|
216
|
+
"crontab": "",
|
|
217
|
+
"once": false,
|
|
218
|
+
"onceDelay": 0.1,
|
|
219
|
+
"topic": "shellyplus2pm-a8032ab12345/status/cover:0",
|
|
220
|
+
"x": 190,
|
|
221
|
+
"y": 340,
|
|
222
|
+
"wires": [
|
|
223
|
+
[
|
|
224
|
+
"example-shelly-cover-adapter"
|
|
225
|
+
]
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"id": "example-shelly-cover-notify",
|
|
230
|
+
"type": "inject",
|
|
231
|
+
"name": "change notification, from the device",
|
|
232
|
+
"props": [
|
|
233
|
+
{
|
|
234
|
+
"p": "payload",
|
|
235
|
+
"v": "{\"src\":\"shellyplus2pm-a8032ab12345\",\"dst\":\"shellyplus2pm-a8032ab12345/events\",\"method\":\"NotifyStatus\",\"params\":{\"ts\":1764151200,\"cover:0\":{\"id\":0,\"state\":\"open\",\"current_pos\":100}}}",
|
|
236
|
+
"vt": "json"
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"repeat": "",
|
|
240
|
+
"crontab": "",
|
|
241
|
+
"once": false,
|
|
242
|
+
"onceDelay": 0.1,
|
|
243
|
+
"topic": "shellyplus2pm-a8032ab12345/events/rpc",
|
|
244
|
+
"x": 210,
|
|
245
|
+
"y": 380,
|
|
246
|
+
"wires": [
|
|
247
|
+
[
|
|
248
|
+
"example-shelly-cover-adapter"
|
|
249
|
+
]
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
]
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "example-shelly-switch-comment",
|
|
4
|
+
"type": "comment",
|
|
5
|
+
"name": "Shelly switch example",
|
|
6
|
+
"info": "A wall switch wired to a Shelly Gen2 relay in detached mode: the relay stays on to power smart bulbs, and the switch's presses drive the room's lights through the switch policy, with no function nodes. The adapter reads the device's own configuration (its mode and input type) and shows it in its status. In your flow, replace the injects marked 'from the device' with an MQTT in node subscribed to <prefix>/# (output: auto-detect), and the debug node 'to the MQTT out node' with an MQTT out node, both on your broker; wire the switch policy to your room controller. Set the adapter's MQTT topic prefix to your device's (its device ID unless you set one).",
|
|
7
|
+
"x": 150,
|
|
8
|
+
"y": 40,
|
|
9
|
+
"wires": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "example-shelly-switch-adapter",
|
|
13
|
+
"type": "home-shelly-switch",
|
|
14
|
+
"name": "",
|
|
15
|
+
"topicPrefix": "shellyplus1-a8032ab12345",
|
|
16
|
+
"channel": 0,
|
|
17
|
+
"mode": "auto",
|
|
18
|
+
"x": 460,
|
|
19
|
+
"y": 200,
|
|
20
|
+
"wires": [
|
|
21
|
+
[
|
|
22
|
+
"example-shelly-switch-to-device"
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"example-shelly-switch-policy"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "example-shelly-switch-policy",
|
|
31
|
+
"type": "home-switch-lighting-policy",
|
|
32
|
+
"name": "",
|
|
33
|
+
"area": "",
|
|
34
|
+
"targets": "[\"main\"]",
|
|
35
|
+
"switchWindowMs": 500,
|
|
36
|
+
"switchFreshnessSeconds": 3600,
|
|
37
|
+
"x": 700,
|
|
38
|
+
"y": 240,
|
|
39
|
+
"wires": [
|
|
40
|
+
[
|
|
41
|
+
"example-shelly-switch-intents"
|
|
42
|
+
]
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "example-shelly-switch-to-device",
|
|
47
|
+
"type": "debug",
|
|
48
|
+
"name": "to the MQTT out node",
|
|
49
|
+
"active": true,
|
|
50
|
+
"tosidebar": true,
|
|
51
|
+
"console": false,
|
|
52
|
+
"tostatus": false,
|
|
53
|
+
"complete": "true",
|
|
54
|
+
"targetType": "full",
|
|
55
|
+
"statusVal": "",
|
|
56
|
+
"statusType": "auto",
|
|
57
|
+
"x": 700,
|
|
58
|
+
"y": 160,
|
|
59
|
+
"wires": []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "example-shelly-switch-intents",
|
|
63
|
+
"type": "debug",
|
|
64
|
+
"name": "lighting intents (to the room controller)",
|
|
65
|
+
"active": true,
|
|
66
|
+
"tosidebar": true,
|
|
67
|
+
"console": false,
|
|
68
|
+
"tostatus": false,
|
|
69
|
+
"complete": "true",
|
|
70
|
+
"targetType": "full",
|
|
71
|
+
"statusVal": "",
|
|
72
|
+
"statusType": "auto",
|
|
73
|
+
"x": 960,
|
|
74
|
+
"y": 240,
|
|
75
|
+
"wires": []
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "example-shelly-switch-config",
|
|
79
|
+
"type": "inject",
|
|
80
|
+
"name": "configuration reply, from the device",
|
|
81
|
+
"props": [
|
|
82
|
+
{
|
|
83
|
+
"p": "payload",
|
|
84
|
+
"v": "{\"id\": 1, \"src\": \"shellyplus1-a8032ab12345\", \"dst\": \"shellyplus1-a8032ab12345/home-automation-switch-0\", \"result\": {\"switch:0\": {\"id\": 0, \"in_mode\": \"detached\"}, \"input:0\": {\"id\": 0, \"type\": \"switch\"}}}",
|
|
85
|
+
"vt": "json"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"repeat": "",
|
|
89
|
+
"crontab": "",
|
|
90
|
+
"once": false,
|
|
91
|
+
"onceDelay": 0.1,
|
|
92
|
+
"topic": "shellyplus1-a8032ab12345/home-automation-switch-0/rpc",
|
|
93
|
+
"x": 210,
|
|
94
|
+
"y": 120,
|
|
95
|
+
"wires": [
|
|
96
|
+
[
|
|
97
|
+
"example-shelly-switch-adapter"
|
|
98
|
+
]
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "example-shelly-switch-status",
|
|
103
|
+
"type": "inject",
|
|
104
|
+
"name": "device status, from the device",
|
|
105
|
+
"props": [
|
|
106
|
+
{
|
|
107
|
+
"p": "payload",
|
|
108
|
+
"v": "{\"switch:0\":{\"id\":0,\"output\":true},\"input:0\":{\"id\":0,\"state\":false}}",
|
|
109
|
+
"vt": "json"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"repeat": "",
|
|
113
|
+
"crontab": "",
|
|
114
|
+
"once": false,
|
|
115
|
+
"onceDelay": 0.1,
|
|
116
|
+
"topic": "shellyplus1-a8032ab12345/status",
|
|
117
|
+
"x": 200,
|
|
118
|
+
"y": 160,
|
|
119
|
+
"wires": [
|
|
120
|
+
[
|
|
121
|
+
"example-shelly-switch-adapter"
|
|
122
|
+
]
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "example-shelly-switch-flip-on",
|
|
127
|
+
"type": "inject",
|
|
128
|
+
"name": "switch flipped on, from the device",
|
|
129
|
+
"props": [
|
|
130
|
+
{
|
|
131
|
+
"p": "payload",
|
|
132
|
+
"v": "{\"method\":\"NotifyStatus\",\"params\":{\"ts\":1764151200,\"input:0\":{\"id\":0,\"state\":true}}}",
|
|
133
|
+
"vt": "json"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"repeat": "",
|
|
137
|
+
"crontab": "",
|
|
138
|
+
"once": false,
|
|
139
|
+
"onceDelay": 0.1,
|
|
140
|
+
"topic": "shellyplus1-a8032ab12345/events/rpc",
|
|
141
|
+
"x": 210,
|
|
142
|
+
"y": 200,
|
|
143
|
+
"wires": [
|
|
144
|
+
[
|
|
145
|
+
"example-shelly-switch-adapter"
|
|
146
|
+
]
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "example-shelly-switch-flip-off",
|
|
151
|
+
"type": "inject",
|
|
152
|
+
"name": "switch flipped off, from the device",
|
|
153
|
+
"props": [
|
|
154
|
+
{
|
|
155
|
+
"p": "payload",
|
|
156
|
+
"v": "{\"method\":\"NotifyStatus\",\"params\":{\"ts\":1764151201,\"input:0\":{\"id\":0,\"state\":false}}}",
|
|
157
|
+
"vt": "json"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"repeat": "",
|
|
161
|
+
"crontab": "",
|
|
162
|
+
"once": false,
|
|
163
|
+
"onceDelay": 0.1,
|
|
164
|
+
"topic": "shellyplus1-a8032ab12345/events/rpc",
|
|
165
|
+
"x": 210,
|
|
166
|
+
"y": 240,
|
|
167
|
+
"wires": [
|
|
168
|
+
[
|
|
169
|
+
"example-shelly-switch-adapter"
|
|
170
|
+
]
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "example-shelly-switch-online",
|
|
175
|
+
"type": "inject",
|
|
176
|
+
"name": "online, from the device",
|
|
177
|
+
"props": [
|
|
178
|
+
{
|
|
179
|
+
"p": "payload",
|
|
180
|
+
"v": "true",
|
|
181
|
+
"vt": "str"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"repeat": "",
|
|
185
|
+
"crontab": "",
|
|
186
|
+
"once": false,
|
|
187
|
+
"onceDelay": 0.1,
|
|
188
|
+
"topic": "shellyplus1-a8032ab12345/online",
|
|
189
|
+
"x": 180,
|
|
190
|
+
"y": 280,
|
|
191
|
+
"wires": [
|
|
192
|
+
[
|
|
193
|
+
"example-shelly-switch-adapter"
|
|
194
|
+
]
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avantics/node-red-home-automation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Deterministic home automation components for Node-RED",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"contract-examples",
|
|
28
28
|
"!dist/**/*.js.map"
|
|
29
29
|
],
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
30
33
|
"scripts": {
|
|
31
34
|
"clean": "node scripts/clean.mjs",
|
|
32
35
|
"build": "npm run clean && tsc && node scripts/copy-node-html.mjs",
|
|
@@ -35,10 +38,11 @@
|
|
|
35
38
|
"scan:public": "node scripts/check-public.mjs",
|
|
36
39
|
"hooks:install": "git config core.hooksPath .githooks",
|
|
37
40
|
"prepack": "npm run build",
|
|
38
|
-
"diagrams": "node scripts/render-diagrams.mjs"
|
|
41
|
+
"diagrams": "node scripts/render-diagrams.mjs",
|
|
42
|
+
"docs": "node scripts/build-docs.mjs"
|
|
39
43
|
},
|
|
40
44
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
45
|
+
"node": ">=24"
|
|
42
46
|
},
|
|
43
47
|
"node-red": {
|
|
44
48
|
"version": ">=5.0.0",
|
|
@@ -47,6 +51,8 @@
|
|
|
47
51
|
"home-motion-lighting-policy": "dist/nodes/motion-policy.js",
|
|
48
52
|
"home-switch-lighting-policy": "dist/nodes/switch-policy.js",
|
|
49
53
|
"home-room-lighting-controller": "dist/nodes/room-controller.js",
|
|
54
|
+
"home-z2m-light": "dist/nodes/z2m-light.js",
|
|
55
|
+
"home-circadian-lighting-policy": "dist/nodes/circadian-policy.js",
|
|
50
56
|
"home-avr-controller": "dist/nodes/avr-controller.js",
|
|
51
57
|
"home-display-mode-controller": "dist/nodes/display-mode-controller.js",
|
|
52
58
|
"home-source-capability-controller": "dist/nodes/source-capability-controller.js",
|
|
@@ -57,7 +63,10 @@
|
|
|
57
63
|
"home-house-schedule": "dist/nodes/house-schedule.js",
|
|
58
64
|
"home-cover-controller": "dist/nodes/cover-controller.js",
|
|
59
65
|
"home-cover-group": "dist/nodes/cover-group.js",
|
|
60
|
-
"home-house-schedule-mqtt": "dist/nodes/house-schedule-mqtt.js"
|
|
66
|
+
"home-house-schedule-mqtt": "dist/nodes/house-schedule-mqtt.js",
|
|
67
|
+
"home-shelly-cover": "dist/nodes/shelly-cover.js",
|
|
68
|
+
"home-shelly-switch": "dist/nodes/shelly-switch.js",
|
|
69
|
+
"home-z2m-cover": "dist/nodes/z2m-cover.js"
|
|
61
70
|
}
|
|
62
71
|
},
|
|
63
72
|
"devDependencies": {
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type DaySchedule } from "./circadian-schedule";
|
|
2
|
-
import type { RoomConfig, RoomState } from "./room-controller";
|
|
3
|
-
export declare function savedSchedule(config: RoomConfig, saved: Partial<RoomState>): Pick<RoomState, "schedule" | "scheduleSetting">;
|
|
4
|
-
export declare function withActiveSchedule(config: RoomConfig, state: RoomState): RoomConfig;
|
|
5
|
-
export declare function requestedSchedule(current: DaySchedule, event: {
|
|
6
|
-
wakeTime?: unknown;
|
|
7
|
-
bedTime?: unknown;
|
|
8
|
-
}): DaySchedule | null;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.savedSchedule = savedSchedule;
|
|
4
|
-
exports.withActiveSchedule = withActiveSchedule;
|
|
5
|
-
exports.requestedSchedule = requestedSchedule;
|
|
6
|
-
// The room's wake and bed times while it runs: the configured times, or times
|
|
7
|
-
// set at runtime (from Home Assistant, say), which last until the node is
|
|
8
|
-
// deployed with a different setting for them. And the room's lighting on
|
|
9
|
-
// whichever times are in use.
|
|
10
|
-
const circadian_schedule_1 = require("./circadian-schedule");
|
|
11
|
-
const settings_1 = require("./settings");
|
|
12
|
-
function configuredSchedule(config) {
|
|
13
|
-
return config.schedule ?? { wakeTime: circadian_schedule_1.DEFAULT_WAKE_TIME, bedTime: circadian_schedule_1.DEFAULT_BED_TIME };
|
|
14
|
-
}
|
|
15
|
-
// Each saved time stands only while the setting it was based on is
|
|
16
|
-
// unchanged; state saved before times could change takes the settings.
|
|
17
|
-
function savedSchedule(config, saved) {
|
|
18
|
-
const setting = configuredSchedule(config);
|
|
19
|
-
const kept = (key) => (0, settings_1.keptOverride)(saved.schedule?.[key], saved.scheduleSetting?.[key], setting[key]);
|
|
20
|
-
return { schedule: { wakeTime: kept("wakeTime"), bedTime: kept("bedTime") }, scheduleSetting: { ...setting } };
|
|
21
|
-
}
|
|
22
|
-
// The room's settings with lighting that follows the times in use.
|
|
23
|
-
function withActiveSchedule(config, state) {
|
|
24
|
-
const setting = configuredSchedule(config);
|
|
25
|
-
const same = state.schedule.wakeTime === setting.wakeTime && state.schedule.bedTime === setting.bedTime;
|
|
26
|
-
if (same)
|
|
27
|
-
return config;
|
|
28
|
-
return { ...config, lighting: config.lighting.withSchedule(state.schedule) };
|
|
29
|
-
}
|
|
30
|
-
// New times from a "schedule" message, each "HH:MM", with a time left out
|
|
31
|
-
// staying as it is; null if they aren't valid, different times.
|
|
32
|
-
function requestedSchedule(current, event) {
|
|
33
|
-
const next = {
|
|
34
|
-
wakeTime: typeof event.wakeTime === "string" ? event.wakeTime.trim() : current.wakeTime,
|
|
35
|
-
bedTime: typeof event.bedTime === "string" ? event.bedTime.trim() : current.bedTime
|
|
36
|
-
};
|
|
37
|
-
const wake = (0, circadian_schedule_1.clockMinutes)(next.wakeTime);
|
|
38
|
-
const bed = (0, circadian_schedule_1.clockMinutes)(next.bedTime);
|
|
39
|
-
return wake === null || bed === null || wake === bed ? null : next;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=room-schedule.js.map
|