"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.ubisysModernExtend = void 0;
const zigbee_herdsman_1 = require("zigbee-herdsman");
const exposes = __importStar(require("../lib/exposes"));
const m = __importStar(require("../lib/modernExtend"));
const exposes_1 = require("./exposes");
const logger_1 = require("./logger");
const modernExtend_1 = require("./modernExtend");
const NS = "zhc:ubisys";
exports.ubisysModernExtend = {
    pollCurrentSummDelivered: (endpointId) => {
        return m.poll({
            key: "measurement",
            defaultIntervalSeconds: 60,
            option: exposes.options.measurement_poll_interval(),
            poll: async (device) => {
                const endpoint = device.getEndpoint(typeof endpointId === "number" ? endpointId : endpointId(device));
                await endpoint.read("seMetering", ["currentSummDelivered"]);
            },
        });
    },
    addCustomClusterHvacThermostat: () => (0, modernExtend_1.deviceAddCustomCluster)("hvacThermostat", {
        name: "hvacThermostat",
        ID: 0x0201,
        attributes: {
            // H10
            ubisysClassBTemperatureOffset: {
                name: "ubisysClassBTemperatureOffset",
                ID: 0x0000,
                type: zigbee_herdsman_1.Zcl.DataType.INT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -128,
            },
            ubisysReturnFlowTemperatureWeight: {
                name: "ubisysReturnFlowTemperatureWeight",
                ID: 0x0001,
                type: zigbee_herdsman_1.Zcl.DataType.INT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -128,
            },
            ubisysRawOutdoorTemperature: {
                name: "ubisysRawOutdoorTemperature",
                ID: 0x0002,
                type: zigbee_herdsman_1.Zcl.DataType.STRUCT,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysRawLocalTemperatureA: {
                name: "ubisysRawLocalTemperatureA",
                ID: 0x0003,
                type: zigbee_herdsman_1.Zcl.DataType.STRUCT,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysRawLocalTemperatureB: {
                name: "ubisysRawLocalTemperatureB",
                ID: 0x0004,
                type: zigbee_herdsman_1.Zcl.DataType.STRUCT,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysRawForwardFlowTemperature: {
                name: "ubisysRawForwardFlowTemperature",
                ID: 0x0005,
                type: zigbee_herdsman_1.Zcl.DataType.STRUCT,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysRawReturnFlowTemperature: {
                name: "ubisysRawReturnFlowTemperature",
                ID: 0x0006,
                type: zigbee_herdsman_1.Zcl.DataType.STRUCT,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysInstalledExtensions: {
                name: "ubisysInstalledExtensions",
                ID: 0x0007,
                type: zigbee_herdsman_1.Zcl.DataType.BITMAP64,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // H1
            ubisysTemperatureOffset: {
                name: "ubisysTemperatureOffset",
                ID: 0x0010,
                type: zigbee_herdsman_1.Zcl.DataType.INT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -128,
            },
            ubisysDefaultOccupiedHeatingSetpoint: {
                name: "ubisysDefaultOccupiedHeatingSetpoint",
                ID: 0x0011,
                type: zigbee_herdsman_1.Zcl.DataType.INT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -32768,
            },
            ubisysVacationMode: {
                name: "ubisysVacationMode",
                ID: 0x0012,
                type: zigbee_herdsman_1.Zcl.DataType.BOOLEAN,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysRemoteTemperature: {
                name: "ubisysRemoteTemperature",
                ID: 0x0013,
                type: zigbee_herdsman_1.Zcl.DataType.INT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -32768,
            },
            ubisysRemoteTemperatureValidDuration: {
                name: "ubisysRemoteTemperatureValidDuration",
                ID: 0x0014,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0x15180,
            },
            ubisysDetectOpenWindow: {
                name: "ubisysDetectOpenWindow",
                ID: 0x0015,
                type: zigbee_herdsman_1.Zcl.DataType.BITMAP8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysOpenWindowState: {
                name: "ubisysOpenWindowState",
                ID: 0x0016,
                type: zigbee_herdsman_1.Zcl.DataType.BITMAP8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysOpenWindowSensitivity: {
                name: "ubisysOpenWindowSensitivity",
                ID: 0x0017,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysOpenWindowDetectionPeriod: {
                name: "ubisysOpenWindowDetectionPeriod",
                ID: 0x0018,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysOpenWindowTimeout: {
                name: "ubisysOpenWindowTimeout",
                ID: 0x0019,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysProportionalGain: {
                name: "ubisysProportionalGain",
                ID: 0x0020,
                type: zigbee_herdsman_1.Zcl.DataType.INT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -32768,
            },
            ubisysProportionalShift: {
                name: "ubisysProportionalShift",
                ID: 0x0021,
                type: zigbee_herdsman_1.Zcl.DataType.INT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -128,
            },
            ubisysIntegralFactor: {
                name: "ubisysIntegralFactor",
                ID: 0x0022,
                type: zigbee_herdsman_1.Zcl.DataType.INT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                min: -32768,
            },
        },
        commands: {},
        commandsResponse: {},
    }),
    addCustomClusterGenLevelCtrl: () => (0, modernExtend_1.deviceAddCustomCluster)("genLevelCtrl", {
        name: "genLevelCtrl",
        ID: 0x0008,
        attributes: {
            // D1(-R)
            ubisysMinimumOnLevel: {
                name: "ubisysMinimumOnLevel",
                ID: 0x0000,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            // H10
            ubisysValveType: {
                name: "ubisysValveType",
                ID: 0x0001,
                type: zigbee_herdsman_1.Zcl.DataType.BITMAP8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysCyclePeriod: {
                name: "ubisysCyclePeriod",
                ID: 0x0002,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysSeason: {
                name: "ubisysSeason",
                ID: 0x0003,
                type: zigbee_herdsman_1.Zcl.DataType.ENUM8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysBackupLevel: {
                name: "ubisysBackupLevel",
                ID: 0x0004,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysAlternateBackupLevel: {
                name: "ubisysAlternateBackupLevel",
                ID: 0x0005,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysLowerRange: {
                name: "ubisysLowerRange",
                ID: 0x0006,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysUpperRange: {
                name: "ubisysUpperRange",
                ID: 0x0007,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysPumpThresholdOn: {
                name: "ubisysPumpThresholdOn",
                ID: 0x0008,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysPumpThresholdOff: {
                name: "ubisysPumpThresholdOff",
                ID: 0x0009,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysHeatingDemandEnableThreshold: {
                name: "ubisysHeatingDemandEnableThreshold",
                ID: 0x000a,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysHeatingDemandDisableThreshold: {
                name: "ubisysHeatingDemandDisableThreshold",
                ID: 0x000b,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysCoolingDemandEnableThreshold: {
                name: "ubisysCoolingDemandEnableThreshold",
                ID: 0x000c,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysCoolingDemandDisableThreshold: {
                name: "ubisysCoolingDemandDisableThreshold",
                ID: 0x000d,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
        },
        commands: {},
        commandsResponse: {},
    }),
    addCustomClusterClosuresWindowCovering: () => (0, modernExtend_1.deviceAddCustomCluster)("closuresWindowCovering", {
        name: "closuresWindowCovering",
        ID: 0x0102,
        attributes: {
            // J1(-R)
            // writable version of the same standard attribute
            ubisysWindowCoveringType: {
                name: "ubisysWindowCoveringType",
                ID: 0x0000,
                type: zigbee_herdsman_1.Zcl.DataType.ENUM8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // writable version of the same standard attribute
            ubisysConfigStatus: {
                name: "ubisysConfigStatus",
                ID: 0x0007,
                type: zigbee_herdsman_1.Zcl.DataType.BITMAP8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // writable version of the same standard attribute
            ubisysInstalledOpenLimitLiftCm: {
                name: "ubisysInstalledOpenLimitLiftCm",
                ID: 0x0010,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // writable version of the same standard attribute
            ubisysInstalledClosedLimitLiftCm: {
                name: "ubisysInstalledClosedLimitLiftCm",
                ID: 0x0011,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // writable version of the same standard attribute
            ubisysInstalledOpenLimitTiltDdegree: {
                name: "ubisysInstalledOpenLimitTiltDdegree",
                ID: 0x0012,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            // writable version of the same standard attribute
            ubisysInstalledClosedLimitTiltDdegree: {
                name: "ubisysInstalledClosedLimitTiltDdegree",
                ID: 0x0013,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
            },
            ubisysTurnaroundGuardTime: {
                name: "ubisysTurnaroundGuardTime",
                ID: 0x1000,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysLiftToTiltTransitionSteps: {
                name: "ubisysLiftToTiltTransitionSteps",
                ID: 0x1001,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysTotalSteps: {
                name: "ubisysTotalSteps",
                ID: 0x1002,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysLiftToTiltTransitionSteps2: {
                name: "ubisysLiftToTiltTransitionSteps2",
                ID: 0x1003,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysTotalSteps2: {
                name: "ubisysTotalSteps2",
                ID: 0x1004,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysAdditionalSteps: {
                name: "ubisysAdditionalSteps",
                ID: 0x1005,
                type: zigbee_herdsman_1.Zcl.DataType.UINT8,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xff,
            },
            ubisysInactivePowerThreshold: {
                name: "ubisysInactivePowerThreshold",
                ID: 0x1006,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            ubisysStartupSteps: {
                name: "ubisysStartupSteps",
                ID: 0x1007,
                type: zigbee_herdsman_1.Zcl.DataType.UINT16,
                manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
                write: true,
                max: 0xffff,
            },
            operationalStatus: { name: "operationalStatus", ID: 0x000a, type: zigbee_herdsman_1.Zcl.DataType.BITMAP8 },
        },
        commands: {},
        commandsResponse: {},
    }),
    addCustomClusterManuSpecificUbisysDeviceSetup: () => (0, modernExtend_1.deviceAddCustomCluster)("manuSpecificUbisysDeviceSetup", {
        name: "manuSpecificUbisysDeviceSetup",
        ID: 0xfc00,
        // XXX: once we moved all manuSpecific ones out of zh, we should revisit this
        // Doesn't use manufacturerCode: https://github.com/Koenkk/zigbee-herdsman-converters/pull/4412
        attributes: {
            inputConfigurations: { name: "inputConfigurations", ID: 0x0000, type: zigbee_herdsman_1.Zcl.DataType.ARRAY, write: true },
            inputActions: { name: "inputActions", ID: 0x0001, type: zigbee_herdsman_1.Zcl.DataType.ARRAY, write: true },
        },
        commands: {},
        commandsResponse: {},
    }),
    addCustomClusterManuSpecificUbisysDimmerSetup: () => (0, modernExtend_1.deviceAddCustomCluster)("manuSpecificUbisysDimmerSetup", {
        name: "manuSpecificUbisysDimmerSetup",
        ID: 0xfc01,
        manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH,
        attributes: {
            capabilities: { name: "capabilities", ID: 0x0000, type: zigbee_herdsman_1.Zcl.DataType.BITMAP8, write: true },
            status: { name: "status", ID: 0x0001, type: zigbee_herdsman_1.Zcl.DataType.BITMAP8, write: true },
            mode: { name: "mode", ID: 0x0002, type: zigbee_herdsman_1.Zcl.DataType.BITMAP8, write: true },
        },
        commands: {},
        commandsResponse: {},
    }),
    localTemperatureOffset: (args) => (0, modernExtend_1.numeric)({
        name: "local_temperature_offset",
        cluster: "hvacThermostat",
        attribute: "ubisysTemperatureOffset",
        entityCategory: "config",
        description: "Specifies the temperature offset for the locally measured temperature value.",
        valueMin: -10,
        valueMax: 10,
        unit: "ºC",
        ...args,
    }),
    occupiedHeatingSetpointDefault: (args) => (0, modernExtend_1.numeric)({
        name: "occupied_heating_default_setpoint",
        cluster: "hvacThermostat",
        attribute: "ubisysDefaultOccupiedHeatingSetpoint",
        entityCategory: "config",
        description: "Specifies the default heating setpoint during occupancy, " +
            "representing the targeted temperature when a recurring weekly schedule ends without a follow-up schedule.",
        scale: 100,
        valueStep: 0.5, // H1 interface uses 0.5 step
        valueMin: 7,
        valueMax: 30,
        unit: "ºC",
        ...args,
    }),
    remoteTemperatureDuration: (args) => (0, modernExtend_1.numeric)({
        name: "remote_temperature_duration",
        cluster: "hvacThermostat",
        attribute: "ubisysRemoteTemperatureValidDuration",
        entityCategory: "config",
        description: "Specifies the duration period in seconds, during which a remotely measured temperature value " +
            "remains valid since its reception as attribute report.",
        valueMin: 0,
        valueMax: 86400,
        unit: "s",
        ...args,
    }),
    vacationMode: () => {
        const clusterName = "hvacThermostat";
        const writeableAttributeName = "ubisysVacationMode";
        const readableAttributeName = "occupancy";
        const propertyName = "vacation_mode";
        const access = exposes_1.access.ALL;
        const expose = exposes_1.presets
            .binary(propertyName, access, true, false)
            .withDescription("When Vacation Mode is active the schedule is disabled and unoccupied_heating_setpoint is used.");
        const fromZigbee = [
            {
                cluster: clusterName,
                type: ["attributeReport", "readResponse"],
                convert: (model, msg, publish, options, meta) => {
                    if (msg.data[readableAttributeName] !== undefined) {
                        return { [propertyName]: msg.data.occupancy === 0 };
                    }
                },
            },
        ];
        const toZigbee = [
            {
                key: [propertyName],
                convertSet: async (entity, key, value, meta) => {
                    if (typeof value === "boolean") {
                        await entity.write(clusterName, { [writeableAttributeName]: value ? 1 : 0 }, { manufacturerCode: zigbee_herdsman_1.Zcl.ManufacturerCode.UBISYS_TECHNOLOGIES_GMBH });
                    }
                    else {
                        logger_1.logger.error(`${propertyName} must be a boolean!`, NS);
                    }
                },
                convertGet: async (entity, key, meta) => {
                    await entity.read(clusterName, [readableAttributeName]);
                },
            },
        ];
        const configure = [
            (0, modernExtend_1.setupConfigureForReporting)(clusterName, readableAttributeName, { config: { min: 0, max: "1_HOUR", change: 0 }, access }),
        ];
        return { exposes: [expose], fromZigbee, toZigbee, configure, isModernExtend: true };
    },
    openWindowState: (args) => (0, modernExtend_1.binary)({
        name: "open_window_state",
        cluster: "hvacThermostat",
        attribute: "ubisysOpenWindowState",
        access: "STATE_GET",
        valueOn: [true, 1],
        valueOff: [false, 0],
        description: "Presents the currently detected window state.",
        ...args,
    }),
    openWindowDetect: (args) => (0, modernExtend_1.binary)({
        name: "open_window_detect",
        cluster: "hvacThermostat",
        attribute: "ubisysDetectOpenWindow",
        entityCategory: "config",
        valueOn: [true, 1],
        valueOff: [false, 0],
        description: "Specifies whether the Open Window Detection is activated or deactivated.",
        ...args,
    }),
    openWindowTimeout: (args) => (0, modernExtend_1.numeric)({
        name: "open_window_timeout",
        cluster: "hvacThermostat",
        attribute: "ubisysOpenWindowTimeout",
        entityCategory: "config",
        description: "Specifies the maximum time duration in seconds for a detected open-window state. This attribute " +
            "effectively defines how long a detected open-window state should last before H1 returns back to " +
            "its default set point settings.",
        valueMin: 0,
        valueMax: 86400,
        unit: "s",
        ...args,
    }),
    openWindowDetectionPeriod: (args) => (0, modernExtend_1.numeric)({
        name: "open_window_detection_periode",
        cluster: "hvacThermostat",
        attribute: "ubisysOpenWindowDetectionPeriod",
        entityCategory: "config",
        description: "Specifies the time duration in minutes, within which the sharp temperature change must have taken " +
            "place for the open window detection.",
        valueMin: 1,
        valueMax: 180,
        unit: "m",
        ...args,
    }),
    openWindowSensitivity: (args) => (0, modernExtend_1.numeric)({
        name: "open_window_sensitivity",
        cluster: "hvacThermostat",
        attribute: "ubisysOpenWindowSensitivity",
        entityCategory: "config",
        description: "Specifies the temperature change threshold for the Open Window Detection. This is the point at " +
            "which the H1 detects a significant temperature change indicating the detection of an open or " +
            "closed window.",
        scale: 100,
        valueStep: 0.5, // H1 interface uses 0.5 step
        valueMin: 1,
        valueMax: 30,
        unit: "ºC",
        ...args,
    }),
    operationalStatus: (args) => (0, modernExtend_1.enumLookup)({
        name: "motor_state",
        cluster: "closuresWindowCovering",
        attribute: "operationalStatus",
        entityCategory: "diagnostic",
        description: "This attribute contains two bits which will be set while the motor is active. " +
            "Thus, devices that do not support positioning or move at a slow pace can still provide feedback. " +
            "Exposed as motor_state for compatibility.",
        access: "STATE_GET",
        lookup: { stopped: 0x00, opening: 0x01, closing: 0x02 },
        ...args,
    }),
};
//# sourceMappingURL=ubisys.js.map