Skip to content
21 changes: 20 additions & 1 deletion src/devices/multir.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as exposes from "../lib/exposes";
import * as m from "../lib/modernExtend";
import type {DefinitionWithExtend, Fz} from "../lib/types";
import type {DefinitionWithExtend, Fz, Tz} from "../lib/types";

const e = exposes.presets;
const ea = exposes.access;

const fzLocal = {
MIRSO100: {
Expand All @@ -21,6 +22,22 @@ const fzLocal = {
} satisfies Fz.Converter<"ssIasZone", undefined, "raw">,
};

const tzLocal = {
MIRSM200: {
key: ["silence"],
convertSet: async (entity, key, value, meta) => {
if (value === "enable") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it also be used to turn off? otherwise we should use an enum as expose with just the enable value

await entity.command("genOnOff", "off", {});
}
return {
state: {
silence: value,
},
};
},
} satisfies Tz.Converter,
};

export const definitions: DefinitionWithExtend[] = [
{
zigbeeModel: ["MIR-MC100"],
Expand Down Expand Up @@ -66,13 +83,15 @@ export const definitions: DefinitionWithExtend[] = [
model: "MIR-SM200",
vendor: "MultIR",
description: "Smoke sensor",
toZigbee: [tzLocal.MIRSM200],
extend: [
m.battery(),
m.iasZoneAlarm({
zoneType: "smoke",
zoneAttributes: ["alarm_1", "tamper", "battery_low"],
}),
],
exposes: [exposes.binary("silence", ea.SET, "enable", "disabled").withDescription("Silence the alarm")],
},
{
zigbeeModel: ["MIR-SO100"],
Expand Down