registry: ThermostatController 3.2 and ThermostatController.Schedule

The thermostat is described from its page: one, two or three setpoints with holdUntil, AdjustTargetTemperature,
SetThermostatMode with the six modes (EM_HEAT is new), ResumeSchedule, adaptiveRecoveryStatus, and its seven error
types under Alexa.ThermostatController. A declaration gives supportedModes, supportsScheduling and the properties
the device has; without them discovery is what 1.5.2 sent: HEAT, COOL, AUTO, OFF and the three setpoints with
thermostatMode. supportedModes without HEAT or COOL is refused where it is declared.

ThermostatController.Schedule replaces its stub. Wire change for a 1.x declaration of it: version 3.2 (was 1) and
scheduleEnabled listed (was nothing). SetAdaptiveRecovery is taken only with supportsAdaptiveRecovery.

24 examples of three pages are saved as fixtures; the page folds the SetWeeklySchedule example away, its payload
is tested from the tables. 207 tests pass, 191 before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 20:34:49 +00:00
parent af1489696d
commit f555a5df70
67 changed files with 2445 additions and 58 deletions

View file

@ -0,0 +1,97 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThermostatController = exports.THERMOSTAT_MODES = void 0;
const schema_js_1 = require("../schema.js");
const types_js_1 = require("../types.js");
/** alexa-property-schemas.html, "ThermostatMode values". EM_HEAT, emergency heating, came with version 3.2. */
exports.THERMOSTAT_MODES = ["AUTO", "COOL", "ECO", "EM_HEAT", "HEAT", "OFF"];
const PROPERTIES = ["targetSetpoint", "lowerSetpoint", "upperSetpoint", "thermostatMode", "adaptiveRecoveryStatus"];
// What 1.x announced for every thermostat. A declaration that leaves an option out announces the same.
const MODES_OF_1X = ["HEAT", "COOL", "AUTO", "OFF"];
const PROPERTIES_OF_1X = ["targetSetpoint", "lowerSetpoint", "upperSetpoint", "thermostatMode"];
const setpoints = schema_js_1.s.object({
targetSetpoint: schema_js_1.s.optional(schema_js_1.s.temperature()),
lowerSetpoint: schema_js_1.s.optional(schema_js_1.s.temperature()),
upperSetpoint: schema_js_1.s.optional(schema_js_1.s.temperature()),
holdUntil: schema_js_1.s.optional(schema_js_1.s.timeInterval()),
});
// One setpoint for a thermostat that holds a temperature, the lower and the upper for one that holds a range, all
// three for one that aims at a temperature within a range. The page marks each as not required; a payload without
// any sets nothing.
const setTargetTemperature = {
expects: "one or more of targetSetpoint, lowerSetpoint, upperSetpoint",
parse(input, path = "") {
const payload = setpoints.parse(input, path);
if (!payload.targetSetpoint && !payload.lowerSetpoint && !payload.upperSetpoint)
throw (0, schema_js_1.mismatch)(path, this.expects, input);
return payload;
},
};
/**
* Version 3.2. A thermostat declares the properties it has: targetSetpoint for a single setpoint, lowerSetpoint and
* upperSetpoint for two, all three for a target within a range. Temperatures are reported "in the same temperature
* scale (Celsius or Fahrenheit) that the thermostat is set to display". An error of errorTypes goes under the
* namespace of the interface, TEMPERATURE_VALUE_OUT_OF_RANGE under Alexa
* (alexa-thermostatcontroller-errorresponse.html).
*/
exports.ThermostatController = (0, types_js_1.defineInterface)({
namespace: "Alexa.ThermostatController",
version: "3.2",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-thermostatcontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
targetSetpoint: { name: "targetSetpoint", value: schema_js_1.s.temperature() },
lowerSetpoint: { name: "lowerSetpoint", value: schema_js_1.s.temperature() },
upperSetpoint: { name: "upperSetpoint", value: schema_js_1.s.temperature() },
thermostatMode: { name: "thermostatMode", value: schema_js_1.s.enum(...exports.THERMOSTAT_MODES) },
adaptiveRecoveryStatus: {
name: "adaptiveRecoveryStatus",
value: schema_js_1.s.enum("PREHEATING", "PRECOOLING", "INACTIVE"),
note: "heating or cooling ahead of an entry of the schedule, of Alexa.ThermostatController.Schedule",
},
},
directives: {
SetTargetTemperature: {
name: "SetTargetTemperature",
payload: setTargetTemperature,
note: "holdUntil comes only to a thermostat declared with supportsScheduling",
},
AdjustTargetTemperature: { name: "AdjustTargetTemperature", payload: schema_js_1.s.object({ targetSetpointDelta: schema_js_1.s.temperature() }) },
SetThermostatMode: {
name: "SetThermostatMode",
payload: schema_js_1.s.object({ thermostatMode: schema_js_1.s.object({ value: schema_js_1.s.enum(...exports.THERMOSTAT_MODES) }) }),
},
ResumeSchedule: { name: "ResumeSchedule", payload: schema_js_1.s.object({}), note: "en-US only" },
},
options: schema_js_1.s.object({
/** Default: HEAT, COOL, AUTO, OFF. */
supportedModes: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.enum(...exports.THERMOSTAT_MODES), { min: 1 })),
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: schema_js_1.s.optional(schema_js_1.s.boolean()),
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.enum(...PROPERTIES), { min: 1 })),
}, { unknownKeys: "reject" }),
discovery({ options: { supportedModes = MODES_OF_1X, supportsScheduling = false, properties = PROPERTIES_OF_1X } }) {
return { supported: properties, configuration: { supportedModes, supportsScheduling } };
},
validate(capability) {
const { supportedModes = MODES_OF_1X, properties = PROPERTIES_OF_1X } = capability.options;
// alexa-thermostatcontroller.html, "Configuration object": "You must include at least one of HEAT or COOL"
if (!supportedModes.includes("HEAT") && !supportedModes.includes("COOL")) {
throw new types_js_1.DeclarationError(capability, `supportedModes ${supportedModes.join(", ")} has neither HEAT nor COOL, Alexa wants one`);
}
const lists = [supportedModes, properties];
for (const list of lists) {
const twice = list.find((entry, i) => list.indexOf(entry) !== i);
if (twice)
throw new types_js_1.DeclarationError(capability, `${twice} is listed twice`);
}
},
errorNamespace: "Alexa.ThermostatController",
errorTypes: [
"DUAL_SETPOINTS_UNSUPPORTED", "REQUESTED_SETPOINTS_TOO_CLOSE", "THERMOSTAT_IS_OFF", "TRIPLE_SETPOINTS_UNSUPPORTED",
"UNSUPPORTED_THERMOSTAT_MODE", "UNWILLING_TO_SET_SCHEDULE", "UNWILLING_TO_SET_VALUE",
],
});

