"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ThermostatControllerSchedule = void 0; const schema_js_1 = require("../schema.js"); const types_js_1 = require("../types.js"); const FAN_MODES = ["ON", "AUTO", "CIRCULATE"]; // alexa-thermostatcontroller-schedule.html, "ScheduleEntry object": an entry ends where the next one starts const entry = schema_js_1.s.object({ startTimeInMinutes: schema_js_1.s.number({ min: 0, max: 1439, integer: true }), setpoints: schema_js_1.s.object({ upperSetpoint: schema_js_1.s.optional(schema_js_1.s.temperature()), lowerSetpoint: schema_js_1.s.optional(schema_js_1.s.temperature()) }), /** Without a mode the fan runs as the manufacturer set it. */ fanSetting: schema_js_1.s.optional(schema_js_1.s.object({ mode: schema_js_1.s.optional(schema_js_1.s.enum(...FAN_MODES)) })), activityType: schema_js_1.s.optional(schema_js_1.s.object({ type: schema_js_1.s.enum("AWAY", "HOME", "SLEEP") })), }); const day = schema_js_1.s.array(entry); // Same page, "WeeklySchedule object" const weeklySchedule = schema_js_1.s.object({ temperatureScale: schema_js_1.s.enum("CELSIUS", "FAHRENHEIT", "KELVIN"), Monday: day, Tuesday: day, Wednesday: day, Thursday: day, Friday: day, Saturday: day, Sunday: day, }); /** * Version 3.2. The schedule a user writes in the Alexa app: the interface has no utterances. Discovery lists * adaptiveRecoveryEnabled for a thermostat declared with supportsAdaptiveRecovery, and Alexa sends * SetAdaptiveRecovery to such a thermostat only. */ exports.ThermostatControllerSchedule = (0, types_js_1.defineInterface)({ namespace: "Alexa.ThermostatController.Schedule", version: "3.2", doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-thermostatcontroller-schedule.html", kind: "controller", tier: 2, instanced: false, properties: { adaptiveRecoveryEnabled: { name: "adaptiveRecoveryEnabled", value: schema_js_1.s.boolean() }, scheduleEnabled: { name: "scheduleEnabled", value: schema_js_1.s.boolean() }, }, directives: { SetWeeklySchedule: { name: "SetWeeklySchedule", payload: schema_js_1.s.object({ weeklySchedule: schema_js_1.s.optional(weeklySchedule) }), note: "a schedule the thermostat cannot keep leaves the one it has and is answered with an error", }, SetScheduleState: { name: "SetScheduleState", payload: schema_js_1.s.object({ scheduleEnabled: schema_js_1.s.boolean() }), note: "a disabled schedule is kept: the user can enable it again", }, SetAdaptiveRecovery: { name: "SetAdaptiveRecovery", payload: schema_js_1.s.object({ adaptiveRecoveryEnabled: schema_js_1.s.boolean() }), when: ({ options }) => options.supportsAdaptiveRecovery === true, }, }, options: schema_js_1.s.object({ supportedFanModes: schema_js_1.s.array(schema_js_1.s.enum(...FAN_MODES)), /** The thermostat heats or cools ahead of an entry, to be at its temperature when it starts. */ supportsAdaptiveRecovery: schema_js_1.s.boolean(), maxEntryPerDay: schema_js_1.s.optional(schema_js_1.s.number({ min: 1, integer: true })), }, { unknownKeys: "reject" }), // A capability declared the 1.x way has none of the options; check() says so, discovery lists what there is discovery({ options: { supportedFanModes, supportsAdaptiveRecovery, maxEntryPerDay } }) { const configuration = { ...(supportedFanModes && { supportedFanModes }), ...(supportsAdaptiveRecovery !== undefined && { supportsAdaptiveRecovery }), ...(maxEntryPerDay !== undefined && { maxEntryPerDay }), }; return { supported: supportsAdaptiveRecovery ? ["adaptiveRecoveryEnabled", "scheduleEnabled"] : ["scheduleEnabled"], ...(Object.keys(configuration).length > 0 && { configuration }), }; }, errorNamespace: "Alexa.ThermostatController.Schedule", errorTypes: ["INSUFFICIENT_SPACE"], });