Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 67 additions & 12 deletions src/devices/candeo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const ea = exposes.access;
const manufacturerSpecificSwitchTypeClusterCode = 0x1224;
const manufacturerSpecificRotaryRemoteControlClusterCode = 0xff03;
const switchTypeAttribute = 0x8803;
const dataType = 0x20;
const valueMap: {[key: number]: string} = {
const switchTypeDataType = 0x20;
const switchTypeValueMap: {[key: number]: string} = {
0: "momentary",
1: "toggle",
};
const valueLookup: {[key: string]: number} = {
const switchTypeValueLookup: {[key: string]: number} = {
momentary: 0,
toggle: 1,
};
Expand Down Expand Up @@ -45,7 +45,7 @@ const fzLocal = {
if (Object.hasOwn(msg.data, switchTypeAttribute)) {
const value = msg.data[switchTypeAttribute];
return {
external_switch_type: valueMap[value] || "unknown",
external_switch_type: switchTypeValueMap[value] || "unknown",
external_switch_type_numeric: value,
};
}
Expand Down Expand Up @@ -147,10 +147,10 @@ const tzLocal = {
key: ["external_switch_type"],
convertSet: async (entity, key, value, meta) => {
utils.assertString(value);
const numericValue = valueLookup[value] ?? Number.parseInt(value, 10);
const numericValue = switchTypeValueLookup[value] ?? Number.parseInt(value, 10);
await entity.write(
"genBasic",
{[switchTypeAttribute]: {value: numericValue, type: dataType}},
{[switchTypeAttribute]: {value: numericValue, type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
return {state: {external_switch_type: value}};
Expand All @@ -175,6 +175,11 @@ export const definitions: DefinitionWithExtend[] = [
const endpoint1 = device.getEndpoint(1);
await endpoint1.write("genOnOff", {16387: {value: 0xff, type: 0x30}});
await endpoint1.read("genOnOff", ["startUpOnOff"]);
await endpoint1.write(
"genBasic",
{[switchTypeAttribute]: {value: switchTypeValueLookup["toggle"], type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
await endpoint1.read("genBasic", [switchTypeAttribute], {manufacturerCode: manufacturerSpecificSwitchTypeClusterCode});
},
},
Expand Down Expand Up @@ -202,8 +207,17 @@ export const definitions: DefinitionWithExtend[] = [
vendor: "Candeo",
description: "Zigbee micro smart dimmer",
extend: [
m.light({configureReporting: true, levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]}}),
m.electricityMeter(),
m.light({
configureReporting: true,
levelReportingConfig: {min: 1, max: 3600, change: 1},
levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]},
}),
m.electricityMeter({
power: {min: 10, max: 600, change: 50},
voltage: {min: 10, max: 600, change: 500},
current: {min: 10, max: 600, change: 500},
energy: {min: 10, max: 1800, change: 360000},
}),
],
fromZigbee: [fzLocal.switch_type, fz.ignore_genOta],
toZigbee: [tzLocal.switch_type],
Expand All @@ -218,6 +232,11 @@ export const definitions: DefinitionWithExtend[] = [
await endpoint1.read("genLevelCtrl", ["onOffTransitionTime"]);
await endpoint1.write("genLevelCtrl", {16384: {value: 0xff, type: 0x20}});
await endpoint1.read("genLevelCtrl", ["startUpCurrentLevel"]);
await endpoint1.write(
"genBasic",
{[switchTypeAttribute]: {value: switchTypeValueLookup["momentary"], type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
await endpoint1.read("genBasic", [switchTypeAttribute], {manufacturerCode: manufacturerSpecificSwitchTypeClusterCode});
},
},
Expand All @@ -227,8 +246,17 @@ export const definitions: DefinitionWithExtend[] = [
vendor: "Candeo",
description: "Zigbee micro smart dimmer",
extend: [
m.light({configureReporting: true, levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]}}),
m.electricityMeter(),
m.light({
configureReporting: true,
levelReportingConfig: {min: 1, max: 3600, change: 1},
levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]},
}),
m.electricityMeter({
power: {min: 10, max: 600, change: 50},
voltage: {min: 10, max: 600, change: 500},
current: {min: 10, max: 600, change: 500},
energy: {min: 10, max: 1800, change: 360000},
}),
],
fromZigbee: [fzLocal.switch_type, fz.ignore_genOta],
toZigbee: [tzLocal.switch_type],
Expand All @@ -243,6 +271,11 @@ export const definitions: DefinitionWithExtend[] = [
await endpoint1.read("genLevelCtrl", ["onOffTransitionTime"]);
await endpoint1.write("genLevelCtrl", {16384: {value: 0xff, type: 0x20}});
await endpoint1.read("genLevelCtrl", ["startUpCurrentLevel"]);
await endpoint1.write(
"genBasic",
{[switchTypeAttribute]: {value: switchTypeValueLookup["momentary"], type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
await endpoint1.read("genBasic", [switchTypeAttribute], {manufacturerCode: manufacturerSpecificSwitchTypeClusterCode});
},
},
Expand All @@ -258,6 +291,7 @@ export const definitions: DefinitionWithExtend[] = [
extend: [
m.light({
configureReporting: true,
levelReportingConfig: {min: 1, max: 3600, change: 1},
levelConfig: {features: ["on_level", "current_level_startup"]},
powerOnBehavior: true,
}),
Expand Down Expand Up @@ -373,7 +407,12 @@ export const definitions: DefinitionWithExtend[] = [
multiEndpointSkip: ["power", "current", "voltage", "energy"],
}),
m.onOff({endpointNames: ["l1", "l2"]}),
m.electricityMeter(),
m.electricityMeter({
power: {min: 10, max: 600, change: 50},
voltage: {min: 10, max: 600, change: 500},
current: {min: 10, max: 600, change: 500},
energy: {min: 10, max: 1800, change: 360000},
}),
],
fromZigbee: [fzLocal.switch_type, fz.ignore_genOta],
toZigbee: [tzLocal.switch_type],
Expand All @@ -387,6 +426,11 @@ export const definitions: DefinitionWithExtend[] = [
await endpoint2.write("genOnOff", {16387: {value: 0xff, type: 0x30}});
await endpoint2.read("genOnOff", [16387]);
const endpoint11 = device.getEndpoint(11);
await endpoint1.write(
"genBasic",
{[switchTypeAttribute]: {value: switchTypeValueLookup["toggle"], type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
await endpoint11.read("genBasic", [switchTypeAttribute], {manufacturerCode: manufacturerSpecificSwitchTypeClusterCode});
},
},
Expand All @@ -405,7 +449,13 @@ export const definitions: DefinitionWithExtend[] = [
model: "C203",
vendor: "Candeo",
description: "Zigbee micro smart dimmer",
extend: [m.light({configureReporting: true, levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]}})],
extend: [
m.light({
configureReporting: true,
levelReportingConfig: {min: 1, max: 3600, change: 1},
levelConfig: {features: ["on_off_transition_time", "on_level", "current_level_startup"]},
}),
],
fromZigbee: [fzLocal.switch_type, fz.ignore_genOta],
toZigbee: [tzLocal.switch_type],
exposes: [e.enum("external_switch_type", ea.ALL, ["momentary", "toggle"]).withLabel("External switch type")],
Expand All @@ -419,6 +469,11 @@ export const definitions: DefinitionWithExtend[] = [
await endpoint1.read("genLevelCtrl", ["onOffTransitionTime"]);
await endpoint1.write("genLevelCtrl", {16384: {value: 0xff, type: 0x20}});
await endpoint1.read("genLevelCtrl", ["startUpCurrentLevel"]);
await endpoint1.write(
"genBasic",
{[switchTypeAttribute]: {value: switchTypeValueLookup["momentary"], type: switchTypeDataType}},
{manufacturerCode: manufacturerSpecificSwitchTypeClusterCode},
);
await endpoint1.read("genBasic", [switchTypeAttribute], {manufacturerCode: manufacturerSpecificSwitchTypeClusterCode});
},
},
Expand Down
Loading