node-red-contrib-ccu 4.10.2 → 4.10.3
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/CHANGELOG.md +15 -0
- package/nodes/ccu-homeassistant.js +1 -0
- package/nodes/lib/hadiscovery.js +29 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ Notable changes to node-red-contrib-ccu. Format follows
|
|
|
5
5
|
user-visible symptom and the cause, not the commit list (the release notes
|
|
6
6
|
append commits automatically).
|
|
7
7
|
|
|
8
|
+
## 4.10.3 (2026-11-20)
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **ccu-homeassistant: a closed cover could show "open" at position 0 in
|
|
13
|
+
Home Assistant (and one opened from 0 "closed").** The cover's state came
|
|
14
|
+
from the DIRECTION/ACTIVITY_STATE message, which says "stopped" before the
|
|
15
|
+
final LEVEL arrives; Home Assistant then fixed open/closed from the stale
|
|
16
|
+
position and ignored the later one. The state now comes from the LEVEL
|
|
17
|
+
message itself, which carries working, direction and the position
|
|
18
|
+
together. With ccu-mqtt's mqsh-basic or plain payloads the cover gets no
|
|
19
|
+
state topic and Home Assistant derives open/closed from the position. Home
|
|
20
|
+
Assistant picks up the changed discovery on the next deploy
|
|
21
|
+
(hobbyquaker/hm2mqtt.js#35, @sgybas).
|
|
22
|
+
|
|
8
23
|
## 4.10.2 (2026-11-20)
|
|
9
24
|
|
|
10
25
|
### Fixed
|
|
@@ -226,6 +226,7 @@ module.exports = function (RED) {
|
|
|
226
226
|
prefix: this.prefix,
|
|
227
227
|
origin: {name: pkg.name, sw: pkg.version, url: pkg.homepage},
|
|
228
228
|
jsonPayloads: mqtt.payloadOutput !== 'plain',
|
|
229
|
+
hmPayload: mqtt.payloadOutput === 'mqsh-extended',
|
|
229
230
|
generic: this.generic,
|
|
230
231
|
area: this.area,
|
|
231
232
|
devices: ccu.metadata.devices,
|
package/nodes/lib/hadiscovery.js
CHANGED
|
@@ -162,6 +162,7 @@ const BINARY_ONLY_CLASSES = new Set([
|
|
|
162
162
|
* @property {string} [prefix] discovery prefix (default homeassistant)
|
|
163
163
|
* @property {{name: string, sw: string, url?: string}} origin the `o` block (package name/version/url)
|
|
164
164
|
* @property {boolean} [jsonPayloads] status payloads are {val, ts, lc} (ccu-mqtt mqsh-*), false = plain
|
|
165
|
+
* @property {boolean} [hmPayload] the payloads carry the `hm` block (ccu-mqtt mqsh-extended; default: jsonPayloads)
|
|
165
166
|
* @property {boolean} [generic] generic entities for datapoints without a role (default true)
|
|
166
167
|
* @property {Object<string, Object<string, object>>} devices metadata.devices (iface → address → device)
|
|
167
168
|
* @property {string[]} selected device addresses to publish
|
|
@@ -174,6 +175,18 @@ const BINARY_ONLY_CLASSES = new Set([
|
|
|
174
175
|
* @property {(iface: string, address: string, datapoint: string) => string} setTopicFor
|
|
175
176
|
*/
|
|
176
177
|
|
|
178
|
+
/**
|
|
179
|
+
* A cover's state from its LEVEL message in ccu-mqtt's mqsh-extended format: `hm.working` and
|
|
180
|
+
* `hm.direction` (1 up, 2 down; ACTIVITY_STATE mapped onto DIRECTION) say whether it moves, the
|
|
181
|
+
* value whether it is closed. Closed is what Home Assistant calls closed without a state topic:
|
|
182
|
+
* the position, rounded to a percent, is 0.
|
|
183
|
+
*/
|
|
184
|
+
const COVER_STATE_TEMPLATE =
|
|
185
|
+
'{% set hm = value_json.hm | default({}) %}' +
|
|
186
|
+
'{% set d = (hm.direction | default(0) | int(0)) if hm.working | default(false) else 0 %}' +
|
|
187
|
+
"{{ 'opening' if d == 1 else 'closing' if d == 2 else" +
|
|
188
|
+
" 'closed' if ((value_json.val | float(0)) * 100) | round == 0 else 'open' }}";
|
|
189
|
+
|
|
177
190
|
/** Stable device/unique-id base: ccu_<address>, sanitised. */
|
|
178
191
|
function discoveryId(address) {
|
|
179
192
|
return 'ccu_' + String(address).replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
@@ -338,6 +351,7 @@ function suggestedArea(roomsOf, deviceAddress, channels) {
|
|
|
338
351
|
*/
|
|
339
352
|
function deviceBlock(ctx, iface, device) {
|
|
340
353
|
const json = ctx.jsonPayloads !== false;
|
|
354
|
+
const hm = json && ctx.hmPayload !== false;
|
|
341
355
|
const generic = ctx.generic !== false;
|
|
342
356
|
const t = templates(json);
|
|
343
357
|
const list = ctx.devices[iface];
|
|
@@ -498,11 +512,6 @@ function deviceBlock(ctx, iface, device) {
|
|
|
498
512
|
case 'cover': {
|
|
499
513
|
if (has('LEVEL')) {
|
|
500
514
|
const tilt = has('LEVEL_2');
|
|
501
|
-
const direction = stateCh.description.ACTIVITY_STATE
|
|
502
|
-
? 'ACTIVITY_STATE'
|
|
503
|
-
: stateCh.description.DIRECTION
|
|
504
|
-
? 'DIRECTION'
|
|
505
|
-
: null;
|
|
506
515
|
add(
|
|
507
516
|
key('LEVEL'),
|
|
508
517
|
e('LEVEL', 'cover', label, {
|
|
@@ -520,12 +529,22 @@ function deviceBlock(ctx, iface, device) {
|
|
|
520
529
|
set_pos_tpl: '{{ (position / 100) | round(3) }}',
|
|
521
530
|
pos_open: 100,
|
|
522
531
|
pos_clsd: 0,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
532
|
+
// The state comes from the LEVEL message alone, which says in its
|
|
533
|
+
// hm block whether and where the cover is moving: every message is
|
|
534
|
+
// a whole state. A state topic that only says moving/stopped makes
|
|
535
|
+
// Home Assistant decide between open and closed from the position
|
|
536
|
+
// it has at that moment, and the 'stopped' of ACTIVITY_STATE/
|
|
537
|
+
// DIRECTION is published before the last LEVEL (which waits for
|
|
538
|
+
// WORKING, ccu-connection's publishEvent) - a closed cover stayed
|
|
539
|
+
// 'open' (hm2mqtt.js #35). Without the hm block there is no state
|
|
540
|
+
// topic: Home Assistant then takes open/closed from the position.
|
|
541
|
+
...(hm && {
|
|
542
|
+
stat_t: sst('LEVEL'),
|
|
543
|
+
val_tpl: COVER_STATE_TEMPLATE,
|
|
544
|
+
stat_open: 'open',
|
|
545
|
+
stat_clsd: 'closed',
|
|
526
546
|
stat_opening: 'opening',
|
|
527
547
|
stat_closing: 'closing',
|
|
528
|
-
stat_stopped: 'stopped',
|
|
529
548
|
}),
|
|
530
549
|
...(tilt && {
|
|
531
550
|
tilt_cmd_t: scmd('LEVEL_2'),
|
|
@@ -1001,6 +1020,7 @@ function discoveryMessages(ctx) {
|
|
|
1001
1020
|
}
|
|
1002
1021
|
|
|
1003
1022
|
module.exports = {
|
|
1023
|
+
COVER_STATE_TEMPLATE,
|
|
1004
1024
|
DEVICE_CLASSES,
|
|
1005
1025
|
NOT_ANNOUNCED,
|
|
1006
1026
|
validDeviceClass,
|