Skip to content
Merged
Show file tree
Hide file tree
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
126 changes: 0 additions & 126 deletions src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from "node:assert";
import * as libColor from "../lib/color";
import * as constants from "../lib/constants";
import * as exposes from "../lib/exposes";
import type {HeimanSpecificAirQualityCluster, HeimanSpecificInfraRedRemoteCluster, HeimanSpecificScenesCluster} from "../lib/heiman";
import {logger} from "../lib/logger";
import * as globalStore from "../lib/store";
import type {Fz, KeyValue, KeyValueAny, KeyValueNumberString} from "../lib/types";
Expand Down Expand Up @@ -2651,68 +2650,6 @@ export const plaid_battery: Fz.Converter<"genPowerCfg", undefined, ["readRespons
return payload;
},
};
export const heiman_ir_remote: Fz.Converter<
"heimanSpecificInfraRedRemote",
HeimanSpecificInfraRedRemoteCluster,
["commandStudyKeyRsp", "commandCreateIdRsp", "commandGetIdAndKeyCodeListRsp"]
> = {
cluster: "heimanSpecificInfraRedRemote",
type: ["commandStudyKeyRsp", "commandCreateIdRsp", "commandGetIdAndKeyCodeListRsp"],
convert: (model, msg, publish, options, meta) => {
// TODO: split converter for each cmd?
switch (msg.type) {
case "commandStudyKeyRsp":
assert("keyCode" in msg.data);
return {
action: "learn",
action_result: msg.data.result === 1 ? "success" : "error",
action_key_code: msg.data.keyCode,
action_id: msg.data.result === 1 ? msg.data.id : undefined,
};
case "commandCreateIdRsp":
assert("id" in msg.data);
assert("modelType" in msg.data);
return {
action: "create",
action_result: msg.data.id === 0xff ? "error" : "success",
action_model_type: msg.data.modelType,
action_id: msg.data.id !== 0xff ? msg.data.id : undefined,
};
case "commandGetIdAndKeyCodeListRsp": {
assert("packetNumber" in msg.data);
// See cluster.js with data format description
if (msg.data.packetNumber === 1) {
// start to collect and merge list
// so, we use store instance for temp storage during merging
globalStore.putValue(msg.endpoint, "db", []);
}
const buffer = msg.data.learnedDevicesList;
for (let i = 0; i < msg.data.packetLength; ) {
const modelDescription: KeyValueAny = {
id: buffer[i],
model_type: buffer[i + 1],
key_codes: [],
};
const numberOfKeys = buffer[i + 2];
for (let j = i + 3; j < i + 3 + numberOfKeys; j++) {
modelDescription.key_codes.push(buffer[j]);
}
i = i + 3 + numberOfKeys;
globalStore.getValue(msg.endpoint, "db").push(modelDescription);
}
if (msg.data.packetNumber === msg.data.packetsTotal) {
// last packet, all data collected, can publish
const result: KeyValueAny = {
devices: globalStore.getValue(msg.endpoint, "db"),
};
globalStore.clearValue(msg.endpoint, "db");
return result;
}
break;
}
}
},
};
export const meazon_meter: Fz.Converter<"seMetering", undefined, ["attributeReport", "readResponse"]> = {
cluster: "seMetering",
type: ["attributeReport", "readResponse"],
Expand Down Expand Up @@ -3311,34 +3248,6 @@ export const U02I007C01_water_leak: Fz.Converter<"ssIasZone", undefined, "comman
};
},
};
export const heiman_hcho: Fz.Converter<"msFormaldehyde", undefined, ["attributeReport", "readResponse"]> = {
cluster: "msFormaldehyde",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
if (msg.data.measuredValue) {
return {hcho: msg.data.measuredValue / 1000.0};
}
},
};
export const heiman_air_quality: Fz.Converter<"heimanSpecificAirQuality", HeimanSpecificAirQualityCluster, ["attributeReport", "readResponse"]> = {
cluster: "heimanSpecificAirQuality",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const result: KeyValueAny = {};
if (msg.data.batteryState) {
const lookup: KeyValueAny = {
0: "not_charging",
1: "charging",
2: "charged",
};
result.battery_state = lookup[msg.data.batteryState];
}
if (msg.data.tvocMeasuredValue) result.voc = msg.data.tvocMeasuredValue;
if (msg.data.aqiMeasuredValue) result.aqi = msg.data.aqiMeasuredValue;
if (msg.data.pm10measuredValue) result.pm10 = msg.data.pm10measuredValue;
return result;
},
};
export const scenes_recall_scene_65024: Fz.Converter<65024, undefined, ["raw"]> = {
cluster: 65024,
type: ["raw"],
Expand Down Expand Up @@ -3508,24 +3417,6 @@ export const STS_PRS_251_presence: Fz.Converter<"genBinaryInput", undefined, ["a
return {presence: true};
},
};
export const heiman_scenes: Fz.Converter<
"heimanSpecificScenes",
HeimanSpecificScenesCluster,
["commandAtHome", "commandGoOut", "commandCinema", "commandRepast", "commandSleep"]
> = {
cluster: "heimanSpecificScenes",
type: ["commandAtHome", "commandGoOut", "commandCinema", "commandRepast", "commandSleep"],
convert: (model, msg, publish, options, meta) => {
const lookup: KeyValueAny = {
commandCinema: "cinema",
commandAtHome: "at_home",
commandSleep: "sleep",
commandGoOut: "go_out",
commandRepast: "repast",
};
if (lookup[msg.type] !== undefined) return {action: lookup[msg.type]};
},
};
export const javis_lock_report: Fz.Converter<"genBasic", undefined, "attributeReport"> = {
cluster: "genBasic",
type: "attributeReport",
Expand Down Expand Up @@ -4023,23 +3914,6 @@ export const rc_110_level_to_scene: Fz.Converter<"genLevelCtrl", undefined, ["co
return {action: `scene_${scenes[msg.data.level]}`};
},
};
export const heiman_doorbell_button: Fz.Converter<"ssIasZone", undefined, "commandStatusChangeNotification"> = {
cluster: "ssIasZone",
type: "commandStatusChangeNotification",
convert: (model, msg, publish, options, meta) => {
if (hasAlreadyProcessedMessage(msg, model)) return;
const lookup: KeyValueAny = {
32768: "pressed",
32772: "pressed",
};
const zoneStatus = msg.data.zonestatus;
return {
action: lookup[zoneStatus],
tamper: (zoneStatus & (1 << 2)) > 0,
battery_low: (zoneStatus & (1 << 3)) > 0,
};
},
};
export const sihas_people_cnt: Fz.Converter<"genAnalogInput", undefined, ["attributeReport", "readResponse"]> = {
cluster: "genAnalogInput",
type: ["attributeReport", "readResponse"],
Expand Down
61 changes: 0 additions & 61 deletions src/converters/toZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {TClusterCommandPayload} from "zigbee-herdsman/dist/zspec/zcl/defini
import * as libColor from "../lib/color";
import * as constants from "../lib/constants";
import * as exposes from "../lib/exposes";
import type {HeimanSpecificInfraRedRemoteCluster} from "../lib/heiman";
import * as legacy from "../lib/legacy";
import * as light from "../lib/light";
import {logger} from "../lib/logger";
Expand Down Expand Up @@ -3359,66 +3358,6 @@ export const power_source: Tz.Converter = {
await entity.read("genBasic", ["powerSource"]);
},
};
export const heiman_ir_remote: Tz.Converter = {
key: ["send_key", "create", "learn", "delete", "get_list"],
convertSet: async (entity, key, value, meta) => {
const options = {
// Don't send a manufacturerCode (otherwise set in herdsman):
// https://github.com/Koenkk/zigbee-herdsman-converters/pull/2827
// @ts-expect-error ignore
manufacturerCode: null,
...utils.getOptions(meta.mapped, entity),
};
switch (key) {
case "send_key":
utils.assertObject(value);
await entity.command<"heimanSpecificInfraRedRemote", "sendKey", HeimanSpecificInfraRedRemoteCluster>(
"heimanSpecificInfraRedRemote",
"sendKey",
{id: value.id, keyCode: value.key_code},
options,
);
break;
case "create":
utils.assertObject(value);
await entity.command<"heimanSpecificInfraRedRemote", "createId", HeimanSpecificInfraRedRemoteCluster>(
"heimanSpecificInfraRedRemote",
"createId",
{modelType: value.model_type},
options,
);
break;
case "learn":
utils.assertObject(value);
await entity.command<"heimanSpecificInfraRedRemote", "studyKey", HeimanSpecificInfraRedRemoteCluster>(
"heimanSpecificInfraRedRemote",
"studyKey",
{id: value.id, keyCode: value.key_code},
options,
);
break;
case "delete":
utils.assertObject(value);
await entity.command<"heimanSpecificInfraRedRemote", "deleteKey", HeimanSpecificInfraRedRemoteCluster>(
"heimanSpecificInfraRedRemote",
"deleteKey",
{id: value.id, keyCode: value.key_code},
options,
);
break;
case "get_list":
await entity.command<"heimanSpecificInfraRedRemote", "getIdAndKeyCodeList", HeimanSpecificInfraRedRemoteCluster>(
"heimanSpecificInfraRedRemote",
"getIdAndKeyCodeList",
{},
options,
);
break;
default: // Unknown key
throw new Error(`Unhandled key ${key}`);
}
},
};
export const scene_store: Tz.Converter = {
key: ["scene_store"],
convertSet: async (entity, key, value: KeyValueAny, meta) => {
Expand Down
Loading