Skip to content

Commit 34f1b61

Browse files
committed
chore: LiXee ZLinky: move cluster definition to ZHC
Also improve logs.
1 parent f963b91 commit 34f1b61

File tree

1 file changed

+67
-9
lines changed

1 file changed

+67
-9
lines changed

src/devices/lixee.ts

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Buffer} from "node:buffer";
2+
import {Zcl} from "zigbee-herdsman";
23
import type {TPartialClusterAttributes} from "zigbee-herdsman/dist/zspec/zcl/definition/clusters-types";
34
import * as fz from "../converters/fromZigbee";
45
import {repInterval} from "../lib/constants";
@@ -13,6 +14,61 @@ const ea = exposes.access;
1314
const e = exposes.presets;
1415

1516
const NS = "zhc:lixee";
17+
18+
const local = {
19+
modernExtend: {
20+
addCustomClusterManuSpecificLixee: () =>
21+
m.deviceAddCustomCluster("liXeeCustom", {
22+
ID: 0xff66,
23+
manufacturerCode: Zcl.ManufacturerCode.NXP_SEMICONDUCTORS,
24+
attributes: {
25+
currentTarif: {ID: 0x0000, type: Zcl.DataType.CHAR_STR},
26+
tomorrowColor: {ID: 0x0001, type: Zcl.DataType.CHAR_STR},
27+
scheduleHPHC: {ID: 0x0002, type: Zcl.DataType.UINT8},
28+
presencePotential: {ID: 0x0003, type: Zcl.DataType.UINT8},
29+
startNoticeEJP: {ID: 0x0004, type: Zcl.DataType.UINT8},
30+
warnDPS: {ID: 0x0005, type: Zcl.DataType.UINT16},
31+
warnDIR1: {ID: 0x0006, type: Zcl.DataType.UINT16},
32+
warnDIR2: {ID: 0x0007, type: Zcl.DataType.UINT16},
33+
warnDIR3: {ID: 0x0008, type: Zcl.DataType.UINT16},
34+
motDEtat: {ID: 0x0009, type: Zcl.DataType.CHAR_STR},
35+
currentPrice: {ID: 0x0200, type: Zcl.DataType.CHAR_STR},
36+
currentIndexTarif: {ID: 0x0201, type: Zcl.DataType.UINT8},
37+
currentDate: {ID: 0x0202, type: Zcl.DataType.CHAR_STR},
38+
activeEnergyOutD01: {ID: 0x0203, type: Zcl.DataType.UINT32},
39+
activeEnergyOutD02: {ID: 0x0204, type: Zcl.DataType.UINT32},
40+
activeEnergyOutD03: {ID: 0x0205, type: Zcl.DataType.UINT32},
41+
activeEnergyOutD04: {ID: 0x0206, type: Zcl.DataType.UINT32},
42+
injectedVA: {ID: 0x0207, type: Zcl.DataType.UINT16},
43+
injectedVAMaxN: {ID: 0x0208, type: Zcl.DataType.INT16},
44+
injectedVAMaxN1: {ID: 0x0209, type: Zcl.DataType.INT16},
45+
injectedActiveLoadN: {ID: 0x0210, type: Zcl.DataType.INT16},
46+
injectedActiveLoadN1: {ID: 0x0211, type: Zcl.DataType.INT16},
47+
drawnVAMaxN1: {ID: 0x0212, type: Zcl.DataType.INT16},
48+
drawnVAMaxN1P2: {ID: 0x0213, type: Zcl.DataType.INT16},
49+
drawnVAMaxN1P3: {ID: 0x0214, type: Zcl.DataType.INT16},
50+
message1: {ID: 0x0215, type: Zcl.DataType.CHAR_STR},
51+
message2: {ID: 0x0216, type: Zcl.DataType.CHAR_STR},
52+
statusRegister: {ID: 0x0217, type: Zcl.DataType.OCTET_STR},
53+
startMobilePoint1: {ID: 0x0218, type: Zcl.DataType.UINT8},
54+
stopMobilePoint1: {ID: 0x0219, type: Zcl.DataType.UINT8},
55+
startMobilePoint2: {ID: 0x0220, type: Zcl.DataType.UINT8},
56+
stopMobilePoint2: {ID: 0x0221, type: Zcl.DataType.UINT8},
57+
startMobilePoint3: {ID: 0x0222, type: Zcl.DataType.UINT8},
58+
stopMobilePoint3: {ID: 0x0223, type: Zcl.DataType.UINT8},
59+
relais: {ID: 0x0224, type: Zcl.DataType.UINT16},
60+
daysNumberCurrentCalendar: {ID: 0x0225, type: Zcl.DataType.UINT8},
61+
daysNumberNextCalendar: {ID: 0x0226, type: Zcl.DataType.UINT8},
62+
daysProfileCurrentCalendar: {ID: 0x0227, type: Zcl.DataType.LONG_OCTET_STR},
63+
daysProfileNextCalendar: {ID: 0x0228, type: Zcl.DataType.LONG_OCTET_STR},
64+
linkyMode: {ID: 0x0300, type: Zcl.DataType.UINT8},
65+
},
66+
commands: {},
67+
commandsResponse: {},
68+
}),
69+
},
70+
};
71+
1672
/* Start ZiPulses */
1773

