"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 tz = __importStar(require("../converters/toZigbee"));
const exposes = __importStar(require("../lib/exposes"));
const m = __importStar(require("../lib/modernExtend"));
const reporting = __importStar(require("../lib/reporting"));
const stelpro = __importStar(require("./stelpro"));
const e = exposes.presets;
const ea = exposes.access;
exports.definitions = [
    {
        zigbeeModel: ["STLO-34"],
        model: "STLO-34",
        vendor: "Stello",
        description: "Hilo thermostat",
        extend: [stelpro.stelproExtend.addStelproHvacThermostatCluster()],
        fromZigbee: [stelpro.fzLocal.stelpro_thermostat, fz.hvac_user_interface, stelpro.fzLocal.power, stelpro.fzLocal.energy],
        toZigbee: [
            tz.thermostat_local_temperature,
            tz.thermostat_occupancy,
            tz.thermostat_occupied_heating_setpoint,
            tz.thermostat_temperature_display_mode,
            tz.thermostat_keypad_lockout,
            tz.thermostat_system_mode,
            tz.thermostat_running_state,
            stelpro.tzLocal.peak_demand_event_icon,
            stelpro.tzLocal.thermostat_outdoor_temperature,
        ],
        exposes: [
            e.local_temperature(),
            e.keypad_lockout(),
            e.power(),
            e.energy(),
            e
                .climate()
                .withSetpoint("occupied_heating_setpoint", 5, 30, 0.5)
                .withLocalTemperature()
                .withSystemMode(["heat"])
                .withRunningState(["idle", "heat"]),
            e
                .numeric("peak_demand_icon", ea.SET)
                .withUnit("hours")
                .withDescription("Set peak demand event icon for the specified number of hours")
                .withValueMin(0)
                .withValueMax(18),
            e
                .numeric("outdoor_temperature_display", ea.SET)
                .withUnit("°C")
                .withDescription("Outdoor temperature displayed on the thermostat")
                .withValueMin(-32)
                .withValueMax(199),
        ],
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(25);
            const binds = ["genBasic", "genIdentify", "genGroups", "hvacThermostat", "hvacUserInterfaceCfg", "msTemperatureMeasurement"];
            await reporting.bind(endpoint, coordinatorEndpoint, binds);
            await reporting.thermostatTemperature(endpoint);
            await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
            await reporting.thermostatSystemMode(endpoint);
            await reporting.thermostatPIHeatingDemand(endpoint);
            await reporting.thermostatKeypadLockMode(endpoint);
            // Has Unknown power source, force it.
            device.powerSource = "Mains (single phase)";
            device.save();
        },
    },
    {
        zigbeeModel: ["STLO-23"],
        model: "STLO-23",
        vendor: "Stello",
        description: "Hilo water heater controller",
        extend: [m.onOff({ powerOnBehavior: false }), m.electricityMeter({ cluster: "metering" })],
        toZigbee: [stelpro.tzLocal.peak_demand_event_icon],
        exposes: [
            e
                .numeric("peak_demand_icon", ea.SET)
                .withUnit("hours")
                .withDescription("Set peak demand event icon for the specified number of hours")
                .withValueMin(0)
                .withValueMax(18),
        ],
        // Missing manufacturer specific FC02 cluster with attributes at
        // 0002: CCRDureeSalubre (min 1s, max 600s, min change 1)
        // 0004: CCRSalubre (min 1s, max 300s, min change 1)
        // 0005: CCRTempEau (min 60s, max 60s, min change 1)
        // 0006: CCRTempFc (min 5s, max 60s, min change 1)
    },
];
//# sourceMappingURL=stello.js.map