"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 = void 0;
const fz = __importStar(require("../converters/fromZigbee"));
const ptvo = __importStar(require("../devices/custom_devices_diy"));
const exposes = __importStar(require("../lib/exposes"));
const m = __importStar(require("../lib/modernExtend"));
const e = exposes.presets;
const ea = exposes.access;
const tzLocal = {
    ptvo_senseair_calibration: {
        key: ["calibrate"],
        convertSet: async (entity, key, value, meta) => {
            if (!value)
                return;
            // presentValue is a single-precision float (ZCL type 0x39)
            // ZERO = force zero-point calibration, SPAN = span calibration
            const writeValue = value === "ZERO" ? 0x00 : 0x01;
            await entity.write("genAnalogInput", { 85: { value: writeValue, type: 0x39 } });
        },
        convertGet: async (entity, key, meta) => {
            await entity.read("genAnalogInput", ["presentValue"]);
        },
    },
};
exports.definitions = [
    {
        zigbeeModel: ["msh.AirQMon"],
        model: "msh.AirQMon",
        vendor: "MySmartHouse",
        description: "MSH Air quality sensor",
        fromZigbee: [ptvo.fzLocal.ptvo_switch_uart, fz.co2, ptvo.fzLocal.ptvo_switch_analog_input, fz.temperature],
        toZigbee: [ptvo.tzLocal.ptvo_switch_trigger, ptvo.tzLocal.ptvo_switch_uart, tzLocal.ptvo_senseair_calibration],
        exposes: [
            e.text("action", ea.STATE_SET).withDescription("button clicks or data from/to UART"),
            e.enum("calibrate", ea.STATE_SET, ["ZERO", "SPAN"]).withEndpoint("l2").withDescription("Calibration"),
            e.co2(),
            e.numeric("l2", ea.STATE).withDescription("Error"),
            e.cpu_temperature().withProperty("temperature").withEndpoint("l3"),
            e.numeric("l4", ea.STATE).withDescription("Uptime (seconds)"),
        ],
        meta: { multiEndpoint: true },
        endpoint: (device) => ({ l2: 2, action: 1, l3: 3, l4: 4 }),
    },
    {
        zigbeeModel: ["msh.bme280psm"],
        model: "msh.bme280psm",
        vendor: "MySmartHouse",
        description: "MSH outdoor thermometer with BME280",
        extend: [m.battery(), m.temperature(), m.humidity(), m.pressure()],
    },
    {
        zigbeeModel: ["msh.ds18b20psm"],
        model: "msh.ds18b20psm",
        vendor: "MySmartHouse",
        description: "MSH outdoor thermometer with DS18B20",
        extend: [m.battery(), m.temperature()],
    },
];
//# sourceMappingURL=msh.js.map