1874
const unitsZiPulses = [
@@ -125,7 +181,7 @@ const fzLocal = {
125181
},
126182
} satisfies Fz.Converter<"haElectricalMeasurement", undefined, ["attributeReport", "readResponse"]>,
127183
lixee_private_fz: {
128-
cluster: "liXeePrivate", // 0xFF66
184+
cluster: "liXeeCustom", // 0xFF66
129185
type: ["attributeReport", "readResponse"],
130186
convert: (model, msg, publish, options, meta) => {
131187
const result: KeyValue = {};
@@ -362,7 +418,7 @@ const fzLocal = {
362418
}
363419
return result;
364420
},
365-
} satisfies Fz.Converter<"liXeePrivate", undefined, ["attributeReport", "readResponse"]>,
421+
} satisfies Fz.Converter<"liXeeCustom", undefined, ["attributeReport", "readResponse"]>,
366422
lixee_metering: {
367423
cluster: "seMetering", // 0x0702
368424
type: ["attributeReport", "readResponse"],
@@ -671,7 +727,7 @@ const linkyPhaseDef = {
671727

672728
const clustersDef = {
673729
// biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
674-
_0xFF66: "liXeePrivate", // 0xFF66
730+
_0xFF66: "liXeeCustom", // 0xFF66
675731
// biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
676732
_0x0B04: "haElectricalMeasurement", // 0x0B04
677733
// biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
@@ -1820,12 +1876,12 @@ export const definitions: DefinitionWithExtend[] = [
18201876
clustersDef._0x0702 /* seMetering */,
18211877
clustersDef._0x0B01 /* haMeterIdentification */,
18221878
clustersDef._0x0B04 /* haElectricalMeasurement */,
1823-
clustersDef._0xFF66 /* liXeePrivate */,
1879+
clustersDef._0xFF66 /* liXeeCustom */,
18241880
]);
18251881

1826-
await endpoint.read("liXeePrivate", ["linkyMode", "currentTarif"], {manufacturerCode: null}).catch((e) => {
1882+
await endpoint.read("liXeeCustom", ["linkyMode", "currentTarif"], {manufacturerCode: null}).catch((e) => {
18271883
// https://github.com/Koenkk/zigbee2mqtt/issues/11674
1828-
logger.warning(`Failed to read zigbee attributes: ${e}`, NS);
1884+
logger.warning(`Failed to read zigbee attributes during configure: ${e}`, NS);
18291885
});
18301886

18311887
const configReportings = [];
@@ -1894,6 +1950,7 @@ export const definitions: DefinitionWithExtend[] = [
18941950
},
18951951
ota: {manufacturerName: "LiXee"}, // TODO: not sure if it's set properly in device
18961952
extend: [
1953+
local.modernExtend.addCustomClusterManuSpecificLixee(),
18971954
m.poll({
18981955
key: "measurement",
18991956
defaultIntervalSeconds: 600,
@@ -1918,13 +1975,14 @@ export const definitions: DefinitionWithExtend[] = [
19181975
const cluster = clustersDef[key];
19191976
const targ = currentExposes.filter((e) => e.cluster === cluster).map((e) => e.att);
19201977
if (targ.length) {
1978+
logger.debug(`Poll: trying to read from ${cluster}: ${targ}`, NS);
19211979
let i: number;
19221980
let j: number;
19231981
// Split array by chunks
19241982
for (i = 0, j = targ.length; i < j; i += measurement_poll_chunk) {
19251983
await endpoint.read(cluster, targ.slice(i, i + measurement_poll_chunk), {manufacturerCode: null}).catch((e) => {
19261984
// https://github.com/Koenkk/zigbee2mqtt/issues/11674
1927-
logger.warning(`Failed to read zigbee attributes: ${e}`, NS);
1985+
logger.warning(`Failed to read zigbee attributes during poll: ${e}`, NS);
19281986
});
19291987
}
19301988
}
@@ -1938,10 +1996,10 @@ export const definitions: DefinitionWithExtend[] = [
19381996
if (event.type === "start") {
19391997
event.data.device
19401998
.getEndpoint(1)
1941-
.read("liXeePrivate", ["linkyMode", "currentTarif"], {manufacturerCode: null})
1999+
.read("liXeeCustom", ["linkyMode", "currentTarif"], {manufacturerCode: null})
19422000
.catch((e) => {
19432001
// https://github.com/Koenkk/zigbee2mqtt/issues/11674
1944-
logger.warning(`Failed to read zigbee attributes: ${e}`, NS);
2002+
logger.warning(`Failed to read zigbee attributes during startup: ${e}`, NS);
19452003
});
19462004
}
19472005
},

0 commit comments

Comments
 (0)