View file

@ -0,0 +1,80 @@
"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"],
});

View file

@ -59,10 +59,8 @@ const TABLE = [
["Alexa.SmartVision.SnapshotProvider", "1", [], "alexa-smartvision-snapshotprovider.html"],
["Alexa.Speaker", "1", [], "alexa-speaker.html"],
["Alexa.StepSpeaker", "1", [], "alexa-stepspeaker.html"],
["Alexa.ThermostatController", "3.2", ["targetSetpoint", "lowerSetpoint", "upperSetpoint", "thermostatMode"], "alexa-thermostatcontroller.html"],
["Alexa.ThermostatController.Configuration", "1", [], "alexa-thermostatcontroller-configuration.html"],
["Alexa.ThermostatController.HVAC.Components", "1", [], "alexa-thermostatcontroller-hvac-components.html"],
["Alexa.ThermostatController.Schedule", "1", [], "alexa-thermostatcontroller-schedule.html"],
// "UNKNOWN" in 1.5.2 as well; the page is titled "Interface 3"
["Alexa.TimeHoldController", "3", [], "alexa-timeholdcontroller.html"],
["Alexa.UIController", "1", [], "alexa-uicontroller.html"],
@ -70,16 +68,13 @@ const TABLE = [
["Alexa.VideoRecorder", "1", [], "alexa-videorecorder.html"],
["Alexa.WakeOnLANController", "1", [], "alexa-wakeonlancontroller.html"],
];
// What 1.5.2 added to the capability object of two of them
// What 1.5.2 added to the capability object of one of them
const EXTRAS = {
// No properties object; supportsDeactivation and proactivelyReported on the capability itself
"Alexa.SceneController": ({ proactivelyReported }) => ({
properties: false,
topLevel: { supportsDeactivation: true, proactivelyReported },
}),
"Alexa.ThermostatController": () => ({
configuration: { supportedModes: ["HEAT", "COOL", "AUTO", "OFF"], supportsScheduling: false },
}),
};
function kindOf(namespace) {
if (namespace.endsWith("Sensor"))