"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.definitions = exports.fzLocal = exports.smartthingsExtend = void 0;
const zigbee_herdsman_1 = require("zigbee-herdsman");
const fz = __importStar(require("../converters/fromZigbee"));
const tz = __importStar(require("../converters/toZigbee"));
const constants = __importStar(require("../lib/constants"));
const exposes = __importStar(require("../lib/exposes"));
const m = __importStar(require("../lib/modernExtend"));
const reporting = __importStar(require("../lib/reporting"));
const globalStore = __importStar(require("../lib/store"));
const utils = __importStar(require("../lib/utils"));
const centralite_1 = require("./centralite");
const e = exposes.presets;
const ea = exposes.access;
exports.smartthingsExtend = {
    addManuSpecificSamsungAccelerometerCluster: () => m.deviceAddCustomCluster("manuSpecificSamsungAccelerometer", {
        name: "manuSpecificSamsungAccelerometer",
        ID: 0xfc02,
        manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.SMARTTHINGS_INC,
        attributes: {
            motionThresholdMultiplier: { name: "motionThresholdMultiplier", ID: 0x0000, type: zigbee_herdsman_1.Zcl.DataType.UINT8, write: true, max: 0xff },
            motionThreshold: { name: "motionThreshold", ID: 0x0002, type: zigbee_herdsman_1.Zcl.DataType.UINT16, write: true, max: 0xffff },
            acceleration: { name: "acceleration", ID: 0x0010, type: zigbee_herdsman_1.Zcl.DataType.BITMAP8, write: true, max: 0xff },
            xAxis: { name: "xAxis", ID: 0x0012, type: zigbee_herdsman_1.Zcl.DataType.INT16, write: true, min: -32768, max: 32767 },
            yAxis: { name: "yAxis", ID: 0x0013, type: zigbee_herdsman_1.Zcl.DataType.INT16, write: true, min: -32768, max: 32767 },
            zAxis: { name: "zAxis", ID: 0x0014, type: zigbee_herdsman_1.Zcl.DataType.INT16, write: true, min: -32768, max: 32767 },
        },
        commands: {},
        commandsResponse: {},
    }),
    addManuSpecificSmartThingsArrivalSensorCluster: () => m.deviceAddCustomCluster("manuSpecificSmartThingsArrivalSensor", {
        name: "manuSpecificSmartThingsArrivalSensor",
        ID: 0xfc05,
        manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.SMARTTHINGS_INC,
        attributes: {},
        commands: {},
        commandsResponse: {
            arrivalSensorNotify: { name: "arrivalSensorNotify", ID: 0x01, parameters: [] },
        },
    }),
};
const tzLocal = {
    // biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
    STS_PRS_251_beep: {
        key: ["beep"],
        convertSet: async (entity, key, value, meta) => {
            await entity.command("genIdentify", "identify", { identifytime: value }, utils.getOptions(meta.mapped, entity));
        },
    },
};
exports.fzLocal = {
    acceleration: {
        cluster: "manuSpecificSamsungAccelerometer",
        type: ["attributeReport", "readResponse"],
        convert: (model, msg, publish, options, meta) => {
            const payload = {};
            if (msg.data.acceleration !== undefined)
                payload.moving = msg.data.acceleration === 1;
            // https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy#L222
            /*
                    The axes reported by the sensor are mapped differently in the SmartThings DTH.
                    Preserving that functionality here.
                    xyzResults.x = z
                    xyzResults.y = y
                    xyzResults.z = -x
                */
            if (msg.data.zAxis !== undefined)
                payload.x_axis = msg.data.zAxis;
            if (msg.data.yAxis !== undefined)
                payload.y_axis = msg.data.yAxis;
            if (msg.data.xAxis !== undefined)
                payload.z_axis = -msg.data.xAxis;
            return payload;
        },
    },
    // biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
    PGC410EU_presence: {
        cluster: "manuSpecificSmartThingsArrivalSensor",
        type: "commandArrivalSensorNotify",
        options: [exposes.options.presence_timeout()],
        convert: (model, msg, publish, options, meta) => {
            const useOptionsTimeout = options?.presence_timeout != null;
            const timeout = useOptionsTimeout ? Number(options.presence_timeout) : 100; // 100 seconds by default
            // Stop existing timer because motion is detected and set a new one.
            clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
            const timer = setTimeout(() => publish({ presence: false }), timeout * 1000).unref();
            globalStore.putValue(msg.endpoint, "timer", timer);
            return { presence: true };
        },
    },
    // biome-ignore lint/style/useNamingConvention: ignored using `--suppress`
    STS_PRS_251_presence: {
        cluster: "genBinaryInput",
        type: ["attributeReport", "readResponse"],
        options: [exposes.options.presence_timeout()],
        convert: (model, msg, publish, options, meta) => {
            const useOptionsTimeout = options?.presence_timeout != null;
            const timeout = useOptionsTimeout ? Number(options.presence_timeout) : 100; // 100 seconds by default
            // Stop existing timer because motion is detected and set a new one.
            clearTimeout(globalStore.getValue(msg.endpoint, "timer"));
            const timer = setTimeout(() => publish({ presence: false }), timeout * 1000).unref();
            globalStore.putValue(msg.endpoint, "timer", timer);
            return { presence: true };
        },
    },
};
exports.definitions = [
    {
        zigbeeModel: ["PGC313"],
        model: "STSS-MULT-001",
        vendor: "SmartThings",
        description: "Multipurpose sensor",
        fromZigbee: [fz.ias_contact_alarm_1],
        toZigbee: [],
        exposes: [e.contact(), e.battery_low(), e.tamper()],
    },
    {
        zigbeeModel: ["PGC314"],
        model: "STSS-IRM-001",
        vendor: "SmartThings",
        description: "Motion sensor (2013 model)",
        fromZigbee: [fz.ias_occupancy_alarm_1],
        toZigbee: [],
        exposes: [e.occupancy(), e.battery_low(), e.tamper()],
    },
    {
        zigbeeModel: ["tagv4"],
        model: "STS-PRS-251",
        vendor: "SmartThings",
        description: "Arrival sensor",
        fromZigbee: [exports.fzLocal.STS_PRS_251_presence, fz.battery, fz.identify],
        exposes: [
            e.battery(),
            e.presence(),
            e.action(["identify"]),
            e.enum("beep", ea.SET, ["2", "5", "10", "15", "30"]).withDescription("Trigger beep for x seconds"),
        ],
        toZigbee: [tzLocal.STS_PRS_251_beep],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genPowerCfg", "genBinaryInput"]);
            await reporting.batteryVoltage(endpoint);
            await reporting.presentValue(endpoint);
        },
    },
    {
        zigbeeModel: ["PGC410EU", "PGC410"],
        model: "STSS-PRES-001",
        vendor: "SmartThings",
        description: "Presence sensor",
        extend: [exports.smartthingsExtend.addManuSpecificSmartThingsArrivalSensorCluster()],
        fromZigbee: [exports.fzLocal.PGC410EU_presence, fz.battery],
        exposes: [e.battery(), e.presence()],
        toZigbee: [],
    },
    {
        zigbeeModel: ["3325-S"],
        model: "3325-S",
        vendor: "SmartThings",
        description: "Motion sensor (2015 model)",
        fromZigbee: [fz.temperature, fz.ias_occupancy_alarm_2, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: "3V_2100" } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.occupancy(), e.battery(), e.tamper()],
    },
    {
        zigbeeModel: ["3321-S"],
        model: "3321-S",
        vendor: "SmartThings",
        description: "Multi Sensor (2015 model)",
        extend: [exports.smartthingsExtend.addManuSpecificSamsungAccelerometerCluster()],
        fromZigbee: [fz.temperature, fz.ias_contact_alarm_1_report, fz.ias_contact_alarm_1, fz.battery, exports.fzLocal.acceleration],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: "3V_2100" } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            const options = { manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.CENTRALITE_SYSTEMS_INC };
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg", "manuSpecificSamsungAccelerometer"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
            const payloadA = reporting.payload("acceleration", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadA, options);
            const payloadX = reporting.payload("xAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadX, options);
            const payloadY = reporting.payload("yAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadY, options);
            const payloadZ = reporting.payload("zAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadZ, options);
            // Has Unknown power source, force it.
            device.powerSource = "Battery";
            device.save();
        },
        exposes: [e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery(), e.moving(), e.x_axis(), e.y_axis(), e.z_axis()],
    },
    {
        zigbeeModel: ["3200-Sgb"],
        model: "F-APP-UK-V2",
        vendor: "SmartThings",
        description: "Zigbee Outlet UK with power meter",
        fromZigbee: [fz.on_off, fz.electrical_measurement],
        toZigbee: [tz.on_off],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement"]);
            await reporting.onOff(endpoint);
            // Does not support reading of acVoltageMultiplier/acVoltageDivisor
            await endpoint.read("haElectricalMeasurement", ["acCurrentMultiplier", "acCurrentDivisor"]);
            await endpoint.read("haElectricalMeasurement", ["acPowerMultiplier", "acPowerDivisor"]);
            // Limit updates to 3V and max 600s (10m)
            await reporting.rmsVoltage(endpoint, { max: 600, change: 3 });
            // Limit updates to 0.01A and max 600s (10m)
            await reporting.rmsCurrent(endpoint, { max: 600, change: 10 });
            // Limit updates to 4.0W and max 600s (10m)
            await reporting.activePower(endpoint, { max: 600, change: 40 });
        },
        exposes: [e.switch(), e.power(), e.current(), e.voltage()],
    },
    {
        zigbeeModel: ["ZB-ONOFFPlug-D0005"],
        model: "GP-WOU019BBDWG",
        vendor: "SmartThings",
        description: "Outlet with power meter",
        // This plug only actively reports power. The voltage and current values are always 0, so we can ignore them.
        // https://github.com/Koenkk/zigbee2mqtt/issues/5198
        extend: [m.onOff(), m.electricityMeter({ current: false, voltage: false })],
    },
    {
        zigbeeModel: ["outlet"],
        model: "IM6001-OTP05",
        vendor: "SmartThings",
        description: "Outlet",
        fromZigbee: [fz.on_off, fz.electrical_measurement],
        toZigbee: [tz.on_off],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement"]);
            await reporting.onOff(endpoint);
            await reporting.readEletricalMeasurementMultiplierDivisors(endpoint);
            await reporting.activePower(endpoint);
            await reporting.rmsCurrent(endpoint);
            await reporting.rmsVoltage(endpoint);
        },
        exposes: [e.switch(), e.power(), e.current(), e.voltage()],
    },
    {
        zigbeeModel: ["outletv4"],
        model: "STS-OUT-US-2",
        vendor: "SmartThings",
        description: "Zigbee smart plug with power meter",
        fromZigbee: [fz.on_off, fz.electrical_measurement],
        toZigbee: [tz.on_off],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement"]);
            await reporting.onOff(endpoint);
            try {
                // https://github.com/Koenkk/zigbee2mqtt/issues/11706
                await reporting.readEletricalMeasurementMultiplierDivisors(endpoint);
            }
            catch {
                /* Fails for some*/
            }
            await reporting.activePower(endpoint);
            await reporting.rmsCurrent(endpoint);
            await reporting.rmsVoltage(endpoint, { change: 10 });
        },
        exposes: [e.switch(), e.power(), e.current(), e.voltage()],
    },
    {
        zigbeeModel: ["motion"],
        model: "IM6001-MTP01",
        vendor: "SmartThings",
        description: "Motion sensor (2018 model)",
        fromZigbee: [fz.temperature, fz.ignore_iaszone_report, fz.ias_occupancy_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.occupancy(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["motionv5"],
        model: "STS-IRM-251",
        vendor: "SmartThings",
        description: "Motion sensor (2017 model)",
        fromZigbee: [fz.temperature, fz.ias_occupancy_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
            device.powerSource = "Battery";
            device.save();
        },
        exposes: [e.temperature(), e.occupancy(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["motionv4"],
        model: "STS-IRM-250",
        vendor: "SmartThings",
        description: "Motion sensor (2016 model)",
        fromZigbee: [fz.temperature, fz.ias_occupancy_alarm_2, fz.ias_occupancy_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: "3V_1500_2800" } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
            // Has Unknown power source, force it.
            device.powerSource = "Battery";
            device.save();
        },
        exposes: [e.temperature(), e.occupancy(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["3305-S", "3305"],
        model: "3305-S",
        vendor: "SmartThings",
        description: "Motion sensor (2014 model)",
        fromZigbee: [fz.temperature, fz.ias_occupancy_alarm_2, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.occupancy(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["3300-S"],
        model: "3300-S",
        vendor: "SmartThings",
        description: "Door sensor",
        fromZigbee: [fz.temperature, fz.ias_contact_alarm_1_report, fz.ias_contact_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["multiv4"],
        model: "F-MLT-US-2",
        vendor: "SmartThings",
        description: "Multipurpose sensor (2016 model)",
        extend: [exports.smartthingsExtend.addManuSpecificSamsungAccelerometerCluster()],
        fromZigbee: [fz.temperature, fz.battery, fz.ias_contact_alarm_1, exports.fzLocal.acceleration],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: "3V_1500_2800" } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            const options = { manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.SMARTTHINGS_INC };
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg", "manuSpecificSamsungAccelerometer"]);
            await endpoint.write("manuSpecificSamsungAccelerometer", { 0: { value: 0x01, type: 0x20 } }, options);
            await endpoint.write("manuSpecificSamsungAccelerometer", { 2: { value: 0x0276, type: 0x21 } }, options);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
            const payloadA = reporting.payload("acceleration", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadA, options);
            const payloadX = reporting.payload("xAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadX, options);
            const payloadY = reporting.payload("yAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadY, options);
            const payloadZ = reporting.payload("zAxis", 10, constants.repInterval.MINUTE, 1);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadZ, options);
            // Has Unknown power source, force it.
            device.powerSource = "Battery";
            device.save();
        },
        exposes: [e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery(), e.moving(), e.x_axis(), e.y_axis(), e.z_axis()],
    },
    {
        zigbeeModel: ["multi"],
        model: "IM6001-MPP01",
        vendor: "SmartThings",
        description: "Multipurpose sensor (2018 model)",
        extend: [exports.smartthingsExtend.addManuSpecificSamsungAccelerometerCluster()],
        fromZigbee: [fz.temperature, fz.battery, fz.ias_contact_alarm_1, exports.fzLocal.acceleration],
        toZigbee: [],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            const options = { manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.SAMJIN_CO_LTD };
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg", "manuSpecificSamsungAccelerometer"]);
            await endpoint.write("manuSpecificSamsungAccelerometer", { 0: { value: 0x14, type: 0x20 } }, options);
            await endpoint.write("genPollCtrl", { checkinInterval: 14400 });
            await reporting.temperature(endpoint);
            await reporting.batteryPercentageRemaining(endpoint);
            const payloadA = reporting.payload("acceleration", 10, constants.repInterval.HOUR, 5);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadA, options);
            const payloadX = reporting.payload("xAxis", 10, constants.repInterval.HOUR, 5);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadX, options);
            const payloadY = reporting.payload("yAxis", 10, constants.repInterval.HOUR, 5);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadY, options);
            const payloadZ = reporting.payload("zAxis", 10, constants.repInterval.HOUR, 5);
            await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadZ, options);
        },
        exposes: [e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery(), e.moving(), e.x_axis(), e.y_axis(), e.z_axis()],
    },
    {
        zigbeeModel: ["3310-S"],
        model: "3310-S",
        vendor: "SmartThings",
        description: "Temperature and humidity sensor",
        extend: [centralite_1.centraliteExtend.addManuSpecificCentraliteHumidityCluster()],
        fromZigbee: [fz.temperature, centralite_1.fzLocal.d3310_humidity, fz.battery],
        exposes: [e.temperature(), e.humidity(), e.battery()],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            const binds = ["msTemperatureMeasurement", "manuSpecificCentraliteHumidity", "genPowerCfg"];
            await reporting.bind(endpoint, coordinatorEndpoint, binds);
            await reporting.temperature(endpoint);
            const payload = [
                {
                    attribute: "measuredValue",
                    minimumReportInterval: 10,
                    maximumReportInterval: constants.repInterval.HOUR,
                    reportableChange: 10,
                },
            ];
            await endpoint.configureReporting("manuSpecificCentraliteHumidity", payload, {
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.CENTRALITE_SYSTEMS_INC,
            });
            await reporting.batteryVoltage(endpoint);
        },
    },
    {
        zigbeeModel: ["3315-S"],
        model: "3315-S",
        vendor: "SmartThings",
        description: "Water sensor",
        fromZigbee: [fz.temperature, fz.ias_water_leak_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.water_leak(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["3315-Seu"],
        model: "WTR-UK-V2",
        vendor: "SmartThings",
        description: "Water leak sensor (2015 model)",
        fromZigbee: [fz.temperature, fz.ias_water_leak_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.water_leak(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["water"],
        model: "IM6001-WLP01",
        vendor: "SmartThings",
        description: "Water leak sensor (2018 model)",
        fromZigbee: [fz.temperature, fz.ias_water_leak_alarm_1, fz.battery, fz.ias_water_leak_alarm_1_report],
        toZigbee: [],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryPercentageRemaining(endpoint);
        },
        exposes: [e.temperature(), e.water_leak(), e.battery_low(), e.tamper(), e.battery(), e.voltage()],
    },
    {
        zigbeeModel: ["moisturev4"],
        model: "STS-WTR-250",
        vendor: "SmartThings",
        description: "Water leak sensor (2016 model)",
        fromZigbee: [fz.ias_water_leak_alarm_1, fz.battery, fz.temperature],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genPowerCfg", "msTemperatureMeasurement"]);
            await reporting.batteryVoltage(endpoint);
            await reporting.temperature(endpoint);
            device.powerSource = "Battery";
            device.save();
        },
        exposes: [e.water_leak(), e.battery_low(), e.tamper(), e.battery(), e.temperature()],
    },
    {
        zigbeeModel: ["3315-G"],
        model: "3315-G",
        vendor: "SmartThings",
        description: "Water sensor",
        fromZigbee: [fz.temperature, fz.ias_water_leak_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.water_leak(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ["F-ADT-WTR-1"],
        model: "F-ADT-WTR-1",
        vendor: "SmartThings",
        description: "ADT water leak detector",
        fromZigbee: [fz.temperature, fz.ias_water_leak_alarm_1, fz.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: { min: 2500, max: 3000 } } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
        exposes: [e.temperature(), e.water_leak(), e.battery_low(), e.battery()],
    },
    {
        zigbeeModel: ["button"],
        model: "IM6001-BTP01",
        vendor: "SmartThings",
        description: "Button",
        fromZigbee: [fz.command_status_change_notification_action, fz.battery, fz.temperature, fz.ignore_iaszone_attreport],
        exposes: [e.action(["off", "single", "double", "hold"]), e.battery(), e.temperature()],
        toZigbee: [],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg"]);
            await reporting.temperature(endpoint);
            await reporting.batteryVoltage(endpoint);
        },
    },
    {
        zigbeeModel: ["Z-SRN12N", "SZ-SRN12N"],
        model: "SZ-SRN12N",
        vendor: "SmartThings",
        description: "Smart siren",
        fromZigbee: [],
        toZigbee: [tz.warning],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ["genPowerCfg"]);
        },
        exposes: [e.warning()],
    },
    {
        zigbeeModel: ["zbt-dimlight-gls0006"],
        model: "GP-LBU019BBAWU",
        vendor: "SmartThings",
        description: "Smart bulb",
        extend: [m.light()],
    },
    {
        zigbeeModel: ["ZBT-DIMLight-GLS0044"],
        model: "7ZA-A806ST-Q1R",
        vendor: "SmartThings",
        description: "Smart bulb",
        extend: [m.light()],
    },
];
//# sourceMappingURL=smartthings.js.map