"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 (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const exposes = __importStar(require("../lib/exposes"));
const fromZigbee_1 = __importDefault(require("../converters/fromZigbee"));
const toZigbee_1 = __importDefault(require("../converters/toZigbee"));
const reporting = __importStar(require("../lib/reporting"));
const modernExtend_1 = require("../lib/modernExtend");
const e = exposes.presets;
const tzLocal = {
    DD10Z_brightness: {
        key: ['brightness'],
        options: [exposes.options.transition()],
        convertSet: async (entity, key, value, meta) => {
            // Device doesn't support moveToLevelWithOnOff therefore this converter is needed.
            await entity.command('genLevelCtrl', 'moveToLevel', { level: Number(value), transtime: 0 }, { disableDefaultResponse: true });
            return { state: { brightness: value } };
        },
        convertGet: async (entity, key, meta) => {
            await entity.read('genLevelCtrl', ['currentLevel']);
        },
    },
};
const definitions = [
    {
        zigbeeModel: ['ccb9f56837ab41dcad366fb1452096b6', '250bccf66c41421b91b5e3242942c164'],
        model: 'DD10Z',
        vendor: 'ORVIBO',
        description: 'Smart spotlight',
        // https://github.com/Koenkk/zigbee2mqtt/issues/13123#issuecomment-1198793749
        meta: { disableDefaultResponse: true },
        toZigbee: [tzLocal.DD10Z_brightness],
        extend: [(0, modernExtend_1.light)({ powerOnBehavior: false, colorTemp: { range: [153, 370], startup: false } })],
    },
    {
        zigbeeModel: ['4a33f5ea766a4c96a962b371ffde9943'],
        model: 'DS20Z07B',
        vendor: 'ORVIBO',
        description: 'Downlight (S series)',
        extend: [(0, modernExtend_1.light)({ colorTemp: { range: [166, 370] } })],
    },
    {
        zigbeeModel: ['ORVIBO Socket', '93e29b89b2ee45bea5bdbb7679d75d24'],
        model: 'OR-ZB-S010-3C',
        vendor: 'ORVIBO',
        description: 'Smart socket',
        extend: [(0, modernExtend_1.onOff)()],
    },
    {
        zigbeeModel: ['3c4e4fc81ed442efaf69353effcdfc5f', '51725b7bcba945c8a595b325127461e9'],
        model: 'CR11S8UZ',
        vendor: 'ORVIBO',
        description: 'Smart sticker switch',
        fromZigbee: [fromZigbee_1.default.orvibo_raw_1],
        exposes: [e.action(['button_1_click', 'button_1_hold', 'button_1_release', 'button_2_click', 'button_2_hold', 'button_2_release',
                'button_3_click', 'button_3_hold', 'button_3_release', 'button_4_click', 'button_4_hold', 'button_4_release'])],
        toZigbee: [],
    },
    {
        zigbeeModel: ['31c989b65ebb45beaf3b67b1361d3965'],
        model: 'T18W3Z',
        vendor: 'ORVIBO',
        description: 'Neutral smart switch 3 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2, 'l3': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2', 'l3'] }),
        ],
    },
    {
        zigbeeModel: ['fdd76effa0e146b4bdafa0c203a37192', 'c670e231d1374dbc9e3c6a9fffbd0ae6', '75a4bfe8ef9c4350830a25d13e3ab068'],
        model: 'SM10ZW',
        vendor: 'ORVIBO',
        description: 'Door or window contact switch',
        fromZigbee: [fromZigbee_1.default.ias_contact_alarm_1, fromZigbee_1.default.battery],
        toZigbee: [],
        exposes: [e.contact(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ['8643db61de35494d93e72c1289b526a3'],
        model: 'RL804CZB',
        vendor: 'ORVIBO',
        description: 'Zigbee LED controller RGB + CCT or RGBW',
        extend: [(0, modernExtend_1.light)({ colorTemp: { range: undefined }, color: true })],
    },
    {
        zigbeeModel: ['82c167c95ed746cdbd21d6817f72c593', '8762413da99140cbb809195ff40f8c51'],
        model: 'RL804QZB',
        vendor: 'ORVIBO',
        description: 'Multi-functional 3 gang relay',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2, 'l3': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2', 'l3'], configureReporting: false }),
        ],
    },
    {
        zigbeeModel: ['396483ce8b3f4e0d8e9d79079a35a420'],
        model: 'CM10ZW',
        vendor: 'ORVIBO',
        description: 'Multi-functional 3 gang relay',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2, 'l3': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2', 'l3'] }),
        ],
    },
    {
        zigbeeModel: ['b467083cfc864f5e826459e5d8ea6079'],
        model: 'ST20',
        vendor: 'ORVIBO',
        description: 'Temperature & humidity sensor',
        fromZigbee: [fromZigbee_1.default.humidity, fromZigbee_1.default.temperature, fromZigbee_1.default.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: '3V_2500' } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint1 = device.getEndpoint(1);
            await reporting.bind(endpoint1, coordinatorEndpoint, ['msTemperatureMeasurement']);
            const endpoint2 = device.getEndpoint(2);
            await reporting.bind(endpoint2, coordinatorEndpoint, ['msRelativeHumidity', 'genPowerCfg']);
            await reporting.temperature(endpoint1);
            await reporting.humidity(endpoint2);
            await reporting.batteryVoltage(endpoint2);
            await reporting.batteryPercentageRemaining(endpoint2);
        },
        exposes: [e.humidity(), e.temperature(), e.battery()],
    },
    {
        zigbeeModel: ['888a434f3cfc47f29ec4a3a03e9fc442'],
        model: 'ST21',
        vendor: 'ORVIBO',
        description: 'Temperature & humidity Sensor',
        fromZigbee: [fromZigbee_1.default.temperature, fromZigbee_1.default.humidity, fromZigbee_1.default.battery],
        toZigbee: [],
        meta: { battery: { voltageToPercentage: '3V_2500' } },
        configure: async (device, coordinatorEndpoint) => {
            const endpoint1 = device.getEndpoint(1);
            await reporting.bind(endpoint1, coordinatorEndpoint, ['msTemperatureMeasurement']);
            const endpoint2 = device.getEndpoint(2);
            await reporting.bind(endpoint2, coordinatorEndpoint, ['msRelativeHumidity', 'genPowerCfg']);
            await reporting.temperature(endpoint1);
            await reporting.humidity(endpoint2);
            await reporting.batteryVoltage(endpoint2);
            await reporting.batteryPercentageRemaining(endpoint2);
        },
        exposes: [e.temperature(), e.humidity(), e.battery()],
    },
    {
        zigbeeModel: ['898ca74409a740b28d5841661e72268d', '50938c4c3c0b4049923cd5afbc151bde'],
        model: 'ST30',
        vendor: 'ORVIBO',
        description: 'Temperature & humidity sensor',
        extend: [(0, modernExtend_1.battery)(), (0, modernExtend_1.humidity)(), (0, modernExtend_1.temperature)()],
    },
    {
        zigbeeModel: ['9f76c9f31b4c4a499e3aca0977ac4494', '6fd24c0f58a04c848fea837aaa7d6e0f'],
        model: 'T30W3Z',
        vendor: 'ORVIBO',
        description: 'Smart light switch - 3 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'top': 1, 'center': 2, 'bottom': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['top', 'center', 'bottom'] }),
        ],
    },
    {
        zigbeeModel: ['074b3ffba5a045b7afd94c47079dd553'],
        model: 'T21W2Z',
        vendor: 'ORVIBO',
        description: 'Smart light switch - 2 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'top': 1, 'bottom': 2 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['top', 'bottom'] }),
        ],
    },
    {
        zigbeeModel: ['095db3379e414477ba6c2f7e0c6aa026'],
        model: 'T21W1Z',
        vendor: 'ORVIBO',
        description: 'Smart light switch - 1 gang',
        extend: [(0, modernExtend_1.onOff)()],
    },
    {
        zigbeeModel: ['093199ff04984948b4c78167c8e7f47e', 'c8daea86aa9c415aa524365775b1218c', 'c8daea86aa9c415aa524365775b1218'],
        model: 'W40CZ',
        vendor: 'ORVIBO',
        description: 'Smart curtain motor',
        fromZigbee: [fromZigbee_1.default.curtain_position_analog_output, fromZigbee_1.default.cover_position_tilt, fromZigbee_1.default.ignore_basic_report],
        toZigbee: [toZigbee_1.default.cover_state, toZigbee_1.default.cover_position_tilt],
        exposes: [e.cover_position()],
    },
    {
        zigbeeModel: ['428f8caf93574815be1a98fa6732c3ea'],
        model: 'W45CZ',
        vendor: 'ORVIBO',
        description: 'Smart curtain motor',
        fromZigbee: [fromZigbee_1.default.curtain_position_analog_output, fromZigbee_1.default.cover_position_tilt, fromZigbee_1.default.ignore_basic_report],
        toZigbee: [toZigbee_1.default.cover_state, toZigbee_1.default.cover_position_tilt],
        exposes: [e.cover_position()],
    },
    {
        zigbeeModel: ['e0fc98cc88df4857847dc4ae73d80b9e'],
        model: 'R11W2Z',
        vendor: 'ORVIBO',
        description: 'In wall switch - 2 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2'] }),
        ],
    },
    {
        zigbeeModel: ['9ea4d5d8778d4f7089ac06a3969e784b', '83b9b27d5ffb4830bf35be5b1023623e', '2810c2403b9c4a5db62cc62d1030d95e'],
        model: 'R20W2Z',
        vendor: 'ORVIBO',
        description: 'In wall switch - 2 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2'] }),
        ],
    },
    {
        zigbeeModel: ['131c854783bc45c9b2ac58088d09571c', 'b2e57a0f606546cd879a1a54790827d6', '585fdfb8c2304119a2432e9845cf2623'],
        model: 'SN10ZW',
        vendor: 'ORVIBO',
        description: 'Occupancy sensor',
        fromZigbee: [fromZigbee_1.default.ias_occupancy_alarm_1_with_timeout, fromZigbee_1.default.battery],
        toZigbee: [],
        exposes: [e.occupancy(), e.battery_low(), e.tamper(), e.battery()],
    },
    {
        zigbeeModel: ['da2edf1ded0d44e1815d06f45ce02029'],
        model: 'SW21',
        vendor: 'ORVIBO',
        description: 'Water leakage sensor',
        fromZigbee: [fromZigbee_1.default.ias_water_leak_alarm_1],
        toZigbee: [],
        exposes: [e.water_leak(), e.battery_low(), e.tamper()],
    },
    {
        zigbeeModel: ['b7e305eb329f497384e966fe3fb0ac69', '52debf035a1b4a66af56415474646c02', 'MultIR', 'ZL1-EN'],
        model: 'SW30',
        vendor: 'ORVIBO',
        description: 'Water leakage sensor',
        fromZigbee: [fromZigbee_1.default.ias_water_leak_alarm_1],
        toZigbee: [],
        exposes: [e.water_leak(), e.battery_low(), e.tamper()],
    },
    {
        zigbeeModel: ['72bd56c539ca4c7fba73a9be0ae0d19f'],
        model: 'SE21',
        vendor: 'ORVIBO',
        description: 'Smart emergency button',
        fromZigbee: [fromZigbee_1.default.command_status_change_notification_action],
        exposes: [e.action(['off', 'single', 'double', 'hold'])],
        toZigbee: [],
    },
    {
        zigbeeModel: ['2a103244da0b406fa51410c692f79ead'],
        model: 'AM25',
        vendor: 'ORVIBO',
        description: 'Smart blind controller',
        fromZigbee: [fromZigbee_1.default.cover_position_tilt, fromZigbee_1.default.battery],
        toZigbee: [toZigbee_1.default.cover_state, toZigbee_1.default.cover_position_tilt],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg', 'closuresWindowCovering']);
            await reporting.batteryPercentageRemaining(endpoint);
            await reporting.currentPositionLiftPercentage(endpoint);
            device.powerSource = 'Battery';
            device.save();
        },
        exposes: [e.cover_position(), e.battery()],
    },
    {
        zigbeeModel: ['2ae011fb6d0542f58705d6861064eb5f'],
        model: 'T40W1Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 1 gang',
        extend: [(0, modernExtend_1.onOff)()],
    },
    {
        zigbeeModel: ['2e13af8e17434961be98f055d68c2166'],
        model: 'T40W2Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 2 gangs',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'left': 1, 'right': 2 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['left', 'right'] }),
        ],
    },
    {
        zigbeeModel: ['e8d667cb184b4a2880dd886c23d00976'],
        model: 'T40W3Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 3 gangs',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'left': 1, 'center': 2, 'right': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['left', 'center', 'right'] }),
        ],
    },
    {
        zigbeeModel: ['20513b10079f4cc68cffb8b0dc6d3277'],
        model: 'T40W4Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 4 gangs',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'l1': 1, 'l2': 2, 'l4': 3, 'l5': 5, 'l6': 6 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['l1', 'l2', 'l4', 'l5', 'l6'] }),
        ],
    },
    {
        zigbeeModel: ['bcb949e87e8c4ea6bc2803052dd8fbf5'],
        model: 'T40S6Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 6 gangs',
        fromZigbee: [fromZigbee_1.default.orvibo_raw_2],
        toZigbee: [],
        exposes: [e.action(['button_1_click', 'button_2_click', 'button_3_click', 'button_4_click', 'button_5_click', 'button_6_click'])],
    },
    {
        zigbeeModel: ['ba8120ad03f744ecb6a973672369e80d'],
        model: 'T41W1Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 1 gang (without neutral wire)',
        extend: [(0, modernExtend_1.onOff)()],
    },
    {
        zigbeeModel: ['7c8f476a0f764cd4b994bc73d07c906d'],
        model: 'T41W2Z',
        vendor: 'ORVIBO',
        description: 'MixSwitch 2 gang (without neutral wire)',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'left': 1, 'right': 2 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['left', 'right'] }),
        ],
    },
    {
        zigbeeModel: ['cb7ce9fe2cb147e69c5ea700b39b3d5b'],
        model: 'DM10ZW',
        vendor: 'ORVIBO',
        description: '0-10v dimmer',
        extend: [(0, modernExtend_1.light)({ colorTemp: { range: [153, 371] } })],
    },
    {
        zigbeeModel: ['1a20628504bf48c88ed698fe96b7867c'],
        model: 'DTZ09039',
        vendor: 'ORVIBO',
        description: 'Downlight (Q series)',
        extend: [(0, modernExtend_1.light)()],
    },
    {
        zigbeeModel: ['bbfed49c738948b989911f9f9f73d759'],
        model: 'R30W3Z',
        vendor: 'ORVIBO',
        description: 'In-wall switch 3 gang',
        extend: [
            (0, modernExtend_1.deviceEndpoints)({ endpoints: { 'left': 1, 'center': 2, 'right': 3 } }),
            (0, modernExtend_1.onOff)({ endpointNames: ['left', 'center', 'right'] }),
        ],
    },
    {
        zigbeeModel: ['0e93fa9c36bb417a90ad5d8a184b683a'],
        model: 'SM20',
        vendor: 'ORVIBO',
        description: 'Door or window contact switch',
        fromZigbee: [fromZigbee_1.default.ias_contact_alarm_1, fromZigbee_1.default.battery],
        toZigbee: [],
        exposes: [e.contact(), e.battery_low(), e.tamper(), e.battery()],
    },
];
exports.default = definitions;
module.exports = definitions;
//# sourceMappingURL=orvibo.js.map