homematic-manager 3.9.1 → 3.10.1

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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The LED and MP3 modes of the homebrew signal devices (task 128): a `SUBMIT` datapoint whose value
3
+ * is several numbers in one string, which the CCU's WebUI composes in a dialog of its own and nobody
4
+ * types by hand.
5
+ *
6
+ * | Device | Channel | WebUI dialog | Value |
7
+ * | --- | --- | --- | --- |
8
+ * | HB-OU-MP3-LED | `SIGNAL_LED` | `setHBOUCFMMode.htm` | `0,brightness,duration,bpm,colour` |
9
+ * | HB-OU-MP3-LED | `SIGNAL_CHIME` | `setHBOUCFMMode.htm` | `volume,repetitions,duration,file[,file…]` |
10
+ * | HB-RC-6-PBU-LED | `SIGNAL_LED` | `setHBRC6LEDMode.htm` | `0,brightness,duration,interval,colour` |
11
+ * | HB-OU-RGBW-LED-FX | `SIGNAL_LED` | `setHBOURGBWLEDFXMode.htm` | `0,brightness,duration,speed,effect,r,g,b,w,options` |
12
+ *
13
+ * (OpenCCU-Base#414 at `6eb475b`, `src/webui/rega/www/pages/msg/`; the WebUI offers them by device
14
+ * type in `esp/side.inc`.) All three write `SUBMIT` of the channel - `STRING`, write only, rfd's
15
+ * `cfm` conversion into a 14-byte frame - and the numbers are clamped as the dialogs clamp them:
16
+ * 0..255 each, a duration of 0..108000 s (108000 being "as long as the file" on the chime), a
17
+ * volume in tenths. The channel types are the HM-OU-CFM-Pl's, whose stock dialog writes another
18
+ * layout, so the device type decides, never the channel type alone.
19
+ */
20
+ import type { ParamsetDescription } from './description.js';
21
+ /** The four layouts. */
22
+ export type SignalModeKind = 'hb-led' | 'hb-rc6-led' | 'hb-mp3' | 'hb-rgbw-fx';
23
+ /** The datapoint the modes are written to. */
24
+ export declare const SIGNAL_MODE_PARAM = "SUBMIT";
25
+ /** The longest duration, in seconds; on the chime it means "as long as the file plays". */
26
+ export declare const SIGNAL_MAX_DURATION = 108000;
27
+ /** The most MP3 files one value can name (the frame's ten action bytes). */
28
+ export declare const SIGNAL_MAX_FILES = 10;
29
+ /**
30
+ * The layout a channel takes, or `undefined` when it is not one of these: the device type and the
31
+ * channel type have to be in the table, and the description has to have a writable `SUBMIT` string -
32
+ * so a firmware without one, or another device with the same channel type, gets no form.
33
+ */
34
+ export declare function signalModeKind(deviceType: string | undefined, channelType: string, description: ParamsetDescription | undefined): SignalModeKind | undefined;
35
+ /** The colours of the LED dialogs, by the value they send, in the dialogs' order. */
36
+ export declare const SIGNAL_LED_COLORS: ReadonlyArray<{
37
+ readonly value: number;
38
+ readonly name: string;
39
+ }>;
40
+ /** The effects of the RGBW-LED-FX (WS2812FX), by number; 0 is off. */
41
+ export declare const SIGNAL_FX_EFFECTS: readonly string[];
42
+ /** An LED mode: the MP3-LED's and the RC-6's (`rate` is BPM on the one, 100 ms steps on the other). */
43
+ export interface SignalLedMode {
44
+ readonly brightness: number;
45
+ readonly duration: number;
46
+ readonly rate: number;
47
+ readonly color: number;
48
+ }
49
+ /** A chime (MP3) mode. `duration` {@link SIGNAL_MAX_DURATION} plays the file as long as it is. */
50
+ export interface SignalChimeMode {
51
+ /** Tenths: 0 is off, 10 is full volume. */
52
+ readonly volume: number;
53
+ readonly repetitions: number;
54
+ readonly duration: number;
55
+ /** The file numbers, 1..255 each (1 is `0001.mp3`). */
56
+ readonly files: readonly number[];
57
+ }
58
+ /** The RGBW-LED-FX's mode. */
59
+ export interface SignalFxMode {
60
+ readonly brightness: number;
61
+ readonly duration: number;
62
+ readonly speed: number;
63
+ readonly effect: number;
64
+ readonly red: number;
65
+ readonly green: number;
66
+ readonly blue: number;
67
+ readonly white: number;
68
+ readonly options: number;
69
+ }
70
+ /** A mode of any layout, tagged by it. */
71
+ export type SignalMode = ({
72
+ readonly kind: 'hb-led' | 'hb-rc6-led';
73
+ } & SignalLedMode) | ({
74
+ readonly kind: 'hb-mp3';
75
+ } & SignalChimeMode) | ({
76
+ readonly kind: 'hb-rgbw-fx';
77
+ } & SignalFxMode);
78
+ /** What each dialog opens with when there is no value yet (`getDefaultValue`). */
79
+ export declare function defaultSignalMode(kind: SignalModeKind): SignalMode;
80
+ /** A whole number in `min..max`; anything else becomes `min`, as the dialogs' `setMinMax` does. */
81
+ export declare function clampInt(value: number, min: number, max: number): number;
82
+ /** The value `SUBMIT` takes for a mode - exactly the string the WebUI's dialog writes. */
83
+ export declare function composeSignalMode(mode: SignalMode): string;
84
+ /**
85
+ * A `SUBMIT` value read back into a mode of this layout, or `undefined` when it is not one (the
86
+ * field may hold anything the user typed). The inverse of {@link composeSignalMode} for every value
87
+ * it writes; numbers out of range are clamped as the dialogs clamp them.
88
+ */
89
+ export declare function parseSignalMode(kind: SignalModeKind, value: string): SignalMode | undefined;
90
+ /**
91
+ * The MP3 file numbers of a typed list (`1, 4,12`), or `undefined` when it is not 1..10 numbers of
92
+ * 1..255.
93
+ */
94
+ export declare function parseSignalFiles(text: string): number[] | undefined;
95
+ /** Seconds as the dialogs' three fields show them. */
96
+ export declare function splitSeconds(total: number): {
97
+ hours: number;
98
+ minutes: number;
99
+ seconds: number;
100
+ };
101
+ //# sourceMappingURL=signalModes.d.ts.map
@@ -0,0 +1,260 @@
1
+ /**
2
+ * The LED and MP3 modes of the homebrew signal devices (task 128): a `SUBMIT` datapoint whose value
3
+ * is several numbers in one string, which the CCU's WebUI composes in a dialog of its own and nobody
4
+ * types by hand.
5
+ *
6
+ * | Device | Channel | WebUI dialog | Value |
7
+ * | --- | --- | --- | --- |
8
+ * | HB-OU-MP3-LED | `SIGNAL_LED` | `setHBOUCFMMode.htm` | `0,brightness,duration,bpm,colour` |
9
+ * | HB-OU-MP3-LED | `SIGNAL_CHIME` | `setHBOUCFMMode.htm` | `volume,repetitions,duration,file[,file…]` |
10
+ * | HB-RC-6-PBU-LED | `SIGNAL_LED` | `setHBRC6LEDMode.htm` | `0,brightness,duration,interval,colour` |
11
+ * | HB-OU-RGBW-LED-FX | `SIGNAL_LED` | `setHBOURGBWLEDFXMode.htm` | `0,brightness,duration,speed,effect,r,g,b,w,options` |
12
+ *
13
+ * (OpenCCU-Base#414 at `6eb475b`, `src/webui/rega/www/pages/msg/`; the WebUI offers them by device
14
+ * type in `esp/side.inc`.) All three write `SUBMIT` of the channel - `STRING`, write only, rfd's
15
+ * `cfm` conversion into a 14-byte frame - and the numbers are clamped as the dialogs clamp them:
16
+ * 0..255 each, a duration of 0..108000 s (108000 being "as long as the file" on the chime), a
17
+ * volume in tenths. The channel types are the HM-OU-CFM-Pl's, whose stock dialog writes another
18
+ * layout, so the device type decides, never the channel type alone.
19
+ */
20
+ /** Which layout a device type's channel type takes. Device types in lower case. */
21
+ const SIGNAL_MODE_DEVICES = {
22
+ 'hb-ou-mp3-led': { SIGNAL_LED: 'hb-led', SIGNAL_CHIME: 'hb-mp3' },
23
+ 'hb-rc-6-pbu-led': { SIGNAL_LED: 'hb-rc6-led' },
24
+ 'hb-ou-rgbw-led-fx': { SIGNAL_LED: 'hb-rgbw-fx' },
25
+ };
26
+ /** The datapoint the modes are written to. */
27
+ export const SIGNAL_MODE_PARAM = 'SUBMIT';
28
+ /** The longest duration, in seconds; on the chime it means "as long as the file plays". */
29
+ export const SIGNAL_MAX_DURATION = 108_000;
30
+ /** The most MP3 files one value can name (the frame's ten action bytes). */
31
+ export const SIGNAL_MAX_FILES = 10;
32
+ /**
33
+ * The layout a channel takes, or `undefined` when it is not one of these: the device type and the
34
+ * channel type have to be in the table, and the description has to have a writable `SUBMIT` string -
35
+ * so a firmware without one, or another device with the same channel type, gets no form.
36
+ */
37
+ export function signalModeKind(deviceType, channelType, description) {
38
+ const kind = SIGNAL_MODE_DEVICES[(deviceType ?? '').toLowerCase()]?.[channelType];
39
+ const submit = description?.[SIGNAL_MODE_PARAM];
40
+ if (kind === undefined || submit === undefined || submit.TYPE !== 'STRING') {
41
+ return undefined;
42
+ }
43
+ return (submit.OPERATIONS & 2) === 2 ? kind : undefined;
44
+ }
45
+ /** The colours of the LED dialogs, by the value they send, in the dialogs' order. */
46
+ export const SIGNAL_LED_COLORS = [
47
+ { value: 0, name: 'Off' },
48
+ { value: 31, name: 'Yellow' },
49
+ { value: 81, name: 'Orange' },
50
+ { value: 11, name: 'Red' },
51
+ { value: 21, name: 'Green' },
52
+ { value: 41, name: 'Blue' },
53
+ { value: 51, name: 'Purple' },
54
+ { value: 61, name: 'Turquoise' },
55
+ { value: 71, name: 'White' },
56
+ ];
57
+ /** The effects of the RGBW-LED-FX (WS2812FX), by number; 0 is off. */
58
+ export const SIGNAL_FX_EFFECTS = [
59
+ 'Off',
60
+ 'Static',
61
+ 'Blink',
62
+ 'Breath',
63
+ 'Color Wipe',
64
+ 'Color Wipe Inverse',
65
+ 'Color Wipe Reverse',
66
+ 'Color Wipe Reverse Inverse',
67
+ 'Color Wipe Random',
68
+ 'Random Color',
69
+ 'Single Dynamic',
70
+ 'Multi Dynamic',
71
+ 'Rainbow',
72
+ 'Rainbow Cycle',
73
+ 'Scan',
74
+ 'Dual Scan',
75
+ 'Fade',
76
+ 'Theater Chase',
77
+ 'Theater Chase Rainbow',
78
+ 'Running Lights',
79
+ 'Twinkle',
80
+ 'Twinkle Random',
81
+ 'Twinkle Fade',
82
+ 'Twinkle Fade Random',
83
+ 'Sparkle',
84
+ 'Flash Sparkle',
85
+ 'Hyper Sparkle',
86
+ 'Strobe',
87
+ 'Strobe Rainbow',
88
+ 'Multi Strobe',
89
+ 'Blink Rainbow',
90
+ 'Chase White',
91
+ 'Chase Color',
92
+ 'Chase Random',
93
+ 'Chase Rainbow',
94
+ 'Chase Flash',
95
+ 'Chase Flash Random',
96
+ 'Chase Rainbow White',
97
+ 'Chase Blackout',
98
+ 'Chase Blackout Rainbow',
99
+ 'Color Sweep Random',
100
+ 'Running Color',
101
+ 'Running Red Blue',
102
+ 'Running Random',
103
+ 'Larson Scanner',
104
+ 'Comet',
105
+ 'Fireworks',
106
+ 'Fireworks Random',
107
+ 'Merry Christmas',
108
+ 'Fire Flicker',
109
+ 'Fire Flicker (soft)',
110
+ 'Fire Flicker (intense)',
111
+ 'Circus Combustus',
112
+ 'Halloween',
113
+ 'Bicolor Chase',
114
+ 'Tricolor Chase',
115
+ 'TwinkleFOX',
116
+ 'Spots',
117
+ 'Custom 1',
118
+ 'Custom 2',
119
+ 'Custom 3',
120
+ 'Custom 4',
121
+ 'Custom 5',
122
+ 'Custom 6',
123
+ 'Custom 7',
124
+ ];
125
+ /** What each dialog opens with when there is no value yet (`getDefaultValue`). */
126
+ export function defaultSignalMode(kind) {
127
+ switch (kind) {
128
+ case 'hb-led':
129
+ return { kind, brightness: 128, duration: 30, rate: 60, color: 0 };
130
+ case 'hb-rc6-led':
131
+ return { kind, brightness: 128, duration: 0, rate: 0, color: 0 };
132
+ case 'hb-mp3':
133
+ return { kind, volume: 10, repetitions: 1, duration: SIGNAL_MAX_DURATION, files: [1] };
134
+ case 'hb-rgbw-fx':
135
+ return {
136
+ kind,
137
+ brightness: 128,
138
+ duration: 0,
139
+ speed: 128,
140
+ effect: 1,
141
+ red: 255,
142
+ green: 0,
143
+ blue: 0,
144
+ white: 0,
145
+ options: 0,
146
+ };
147
+ }
148
+ }
149
+ /** A whole number in `min..max`; anything else becomes `min`, as the dialogs' `setMinMax` does. */
150
+ export function clampInt(value, min, max) {
151
+ if (!Number.isFinite(value)) {
152
+ return min;
153
+ }
154
+ return Math.min(max, Math.max(min, Math.trunc(value)));
155
+ }
156
+ const byte = (value) => clampInt(value, 0, 255);
157
+ const seconds = (value) => clampInt(value, 0, SIGNAL_MAX_DURATION);
158
+ /** The value `SUBMIT` takes for a mode - exactly the string the WebUI's dialog writes. */
159
+ export function composeSignalMode(mode) {
160
+ switch (mode.kind) {
161
+ case 'hb-led':
162
+ case 'hb-rc6-led': {
163
+ const color = SIGNAL_LED_COLORS.some((entry) => entry.value === mode.color) ? mode.color : 0;
164
+ return ['0', byte(mode.brightness), seconds(mode.duration), byte(mode.rate), color].join(',');
165
+ }
166
+ case 'hb-mp3': {
167
+ const files = mode.files.map((file) => clampInt(file, 1, 255)).slice(0, SIGNAL_MAX_FILES);
168
+ const level = clampInt(mode.volume, 0, 10) / 10;
169
+ return [
170
+ String(level),
171
+ byte(mode.repetitions),
172
+ seconds(mode.duration),
173
+ ...(files.length > 0 ? files : [1]),
174
+ ].join(',');
175
+ }
176
+ case 'hb-rgbw-fx':
177
+ return [
178
+ '0',
179
+ byte(mode.brightness),
180
+ seconds(mode.duration),
181
+ byte(mode.speed),
182
+ clampInt(mode.effect, 0, SIGNAL_FX_EFFECTS.length - 1),
183
+ byte(mode.red),
184
+ byte(mode.green),
185
+ byte(mode.blue),
186
+ byte(mode.white),
187
+ byte(mode.options),
188
+ ].join(',');
189
+ }
190
+ }
191
+ /**
192
+ * A `SUBMIT` value read back into a mode of this layout, or `undefined` when it is not one (the
193
+ * field may hold anything the user typed). The inverse of {@link composeSignalMode} for every value
194
+ * it writes; numbers out of range are clamped as the dialogs clamp them.
195
+ */
196
+ export function parseSignalMode(kind, value) {
197
+ const parts = value.split(',').map((part) => part.trim());
198
+ if (parts.some((part) => part === '' || !Number.isFinite(Number(part)))) {
199
+ return undefined;
200
+ }
201
+ const numbers = parts.map(Number);
202
+ const at = (index) => numbers[index] ?? 0;
203
+ switch (kind) {
204
+ case 'hb-led':
205
+ case 'hb-rc6-led': {
206
+ if (numbers.length !== 5)
207
+ return undefined;
208
+ const color = SIGNAL_LED_COLORS.some((entry) => entry.value === at(4)) ? at(4) : 0;
209
+ return { kind, brightness: byte(at(1)), duration: seconds(at(2)), rate: byte(at(3)), color };
210
+ }
211
+ case 'hb-mp3': {
212
+ if (numbers.length < 4 || numbers.length > 3 + SIGNAL_MAX_FILES)
213
+ return undefined;
214
+ return {
215
+ kind,
216
+ volume: clampInt(Math.round(at(0) * 10), 0, 10),
217
+ repetitions: byte(at(1)),
218
+ duration: seconds(at(2)),
219
+ files: numbers.slice(3).map((file) => clampInt(file, 1, 255)),
220
+ };
221
+ }
222
+ case 'hb-rgbw-fx': {
223
+ if (numbers.length < 10)
224
+ return undefined;
225
+ return {
226
+ kind,
227
+ brightness: byte(at(1)),
228
+ duration: seconds(at(2)),
229
+ speed: byte(at(3)),
230
+ effect: clampInt(at(4), 0, SIGNAL_FX_EFFECTS.length - 1),
231
+ red: byte(at(5)),
232
+ green: byte(at(6)),
233
+ blue: byte(at(7)),
234
+ white: byte(at(8)),
235
+ options: byte(at(9)),
236
+ };
237
+ }
238
+ }
239
+ }
240
+ /**
241
+ * The MP3 file numbers of a typed list (`1, 4,12`), or `undefined` when it is not 1..10 numbers of
242
+ * 1..255.
243
+ */
244
+ export function parseSignalFiles(text) {
245
+ const parts = text
246
+ .split(/[,\s]+/)
247
+ .map((part) => part.trim())
248
+ .filter((part) => part !== '');
249
+ if (parts.length === 0 || parts.length > SIGNAL_MAX_FILES) {
250
+ return undefined;
251
+ }
252
+ const files = parts.map(Number);
253
+ return files.every((file) => Number.isInteger(file) && file >= 1 && file <= 255) ? files : undefined;
254
+ }
255
+ /** Seconds as the dialogs' three fields show them. */
256
+ export function splitSeconds(total) {
257
+ const value = seconds(total);
258
+ return { hours: Math.floor(value / 3600), minutes: Math.floor((value % 3600) / 60), seconds: value % 60 };
259
+ }
260
+ //# sourceMappingURL=signalModes.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homematic-manager/core",
3
- "version": "3.9.1",
3
+ "version": "3.10.1",
4
4
  "type": "module",
5
5
  "description": "Pure domain logic of the Homematic Manager: no I/O, no DOM",
6
6
  "license": "AGPL-3.0-or-later",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homematic-manager",
3
- "version": "3.9.1",
3
+ "version": "3.10.1",
4
4
  "type": "module",
5
5
  "description": "Configure and administer Homematic and HomematicIP devices - devices and channels, direct links, paramsets, RSSI, service messages, events and an RPC console - from a local HTTP/WebSocket server that also serves the web UI",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  "hm-simulator": "^1.5.0"
68
68
  },
69
69
  "dependencies": {
70
- "@homematic-manager/backend": "3.9.1",
71
- "@homematic-manager/core": "3.9.1",
70
+ "@homematic-manager/backend": "3.10.1",
71
+ "@homematic-manager/core": "3.10.1",
72
72
  "binrpc": "^4.2.0",
73
73
  "homematic-rega": "^2.0.0",
74
74
  "homematic-xmlrpc": "^2.0.0",