homematic-manager 3.4.2 → 3.5.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 (37) hide show
  1. package/data/cross-validations.json +14 -0
  2. package/data/easymode-time-selectors.json +1 -1
  3. package/data/manifest.json +12 -12
  4. package/data/master-forms.json +245 -24
  5. package/data/master-metadata.json +323 -9
  6. package/data/translations/de.json +12 -1
  7. package/data/translations/en.json +11 -0
  8. package/node_modules/@homematic-manager/backend/dist/api/backend.js +28 -5
  9. package/node_modules/@homematic-manager/backend/dist/rega/scripts.d.ts +12 -6
  10. package/node_modules/@homematic-manager/backend/dist/rega/scripts.js +17 -8
  11. package/node_modules/@homematic-manager/backend/dist/write/paramset.d.ts +10 -0
  12. package/node_modules/@homematic-manager/backend/dist/write/paramset.js +22 -1
  13. package/node_modules/@homematic-manager/backend/dist/write/repair.d.ts +7 -7
  14. package/node_modules/@homematic-manager/backend/dist/write/repair.js +5 -14
  15. package/node_modules/@homematic-manager/backend/package.json +1 -1
  16. package/node_modules/@homematic-manager/core/dist/api/types.d.ts +15 -0
  17. package/node_modules/@homematic-manager/core/dist/index.d.ts +2 -0
  18. package/node_modules/@homematic-manager/core/dist/index.js +2 -0
  19. package/node_modules/@homematic-manager/core/dist/interfaces/table.d.ts +14 -0
  20. package/node_modules/@homematic-manager/core/dist/interfaces/table.js +20 -0
  21. package/node_modules/@homematic-manager/core/dist/links/partnerFilter.d.ts +55 -0
  22. package/node_modules/@homematic-manager/core/dist/links/partnerFilter.js +235 -0
  23. package/node_modules/@homematic-manager/core/dist/paramset/cast.d.ts +37 -0
  24. package/node_modules/@homematic-manager/core/dist/paramset/cast.js +61 -1
  25. package/node_modules/@homematic-manager/core/dist/paramset/diff.d.ts +15 -0
  26. package/node_modules/@homematic-manager/core/dist/paramset/diff.js +16 -2
  27. package/node_modules/@homematic-manager/core/dist/paramset/powerMeter.d.ts +40 -0
  28. package/node_modules/@homematic-manager/core/dist/paramset/powerMeter.js +47 -0
  29. package/node_modules/@homematic-manager/core/dist/paramset/units.d.ts +11 -0
  30. package/node_modules/@homematic-manager/core/dist/paramset/units.js +19 -0
  31. package/node_modules/@homematic-manager/core/package.json +1 -1
  32. package/package.json +3 -3
  33. package/ui/assets/index-BGYochtr.js +21 -0
  34. package/ui/assets/index-Cd-Vx9ge.css +1 -0
  35. package/ui/index.html +2 -2
  36. package/ui/assets/index-BOEXCG42.css +0 -1
  37. package/ui/assets/index-Fj6yr6EG.js +0 -21
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Which channels the "create link" dialog offers, beyond the role matrix.
3
+ *
4
+ * The roles (`roles.ts`) say which channels *can* be linked. The CCU's WebUI offers fewer: its
5
+ * channel list for a new link (`ic_selchannel.cgi`, `showHmIPChannel` and `linkIsExpertChannel`,
6
+ * read at OpenCCU 3.89.13) leaves out channels a link makes no sense for or must not be made
7
+ * with - a plug's own button as the sender of a link to another device, the channels a light
8
+ * controller does not use in its mode, the second and third virtual channel of every actuator
9
+ * channel. This module is those rules as data and a few predicates, so the dialog can offer what
10
+ * the CCU offers and still show everything on request.
11
+ *
12
+ * Pure: the rules that depend on how a device is set up need a MASTER paramset, and the caller
13
+ * reads those ({@link linkFilterMasters} says which) and hands them in. A paramset that was not
14
+ * read hides nothing - an unknown mode shows the channel, as the WebUI's rules fall through.
15
+ *
16
+ * Not ported: the display channels of the wall-mount glass displays (`*-WGD`, `*-WGD-PL`). The
17
+ * WebUI picks them by the order of the screens, which it keeps in ReGa's metadata of the device
18
+ * and nowhere on the device itself; there is nothing to read it from on a system without ReGa.
19
+ */
20
+ import { tryParseAddress } from '../address/address.js';
21
+ import { isChannelDescription } from '../devices/index.js';
22
+ /** `DIRECTION` of a channel description. */
23
+ const SENDER = 1;
24
+ /** `FLAGS` bit 0: the channel is meant to be shown. */
25
+ const FLAG_VISIBLE = 1;
26
+ /** The virtual receiver channels that come in threes, of which the WebUI shows the first. */
27
+ const VIRTUAL_RECEIVER_TYPES = new Set([
28
+ 'DIMMER_VIRTUAL_RECEIVER',
29
+ 'SWITCH_VIRTUAL_RECEIVER',
30
+ 'BLIND_VIRTUAL_RECEIVER',
31
+ 'SHUTTER_VIRTUAL_RECEIVER',
32
+ 'ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER',
33
+ 'SERVO_VIRTUAL_RECEIVER',
34
+ ]);
35
+ /** The BidCos dimmers' virtual channels: only with the WebUI's expert mode. */
36
+ const BIDCOS_VIRTUAL_TYPES = new Set([
37
+ 'VIRTUAL_DIMMER',
38
+ 'VIRTUAL_DUAL_WHITE_BRIGHTNESS',
39
+ 'VIRTUAL_DUAL_WHITE_COLOR',
40
+ ]);
41
+ /** Devices whose channels 2, 4, 6 and 8 are the expert ones (3 and 7 are needed for some links). */
42
+ const EVEN_CHANNEL_EXPERT_DEVICES = new Set(['HMIP-MIOB', 'HMIP-WHS2']);
43
+ /** The wall-mount glass switches whose keys depend on `DEVICE_INPUT_LAYOUT_MODE`. */
44
+ const WGS_DEVICES = new Set(['HMIP-WGS', 'HMIP-WGS-A', 'HMIPW-WGS', 'HMIPW-WGS-A']);
45
+ /** Channel types the WebUI never offers for a link. */
46
+ const NEVER_LINKED_TYPES = new Set(['WEEK_PROGRAM', 'KWL_CONTROLLER_TRANSMITTER']);
47
+ function deviceTypeOf(channel, device) {
48
+ return (channel.PARENT_TYPE ?? device?.TYPE ?? '').toUpperCase();
49
+ }
50
+ function channelNumber(channel) {
51
+ return channel.INDEX ?? tryParseAddress(channel.ADDRESS)?.index;
52
+ }
53
+ function maintenanceAddress(channel) {
54
+ const device = channel.PARENT ?? tryParseAddress(channel.ADDRESS)?.device ?? channel.ADDRESS;
55
+ return `${device}:0`;
56
+ }
57
+ /** A number out of a paramset: hmipserver answers an ENUM with its index. A name is not resolved. */
58
+ function numberOf(master, param) {
59
+ const value = master?.[param];
60
+ if (typeof value === 'number') {
61
+ return value;
62
+ }
63
+ if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value))) {
64
+ return Number(value);
65
+ }
66
+ return undefined;
67
+ }
68
+ /** The major version of a firmware string; `undefined` where there is none. */
69
+ function firmwareMajor(firmware) {
70
+ const major = Number.parseInt((firmware ?? '').split('.')[0] ?? '', 10);
71
+ return Number.isNaN(major) ? undefined : major;
72
+ }
73
+ /**
74
+ * The device's own sender channels that are not offered to other devices: the internal button of
75
+ * the plugs and the PCB switches (`HmIP-PS`, `HmIP-PSM*`, `HmIP-PDT*`, `HmIP-PCBS*`,
76
+ * `ELV-SH-SW1-BAT`), and every sender channel of a measuring plug with a firmware before 2.x -
77
+ * its `COND_SWITCH_TRANSMITTER` cannot be linked there - except on the HmIP-PSMCO.
78
+ */
79
+ function isInternalSender(deviceType, channel, device) {
80
+ if (channel.DIRECTION !== SENDER) {
81
+ return false;
82
+ }
83
+ if (deviceType === 'HMIP-PS' || deviceType === 'ELV-SH-SW1-BAT') {
84
+ return true;
85
+ }
86
+ if (deviceType.startsWith('HMIP-PDT') || deviceType.startsWith('HMIP-PCBS')) {
87
+ return true;
88
+ }
89
+ if (deviceType.startsWith('HMIP-PSM')) {
90
+ if (channel.TYPE === 'KEY_TRANSCEIVER') {
91
+ return true;
92
+ }
93
+ const major = firmwareMajor(device?.FIRMWARE);
94
+ return major !== undefined && major < 2 && deviceType !== 'HMIP-PSMCO';
95
+ }
96
+ return false;
97
+ }
98
+ /**
99
+ * The channels a device does not use the way it is set up. `undefined` where no rule of this kind
100
+ * applies to the channel or the paramset it needs was not read; `false` where a rule says "show".
101
+ */
102
+ function hiddenByMode(deviceType, channel, number, masters) {
103
+ if (deviceType === 'HMIP-RGBW' && channel.TYPE === 'UNIVERSAL_LIGHT_RECEIVER') {
104
+ // 0 = RGBW, 1 = RGB: one light on channel 1; 2 = tunable white: two; 3 = PWM: all four
105
+ const mode = numberOf(masters.get(maintenanceAddress(channel)), 'DEVICE_OPERATION_MODE');
106
+ if (mode === 0 || mode === 1)
107
+ return number !== 1;
108
+ if (mode === 2)
109
+ return number !== 1 && number !== 2;
110
+ if (mode === 3)
111
+ return false;
112
+ return undefined;
113
+ }
114
+ if (deviceType === 'HMIP-DRG-DALI') {
115
+ const own = masters.get(channel.ADDRESS);
116
+ const dali = numberOf(own, 'DALI_ADDRESS');
117
+ if (dali !== undefined) {
118
+ // 255: no DALI device behind this channel
119
+ return dali === 255;
120
+ }
121
+ if (number !== undefined && number >= 33 && number <= 48) {
122
+ // a group channel nothing is assigned to
123
+ return numberOf(own, 'UNIVERSAL_LIGHT_MAX_CAPABILITIES') === 5 ? true : undefined;
124
+ }
125
+ return undefined;
126
+ }
127
+ if (WGS_DEVICES.has(deviceType) && channel.TYPE === 'KEY_TRANSCEIVER') {
128
+ // the keys the chosen layout has: one rocker (0), two (1, 2), or all four keys
129
+ const mode = numberOf(masters.get(maintenanceAddress(channel)), 'DEVICE_INPUT_LAYOUT_MODE');
130
+ if (mode === 0 && (number === 2 || number === 3 || number === 4))
131
+ return true;
132
+ if ((mode === 1 || mode === 2) && (number === 3 || number === 4))
133
+ return true;
134
+ return undefined;
135
+ }
136
+ return undefined;
137
+ }
138
+ /**
139
+ * Every channel of the interface the WebUI would not offer for a new link, with the reason.
140
+ *
141
+ * The order of the rules is the WebUI's: the device's own senders, the channel types never linked,
142
+ * the device's mode, the expert channels, and last the interface's own "invisible" flag.
143
+ */
144
+ export function hiddenLinkChannels(index, masters = new Map()) {
145
+ const hidden = new Map();
146
+ for (const device of index.devices()) {
147
+ // the virtual channels of one device, counted in threes in channel order
148
+ let virtualCount = 0;
149
+ for (const channel of index.childrenOf(device.ADDRESS)) {
150
+ if (!isChannelDescription(channel)) {
151
+ continue;
152
+ }
153
+ const deviceType = deviceTypeOf(channel, device);
154
+ const number = channelNumber(channel);
155
+ const reason = reasonFor(deviceType, channel, device, number, masters, () => {
156
+ virtualCount = virtualCount >= 3 ? 1 : virtualCount + 1;
157
+ return virtualCount;
158
+ });
159
+ if (reason !== undefined) {
160
+ hidden.set(channel.ADDRESS, reason);
161
+ }
162
+ }
163
+ }
164
+ return hidden;
165
+ }
166
+ function reasonFor(deviceType, channel, device, number, masters, nextVirtual) {
167
+ if (BIDCOS_VIRTUAL_TYPES.has(channel.TYPE)) {
168
+ return 'expert';
169
+ }
170
+ if (isInternalSender(deviceType, channel, device)) {
171
+ return 'internal-sender';
172
+ }
173
+ if (NEVER_LINKED_TYPES.has(channel.TYPE)) {
174
+ return 'not-for-links';
175
+ }
176
+ // the sabotage contact of the HmIP-ASIR is described as a key and is none
177
+ if (deviceType.includes('HMIP-ASIR') && channel.TYPE === 'KEY_TRANSCEIVER') {
178
+ return 'not-for-links';
179
+ }
180
+ const mode = hiddenByMode(deviceType, channel, number, masters);
181
+ if (mode === true) {
182
+ return 'device-mode';
183
+ }
184
+ if (mode === undefined) {
185
+ // a mode rule that says "show" ends the WebUI's function before the expert rule, too
186
+ if (EVEN_CHANNEL_EXPERT_DEVICES.has(deviceType)) {
187
+ if (number === 2 || number === 4 || number === 6 || number === 8) {
188
+ return 'expert';
189
+ }
190
+ }
191
+ else if (VIRTUAL_RECEIVER_TYPES.has(channel.TYPE) && nextVirtual() !== 1) {
192
+ return 'expert';
193
+ }
194
+ }
195
+ if (channel.FLAGS !== undefined && (channel.FLAGS & FLAG_VISIBLE) === 0) {
196
+ return 'invisible';
197
+ }
198
+ return undefined;
199
+ }
200
+ /**
201
+ * The MASTER paramsets {@link hiddenLinkChannels} needs to decide the mode rules: the maintenance
202
+ * channel of an HmIP-RGBW and of the glass switches, and every channel of a DALI gateway. Only
203
+ * for channels that take part in links at all; empty on an interface without such devices.
204
+ */
205
+ export function linkFilterMasters(index) {
206
+ const addresses = new Set();
207
+ for (const channel of index.channels()) {
208
+ if ((channel.LINK_SOURCE_ROLES ?? '') === '' && (channel.LINK_TARGET_ROLES ?? '') === '') {
209
+ continue;
210
+ }
211
+ const deviceType = deviceTypeOf(channel, index.parentOf(channel.ADDRESS));
212
+ if (deviceType === 'HMIP-RGBW' && channel.TYPE === 'UNIVERSAL_LIGHT_RECEIVER') {
213
+ addresses.add(maintenanceAddress(channel));
214
+ }
215
+ else if (WGS_DEVICES.has(deviceType) && channel.TYPE === 'KEY_TRANSCEIVER') {
216
+ addresses.add(maintenanceAddress(channel));
217
+ }
218
+ else if (deviceType === 'HMIP-DRG-DALI') {
219
+ addresses.add(channel.ADDRESS);
220
+ }
221
+ }
222
+ return [...addresses];
223
+ }
224
+ /**
225
+ * A pair the WebUI does not offer although the roles match: a radiator thermostat's own
226
+ * `CLIMATECONTROL_RT_RECEIVER` as the receiver of its own sender channel. The two halves of an
227
+ * HM-CC-RT-DN are meant for the same channels of *other* thermostats.
228
+ */
229
+ export function isSameDeviceClimatePair(sender, receiver) {
230
+ const senderDevice = tryParseAddress(sender.ADDRESS)?.device;
231
+ return (senderDevice !== undefined &&
232
+ senderDevice === tryParseAddress(receiver.ADDRESS)?.device &&
233
+ receiver.TYPE === 'CLIMATECONTROL_RT_RECEIVER');
234
+ }
235
+ //# sourceMappingURL=partnerFilter.js.map
@@ -39,4 +39,41 @@ export interface CastOptions {
39
39
  * the original does for datapoints whose description has not been fetched.
40
40
  */
41
41
  export declare function castValue(input: unknown, description?: ParameterDescription, options?: CastOptions): RpcWriteValue;
42
+ /**
43
+ * The decimals the interface processes print a double with: rfd's XML-RPC answers `0.500000`, and
44
+ * binrpc decodes every double with `toFixed(6)`. Anything finer is float residue, never a value a
45
+ * device holds.
46
+ */
47
+ export declare const FLOAT_WIRE_DECIMALS = 6;
48
+ /**
49
+ * The decimals a number is written with, residue removed first: `0.1` has one, `1.005` three,
50
+ * `30` none, and `0.30000000000000004` one, because twelve significant digits are all the
51
+ * comparison trusts (the WebUI's `toPrecision(12)` guard, OpenCCU-Base 3412ada).
52
+ */
53
+ export declare function decimalsOf(value: number): number;
54
+ /**
55
+ * The decimals of a parameter's range: the most that `MIN` or `MAX` carry, 0 when neither is a
56
+ * number. This is what the CCU's WebUI rounds a FLOAT to (`ProofAndSetValue`, OpenCCU-Base
57
+ * 3412ada) and what the editor derives its step from.
58
+ */
59
+ export declare function rangeDecimals(description: ParameterDescription): number;
60
+ /**
61
+ * The decimals a FLOAT is rounded to before it is compared or written: those of its range, but
62
+ * never fewer than {@link FLOAT_WIRE_DECIMALS}.
63
+ *
64
+ * The WebUI rounds to the range alone, and it can, because Tcl sees the bounds as the text the
65
+ * interface sent (`30.000000`). Here they arrive as numbers, and a bound of `30.0` is `30`: most
66
+ * FLOATs of the hm-simulator corpus have integer bounds while they hold halves (temperatures
67
+ * 5..30), twentieths (levels 0..1) or tenths (times 0..111600). Rounding those to the range would
68
+ * turn 21.5 °C into 22, so the range only ever adds decimals.
69
+ */
70
+ export declare function floatDecimals(description: ParameterDescription): number;
71
+ /**
72
+ * A FLOAT rounded to {@link floatDecimals}: `0.1 + 0.2` is `0.3` again, and `1.0049999999999999`
73
+ * is `1.005`. The scaled number goes through `toPrecision(15)` first, so a product that lands a
74
+ * bit below a half (`1.005 * 1000` is `1004.9999999999999`) still rounds the way it was written;
75
+ * fifteen digits rather than the WebUI's twelve, because a Wired time of 16383000 s scaled by
76
+ * 10**6 already has fourteen.
77
+ */
78
+ export declare function roundFloat(value: number, description: ParameterDescription): number;
42
79
  //# sourceMappingURL=cast.d.ts.map
@@ -65,7 +65,7 @@ export function castValue(input, description, options = {}) {
65
65
  case 'BOOL':
66
66
  return castBool(value);
67
67
  case 'FLOAT': {
68
- const number = clamp(finite(Number.parseFloat(String(value))), description, options);
68
+ const number = roundFloat(clamp(finite(Number.parseFloat(String(value))), description, options), description);
69
69
  return options.explicitDouble === false ? number : { explicitDouble: number };
70
70
  }
71
71
  case 'ENUM':
@@ -131,6 +131,66 @@ function castInteger(value, description, options) {
131
131
  function toInteger(value) {
132
132
  return finite(Number.parseInt(String(value), 10));
133
133
  }
134
+ /**
135
+ * The decimals the interface processes print a double with: rfd's XML-RPC answers `0.500000`, and
136
+ * binrpc decodes every double with `toFixed(6)`. Anything finer is float residue, never a value a
137
+ * device holds.
138
+ */
139
+ export const FLOAT_WIRE_DECIMALS = 6;
140
+ /**
141
+ * The decimals a number is written with, residue removed first: `0.1` has one, `1.005` three,
142
+ * `30` none, and `0.30000000000000004` one, because twelve significant digits are all the
143
+ * comparison trusts (the WebUI's `toPrecision(12)` guard, OpenCCU-Base 3412ada).
144
+ */
145
+ export function decimalsOf(value) {
146
+ if (!Number.isFinite(value)) {
147
+ return 0;
148
+ }
149
+ const text = String(Number.parseFloat(value.toPrecision(12)));
150
+ const exponent = /e([+-]\d+)$/.exec(text);
151
+ const mantissa = exponent ? text.slice(0, exponent.index) : text;
152
+ const point = mantissa.indexOf('.');
153
+ const fraction = point === -1 ? 0 : mantissa.length - point - 1;
154
+ return Math.max(0, fraction - (exponent ? Number(exponent[1]) : 0));
155
+ }
156
+ /**
157
+ * The decimals of a parameter's range: the most that `MIN` or `MAX` carry, 0 when neither is a
158
+ * number. This is what the CCU's WebUI rounds a FLOAT to (`ProofAndSetValue`, OpenCCU-Base
159
+ * 3412ada) and what the editor derives its step from.
160
+ */
161
+ export function rangeDecimals(description) {
162
+ const bounds = [description.MIN, description.MAX].filter((bound) => typeof bound === 'number');
163
+ return bounds.reduce((most, bound) => Math.max(most, decimalsOf(bound)), 0);
164
+ }
165
+ /**
166
+ * The decimals a FLOAT is rounded to before it is compared or written: those of its range, but
167
+ * never fewer than {@link FLOAT_WIRE_DECIMALS}.
168
+ *
169
+ * The WebUI rounds to the range alone, and it can, because Tcl sees the bounds as the text the
170
+ * interface sent (`30.000000`). Here they arrive as numbers, and a bound of `30.0` is `30`: most
171
+ * FLOATs of the hm-simulator corpus have integer bounds while they hold halves (temperatures
172
+ * 5..30), twentieths (levels 0..1) or tenths (times 0..111600). Rounding those to the range would
173
+ * turn 21.5 °C into 22, so the range only ever adds decimals.
174
+ */
175
+ export function floatDecimals(description) {
176
+ return Math.max(FLOAT_WIRE_DECIMALS, rangeDecimals(description));
177
+ }
178
+ /**
179
+ * A FLOAT rounded to {@link floatDecimals}: `0.1 + 0.2` is `0.3` again, and `1.0049999999999999`
180
+ * is `1.005`. The scaled number goes through `toPrecision(15)` first, so a product that lands a
181
+ * bit below a half (`1.005 * 1000` is `1004.9999999999999`) still rounds the way it was written;
182
+ * fifteen digits rather than the WebUI's twelve, because a Wired time of 16383000 s scaled by
183
+ * 10**6 already has fourteen.
184
+ */
185
+ export function roundFloat(value, description) {
186
+ if (!Number.isFinite(value)) {
187
+ return value;
188
+ }
189
+ const factor = 10 ** floatDecimals(description);
190
+ const rounded = Math.round(Number.parseFloat((value * factor).toPrecision(15))) / factor;
191
+ // `-0` is a number no interface wants to see and `Object.is` tells it from 0
192
+ return rounded === 0 ? 0 : rounded;
193
+ }
134
194
  /** No `NaN` and no `Infinity` ever leaves this module: both are unencodable in XML-RPC. */
135
195
  function finite(value) {
136
196
  return Number.isFinite(value) ? value : 0;
@@ -10,6 +10,11 @@
10
10
  * Here the default is the opposite: only parameters whose value actually changed, each cast and
11
11
  * validated, and never a parameter that is unknown, read-only or out of range. `writeAll` is the
12
12
  * explicit opt-out the dialog offers (roadmap task 6.1).
13
+ *
14
+ * Link paramsets are the exception, and `full` is their mode: the CCU's WebUI went back to sending
15
+ * every link parameter in 2026 after "only the dirty ones" had lost settings in the field (a link's
16
+ * on-time changed and its brightness thresholds were back at their defaults). A `full` payload is
17
+ * every writable parameter with the value that was read, the edits on top - never a `DEFAULT`.
13
18
  */
14
19
  import { type EnumEncoding } from './cast.js';
15
20
  import { type ParamsetDescription } from './description.js';
@@ -18,6 +23,14 @@ import { type Paramset, type ParamsetWrite } from '../rpc/values.js';
18
23
  export interface DiffOptions {
19
24
  /** Send every writable parameter instead of only the changed ones. Off by default. */
20
25
  readonly writeAll?: boolean;
26
+ /**
27
+ * The whole paramset as it stands: every writable parameter with the value read from the
28
+ * device, the edited ones with their new value. Unlike `writeAll` it never falls back to the
29
+ * `DEFAULT` (A-14) - a parameter that was neither read nor edited is left out - and a stored
30
+ * value that does not validate is left out too instead of failing a write the user did not make.
31
+ * Wins over `writeAll`.
32
+ */
33
+ readonly full?: boolean;
21
34
  /** How to encode `ENUM`; see `enumEncodingFor(interfaceName)`. */
22
35
  readonly enumAs?: EnumEncoding;
23
36
  /** Passed to the validation. */
@@ -31,6 +44,8 @@ export type SkipReason =
31
44
  | 'not-writable'
32
45
  /** The description does not have it. */
33
46
  | 'unknown-parameter'
47
+ /** `full`: neither read from the device nor edited, so there is no value to send. */
48
+ | 'unread'
34
49
  /** It failed validation; the reason is in `problems`. */
35
50
  | 'invalid';
36
51
  export interface SkippedParameter {
@@ -10,6 +10,11 @@
10
10
  * Here the default is the opposite: only parameters whose value actually changed, each cast and
11
11
  * validated, and never a parameter that is unknown, read-only or out of range. `writeAll` is the
12
12
  * explicit opt-out the dialog offers (roadmap task 6.1).
13
+ *
14
+ * Link paramsets are the exception, and `full` is their mode: the CCU's WebUI went back to sending
15
+ * every link parameter in 2026 after "only the dirty ones" had lost settings in the field (a link's
16
+ * on-time changed and its brightness thresholds were back at their defaults). A `full` payload is
17
+ * every writable parameter with the value that was read, the edits on top - never a `DEFAULT`.
13
18
  */
14
19
  import { castValue } from './cast.js';
15
20
  import { isWritable } from './description.js';
@@ -28,7 +33,8 @@ export function diffParamset(original, edited, description, options = {}) {
28
33
  const changed = [];
29
34
  const skipped = [];
30
35
  const problems = [];
31
- const writeAll = options.writeAll === true;
36
+ const full = options.full === true;
37
+ const writeAll = full || options.writeAll === true;
32
38
  const castOptions = options.enumAs === undefined ? {} : { enumAs: options.enumAs };
33
39
  const validateOptions = options.maxStringLength === undefined ? {} : { maxStringLength: options.maxStringLength };
34
40
  for (const param of candidates(edited, description, writeAll)) {
@@ -48,6 +54,10 @@ export function diffParamset(original, edited, description, options = {}) {
48
54
  skipped.push({ param, reason: 'not-writable' });
49
55
  continue;
50
56
  }
57
+ if (full && !wasEdited && !Object.prototype.hasOwnProperty.call(original, param)) {
58
+ skipped.push({ param, reason: 'unread' });
59
+ continue;
60
+ }
51
61
  const raw = wasEdited ? edited[param] : (original[param] ?? parameter.DEFAULT);
52
62
  const value = castValue(raw, parameter, castOptions);
53
63
  if (!writeAll && isUnchanged(original, param, raw, parameter, castOptions)) {
@@ -56,7 +66,11 @@ export function diffParamset(original, edited, description, options = {}) {
56
66
  }
57
67
  const found = validateValue(param, value, parameter, validateOptions);
58
68
  if (found.length > 0) {
59
- problems.push(...found);
69
+ // a stored value the description does not allow is the device's business, not a mistake
70
+ // in this write: `full` leaves it where it is
71
+ if (!full || wasEdited) {
72
+ problems.push(...found);
73
+ }
60
74
  skipped.push({ param, reason: 'invalid' });
61
75
  continue;
62
76
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The switching thresholds of the HmIP power meters, in watts (task 110).
3
+ *
4
+ * `COND_TX_THRESHOLD_LO` and `_HI` of a measuring actuator's `COND_SWITCH_TRANSMITTER` channel are
5
+ * INTEGERs `0..16777215` in hundredths of a watt, without a unit: a threshold of 100 W is stored as
6
+ * 10000. The CCU's WebUI shows them divided by 100 as watts with two decimals, capped at what the
7
+ * device can switch, and writes `Math.round(W * 100)` back (`getCondSwitchTransmitter` in
8
+ * `hmipChannelConfigDialogs.tcl`, `devIsPowerMeter` in `hmip_helper.tcl`, `getUserDefinedMaxValue`
9
+ * in `uiElements.tcl`; OpenCCU-Base 949e204, 3412ada, 2466de4). Without that a user reads "10000"
10
+ * and the range `0 … 16777215` and has to know the unit.
11
+ */
12
+ /** The parameters the WebUI shows in watts on a power meter. */
13
+ export declare const POWER_THRESHOLD_PARAMETERS: ReadonlySet<string>;
14
+ /**
15
+ * The most a power meter can switch, in watts, by device type in lower case - `devIsPowerMeter`'s
16
+ * list with `getUserDefinedMaxValue`'s caps. A type that is not here is not a power meter, and its
17
+ * thresholds stay as the interface describes them.
18
+ */
19
+ export declare const POWER_METER_MAX_WATTS: Readonly<Record<string, number>>;
20
+ /** Stored value × factor = watts. */
21
+ export declare const POWER_THRESHOLD_FACTOR = 0.01;
22
+ /** How a power threshold is shown and entered. */
23
+ export interface PowerThresholdScale {
24
+ /** Stored value × factor = displayed value. */
25
+ readonly factor: number;
26
+ readonly unit: 'W';
27
+ /** In watts. */
28
+ readonly min: number;
29
+ /** In watts: what the device can switch. */
30
+ readonly max: number;
31
+ /** The WebUI's two decimals. */
32
+ readonly step: number;
33
+ }
34
+ /**
35
+ * The watt scale of a parameter, or `undefined` when it is not a power meter's threshold. The device
36
+ * type is matched without regard to case: hmipserver reports `HMIP-PSM` for older units and
37
+ * `HmIP-PSM` for newer ones, and the WebUI lower-cases it too.
38
+ */
39
+ export declare function powerThresholdScale(deviceType: string | undefined, param: string): PowerThresholdScale | undefined;
40
+ //# sourceMappingURL=powerMeter.d.ts.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The switching thresholds of the HmIP power meters, in watts (task 110).
3
+ *
4
+ * `COND_TX_THRESHOLD_LO` and `_HI` of a measuring actuator's `COND_SWITCH_TRANSMITTER` channel are
5
+ * INTEGERs `0..16777215` in hundredths of a watt, without a unit: a threshold of 100 W is stored as
6
+ * 10000. The CCU's WebUI shows them divided by 100 as watts with two decimals, capped at what the
7
+ * device can switch, and writes `Math.round(W * 100)` back (`getCondSwitchTransmitter` in
8
+ * `hmipChannelConfigDialogs.tcl`, `devIsPowerMeter` in `hmip_helper.tcl`, `getUserDefinedMaxValue`
9
+ * in `uiElements.tcl`; OpenCCU-Base 949e204, 3412ada, 2466de4). Without that a user reads "10000"
10
+ * and the range `0 … 16777215` and has to know the unit.
11
+ */
12
+ /** The parameters the WebUI shows in watts on a power meter. */
13
+ export const POWER_THRESHOLD_PARAMETERS = new Set([
14
+ 'COND_TX_THRESHOLD_LO',
15
+ 'COND_TX_THRESHOLD_HI',
16
+ ]);
17
+ /**
18
+ * The most a power meter can switch, in watts, by device type in lower case - `devIsPowerMeter`'s
19
+ * list with `getUserDefinedMaxValue`'s caps. A type that is not here is not a power meter, and its
20
+ * thresholds stay as the interface describes them.
21
+ */
22
+ export const POWER_METER_MAX_WATTS = {
23
+ 'hmip-psm': 3680,
24
+ 'hmip-psmco': 3680,
25
+ 'elv-sh-psmci': 3680,
26
+ 'hmip-fsm16': 3680,
27
+ 'hmip-psm-2': 3000,
28
+ 'hmip-psm-2 qhj': 3000,
29
+ 'hmip-bsm': 1150,
30
+ 'hmip-fsm': 1150,
31
+ 'hmip-usbsm': 60,
32
+ };
33
+ /** Stored value × factor = watts. */
34
+ export const POWER_THRESHOLD_FACTOR = 0.01;
35
+ /**
36
+ * The watt scale of a parameter, or `undefined` when it is not a power meter's threshold. The device
37
+ * type is matched without regard to case: hmipserver reports `HMIP-PSM` for older units and
38
+ * `HmIP-PSM` for newer ones, and the WebUI lower-cases it too.
39
+ */
40
+ export function powerThresholdScale(deviceType, param) {
41
+ if (deviceType === undefined || !POWER_THRESHOLD_PARAMETERS.has(param)) {
42
+ return undefined;
43
+ }
44
+ const max = POWER_METER_MAX_WATTS[deviceType.toLowerCase()];
45
+ return max === undefined ? undefined : { factor: POWER_THRESHOLD_FACTOR, unit: 'W', min: 0, max, step: 0.01 };
46
+ }
47
+ //# sourceMappingURL=powerMeter.js.map
@@ -36,6 +36,17 @@ export declare function displayFactor(description: ParameterDescription | undefi
36
36
  export declare function toDisplayValue(value: number | undefined, description: ParameterDescription | undefined): number | undefined;
37
37
  /** Displayed value -> stored value, the inverse of {@link toDisplayValue}. */
38
38
  export declare function fromDisplayValue(value: number | undefined, description: ParameterDescription | undefined): number | undefined;
39
+ /**
40
+ * Stored value -> displayed value for a field with a scale of its own, not its `UNIT`'s - a power
41
+ * meter's thresholds in hundredths of a watt shown in watts (task 110).
42
+ */
43
+ export declare function toScaledDisplay(value: number | undefined, factor: number): number | undefined;
44
+ /**
45
+ * Displayed value -> stored value, the inverse of {@link toScaledDisplay}. An INTEGER parameter is
46
+ * rounded to the nearest whole number, as the WebUI's `Math.round(W * 100)` does; truncating
47
+ * would turn 12.34 W (1233.9999… after the division) into 1233.
48
+ */
49
+ export declare function fromScaledDisplay(value: number | undefined, factor: number, integer: boolean): number | undefined;
39
50
  /** `MIN`/`MAX` in display units, so a spin box can use them directly. */
40
51
  export declare function displayBounds(description: ParameterDescription): {
41
52
  min?: number;
@@ -62,6 +62,25 @@ export function fromDisplayValue(value, description) {
62
62
  }
63
63
  return roundScaled(value / displayFactor(description));
64
64
  }
65
+ /**
66
+ * Stored value -> displayed value for a field with a scale of its own, not its `UNIT`'s - a power
67
+ * meter's thresholds in hundredths of a watt shown in watts (task 110).
68
+ */
69
+ export function toScaledDisplay(value, factor) {
70
+ return value === undefined ? undefined : roundScaled(value * factor);
71
+ }
72
+ /**
73
+ * Displayed value -> stored value, the inverse of {@link toScaledDisplay}. An INTEGER parameter is
74
+ * rounded to the nearest whole number, as the WebUI's `Math.round(W * 100)` does; truncating
75
+ * would turn 12.34 W (1233.9999… after the division) into 1233.
76
+ */
77
+ export function fromScaledDisplay(value, factor, integer) {
78
+ if (value === undefined) {
79
+ return undefined;
80
+ }
81
+ const stored = roundScaled(value / factor);
82
+ return integer && Number.isFinite(stored) ? Math.round(stored) : stored;
83
+ }
65
84
  /** `MIN`/`MAX` in display units, so a spin box can use them directly. */
66
85
  export function displayBounds(description) {
67
86
  const min = toDisplayValue(numericBound(description, 'MIN'), description);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homematic-manager/core",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
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.4.2",
3
+ "version": "3.5.0",
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.4.2",
71
- "@homematic-manager/core": "3.4.2",
70
+ "@homematic-manager/backend": "3.5.0",
71
+ "@homematic-manager/core": "3.5.0",
72
72
  "binrpc": "^4.2.0",
73
73
  "homematic-rega": "^2.0.0",
74
74
  "homematic-xmlrpc": "^2.0.0",