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

@ -56,9 +56,9 @@ class AlexaInterface extends Capability_js_1.Capability {
getVersion() {
return this.descriptor.version;
}
/** @deprecated Read the keys of descriptor.properties. */
/** @deprecated The properties discovery lists: read properties.supported of toJSON(). */
getProps() {
return Object.keys(this.descriptor.properties);
return (super.toJSON().properties?.supported ?? []).map(({ name }) => name);
}
getJSON() {
return super.toJSON();

View file

@ -172,6 +172,8 @@ var ThermostatMode;
ThermostatMode["AUTO"] = "AUTO";
ThermostatMode["ECO"] = "ECO";
ThermostatMode["CUSTOM"] = "CUSTOM";
/** Emergency heating, since 2.0. */
ThermostatMode["EM_HEAT"] = "EM_HEAT";
})(ThermostatMode || (exports.ThermostatMode = ThermostatMode = {}));
/** The scale of a temperature given to addTemperatureSensorProp() and addThermostatControllerProp(). */
var TemperatureSensorScale;

View file

@ -63,7 +63,7 @@ class Capability {
};
if (extras.properties !== false) {
json.properties = {
supported: Object.keys(descriptor.properties).map((name) => ({ name })),
supported: (extras.supported ?? Object.keys(descriptor.properties)).map((name) => ({ name })),
proactivelyReported: this.proactivelyReported,
retrievable: this.retrievable,
};

7
dist/cjs/index.js vendored
View file

@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlexaStatusMessage = exports.ThermostatMode = exports.TemperatureSensorScale = exports.PowerState = exports.DisplayCategory = exports.AlexaInterfaceType = exports.AlexaErrorType = exports.AlexaActions = exports.ActionMapping = exports.AlexaInterface = exports.MemoryPublisher = exports.topics = exports.property = exports.StateBuilder = exports.MessageError = exports.AlexaErrors = exports.AlexaError = exports.messages = exports.DisplayCategories = exports.States = exports.Actions = exports.Units = exports.Assets = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.EndpointHealth = exports.PowerController = exports.ToggleController = exports.TemperatureSensor = exports.RangeController = exports.PowerLevelController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.SchemaError = exports.DeclarationError = exports.registry = exports.Capability = exports.Device = exports.DEFAULT_HOST = exports.Alex2MQTT = void 0;
exports.AlexaErrorResponse = void 0;
exports.PowerState = exports.DisplayCategory = exports.AlexaInterfaceType = exports.AlexaErrorType = exports.AlexaActions = exports.ActionMapping = exports.AlexaInterface = exports.MemoryPublisher = exports.topics = exports.property = exports.StateBuilder = exports.MessageError = exports.AlexaErrors = exports.AlexaError = exports.messages = exports.ThermostatModes = exports.DisplayCategories = exports.States = exports.Actions = exports.Units = exports.Assets = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.EndpointHealth = exports.PowerController = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.RangeController = exports.PowerLevelController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.SchemaError = exports.DeclarationError = exports.registry = exports.Capability = exports.Device = exports.DEFAULT_HOST = exports.Alex2MQTT = void 0;
exports.AlexaErrorResponse = exports.AlexaStatusMessage = exports.ThermostatMode = exports.TemperatureSensorScale = void 0;
// Relative specifiers carry ".js": Node's ES module loader resolves no extension, and TypeScript maps it back to the .ts.
var Alex2Node_js_1 = require("./Alex2Node.js");
Object.defineProperty(exports, "Alex2MQTT", { enumerable: true, get: function () { return __importDefault(Alex2Node_js_1).default; } });
@ -65,6 +65,8 @@ Object.defineProperty(exports, "PercentageController", { enumerable: true, get:
Object.defineProperty(exports, "PowerLevelController", { enumerable: true, get: function () { return index_js_2.PowerLevelController; } });
Object.defineProperty(exports, "RangeController", { enumerable: true, get: function () { return index_js_2.RangeController; } });
Object.defineProperty(exports, "TemperatureSensor", { enumerable: true, get: function () { return index_js_2.TemperatureSensor; } });
Object.defineProperty(exports, "ThermostatController", { enumerable: true, get: function () { return index_js_2.ThermostatController; } });
Object.defineProperty(exports, "ThermostatControllerSchedule", { enumerable: true, get: function () { return index_js_2.ThermostatControllerSchedule; } });
Object.defineProperty(exports, "ToggleController", { enumerable: true, get: function () { return index_js_2.ToggleController; } });
var enums_js_1 = require("./compat/enums.js");
Object.defineProperty(exports, "PowerController", { enumerable: true, get: function () { return enums_js_1.PowerController; } });
@ -81,6 +83,7 @@ Object.defineProperty(exports, "Units", { enumerable: true, get: function () { r
Object.defineProperty(exports, "Actions", { enumerable: true, get: function () { return index_js_4.ACTIONS; } });
Object.defineProperty(exports, "States", { enumerable: true, get: function () { return index_js_4.STATES; } });
Object.defineProperty(exports, "DisplayCategories", { enumerable: true, get: function () { return index_js_4.DISPLAY_CATEGORIES; } });
Object.defineProperty(exports, "ThermostatModes", { enumerable: true, get: function () { return index_js_4.THERMOSTAT_MODES; } });
// The messages: what the bridge publishes, built from plain values
exports.messages = __importStar(require("./messages/index.js"));
var index_js_5 = require("./messages/index.js");

View file

@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaError = exports.s = exports.defineInterface = exports.DeclarationError = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.ToggleController = exports.TemperatureSensor = exports.RangeController = exports.PowerLevelController = exports.PowerController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.EndpointHealth = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.registry = void 0;
exports.SchemaError = exports.s = exports.defineInterface = exports.DeclarationError = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.THERMOSTAT_MODES = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.RangeController = exports.PowerLevelController = exports.PowerController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.EndpointHealth = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.registry = void 0;
// The interfaces the library knows, by namespace.
const Alexa_js_1 = require("./interfaces/Alexa.js");
Object.defineProperty(exports, "Alexa", { enumerable: true, get: function () { return Alexa_js_1.Alexa; } });
@ -46,6 +46,10 @@ const RangeController_js_1 = require("./interfaces/RangeController.js");
Object.defineProperty(exports, "RangeController", { enumerable: true, get: function () { return RangeController_js_1.RangeController; } });
const TemperatureSensor_js_1 = require("./interfaces/TemperatureSensor.js");
Object.defineProperty(exports, "TemperatureSensor", { enumerable: true, get: function () { return TemperatureSensor_js_1.TemperatureSensor; } });
const ThermostatController_js_1 = require("./interfaces/ThermostatController.js");
Object.defineProperty(exports, "ThermostatController", { enumerable: true, get: function () { return ThermostatController_js_1.ThermostatController; } });
const ThermostatControllerSchedule_js_1 = require("./interfaces/ThermostatControllerSchedule.js");
Object.defineProperty(exports, "ThermostatControllerSchedule", { enumerable: true, get: function () { return ThermostatControllerSchedule_js_1.ThermostatControllerSchedule; } });
const ToggleController_js_1 = require("./interfaces/ToggleController.js");
Object.defineProperty(exports, "ToggleController", { enumerable: true, get: function () { return ToggleController_js_1.ToggleController; } });
const stubs_js_1 = require("./interfaces/stubs.js");
@ -66,6 +70,8 @@ const described = [
PowerLevelController_js_1.PowerLevelController,
RangeController_js_1.RangeController,
TemperatureSensor_js_1.TemperatureSensor,
ThermostatController_js_1.ThermostatController,
ThermostatControllerSchedule_js_1.ThermostatControllerSchedule,
ToggleController_js_1.ToggleController,
];
const descriptors = new Map();
@ -92,6 +98,8 @@ exports.registry = {
return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1));
},
};
var ThermostatController_js_2 = require("./interfaces/ThermostatController.js");
Object.defineProperty(exports, "THERMOSTAT_MODES", { enumerable: true, get: function () { return ThermostatController_js_2.THERMOSTAT_MODES; } });
var resources_js_1 = require("./resources.js");
Object.defineProperty(exports, "asset", { enumerable: true, get: function () { return resources_js_1.asset; } });
Object.defineProperty(exports, "text", { enumerable: true, get: function () { return resources_js_1.text; } });

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"))

View file

@ -51,7 +51,7 @@ export declare class AlexaInterface extends Capability<any, any, Options> {
getTypeString(): string;
/** @deprecated Read descriptor.version. */
getVersion(): string;
/** @deprecated Read the keys of descriptor.properties. */
/** @deprecated The properties discovery lists: read properties.supported of toJSON(). */
getProps(): string[];
getJSON(): CapabilityJson;
toJSON(): CapabilityJson;

View file

@ -53,9 +53,9 @@ export class AlexaInterface extends Capability {
getVersion() {
return this.descriptor.version;
}
/** @deprecated Read the keys of descriptor.properties. */
/** @deprecated The properties discovery lists: read properties.supported of toJSON(). */
getProps() {
return Object.keys(this.descriptor.properties);
return (super.toJSON().properties?.supported ?? []).map(({ name }) => name);
}
getJSON() {
return super.toJSON();

View file

@ -199,7 +199,9 @@ export declare enum ThermostatMode {
COOL = "COOL",
AUTO = "AUTO",
ECO = "ECO",
CUSTOM = "CUSTOM"
CUSTOM = "CUSTOM",
/** Emergency heating, since 2.0. */
EM_HEAT = "EM_HEAT"
}
/** The scale of a temperature given to addTemperatureSensorProp() and addThermostatControllerProp(). */
export declare enum TemperatureSensorScale {

View file

@ -169,6 +169,8 @@ export var ThermostatMode;
ThermostatMode["AUTO"] = "AUTO";
ThermostatMode["ECO"] = "ECO";
ThermostatMode["CUSTOM"] = "CUSTOM";
/** Emergency heating, since 2.0. */
ThermostatMode["EM_HEAT"] = "EM_HEAT";
})(ThermostatMode || (ThermostatMode = {}));
/** The scale of a temperature given to addTemperatureSensorProp() and addThermostatControllerProp(). */
export var TemperatureSensorScale;

View file

@ -60,7 +60,7 @@ export class Capability {
};
if (extras.properties !== false) {
json.properties = {
supported: Object.keys(descriptor.properties).map((name) => ({ name })),
supported: (extras.supported ?? Object.keys(descriptor.properties)).map((name) => ({ name })),
proactivelyReported: this.proactivelyReported,
retrievable: this.retrievable,
};

6
dist/esm/index.d.ts vendored
View file

@ -5,11 +5,11 @@ export type { EndpointDefinition, EndpointJson } from "./device/Device.js";
export { Capability } from "./device/Capability.js";
export type { CapabilityJson, CommonOptions, Declaration } from "./device/Capability.js";
export { registry, DeclarationError, SchemaError } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js";
export { PowerController, EndpointHealth } from "./compat/enums.js";
export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export * as messages from "./messages/index.js";
export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js";

4
dist/esm/index.js vendored
View file

@ -4,11 +4,11 @@ export { default as Device } from "./device/Device.js";
export { Capability } from "./device/Capability.js";
// The interfaces, for device.add(), and the registry that holds them by name
export { registry, DeclarationError, SchemaError } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js";
export { PowerController, EndpointHealth } from "./compat/enums.js";
export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js";
// The vocabularies of the Smart Home API
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js";
// The messages: what the bridge publishes, built from plain values
export * as messages from "./messages/index.js";
export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js";

View file

@ -13,6 +13,8 @@ import { PowerController } from "./interfaces/PowerController.js";
import { PowerLevelController } from "./interfaces/PowerLevelController.js";
import { RangeController } from "./interfaces/RangeController.js";
import { TemperatureSensor } from "./interfaces/TemperatureSensor.js";
import { ThermostatController } from "./interfaces/ThermostatController.js";
import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js";
import { ToggleController } from "./interfaces/ToggleController.js";
import type { AnyDescriptor } from "./types.js";
export declare const registry: {
@ -23,8 +25,10 @@ export declare const registry: {
/** Every descriptor, ordered by namespace. */
list(): AnyDescriptor[];
};
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, };
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, };
export type { Mode } from "./interfaces/ModeController.js";
export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js";
export type { ThermostatModeName } from "./interfaces/ThermostatController.js";
export { asset, text } from "./resources.js";
export { semantics, SemanticsBuilder } from "./semantics.js";
export type { ActionName, StateName } from "./semantics.js";

View file

@ -14,6 +14,8 @@ import { PowerController } from "./interfaces/PowerController.js";
import { PowerLevelController } from "./interfaces/PowerLevelController.js";
import { RangeController } from "./interfaces/RangeController.js";
import { TemperatureSensor } from "./interfaces/TemperatureSensor.js";
import { ThermostatController } from "./interfaces/ThermostatController.js";
import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js";
import { ToggleController } from "./interfaces/ToggleController.js";
import { STUBS } from "./interfaces/stubs.js";
import { DeclarationError } from "./types.js";
@ -33,6 +35,8 @@ const described = [
PowerLevelController,
RangeController,
TemperatureSensor,
ThermostatController,
ThermostatControllerSchedule,
ToggleController,
];
const descriptors = new Map();
@ -59,7 +63,8 @@ export const registry = {
return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1));
},
};
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, };
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, };
export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js";
export { asset, text } from "./resources.js";
export { semantics, SemanticsBuilder } from "./semantics.js";
export { DeclarationError, defineInterface } from "./types.js";

View file

@ -0,0 +1,71 @@
import type { Schema } from "../schema.js";
/** alexa-property-schemas.html, "ThermostatMode values". EM_HEAT, emergency heating, came with version 3.2. */
export declare const THERMOSTAT_MODES: readonly ["AUTO", "COOL", "ECO", "EM_HEAT", "HEAT", "OFF"];
export type ThermostatModeName = (typeof THERMOSTAT_MODES)[number];
/**
* 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).
*/
export declare const ThermostatController: import("../types.js").InterfaceDescriptor<{
targetSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
lowerSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
upperSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
thermostatMode: {
name: string;
value: import("../schema.js").EnumSchema<"ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT">;
};
adaptiveRecoveryStatus: {
name: string;
value: import("../schema.js").EnumSchema<"PREHEATING" | "PRECOOLING" | "INACTIVE">;
note: string;
};
}, {
SetTargetTemperature: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
targetSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
holdUntil: import("../schema.js").OptionalSchema<import("../schema.js").TimeInterval>;
}>>;
note: string;
};
AdjustTargetTemperature: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
targetSetpointDelta: Schema<import("../schema.js").Temperature>;
}>>;
};
SetThermostatMode: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
thermostatMode: Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT">;
}>>;
}>>;
};
ResumeSchedule: {
name: string;
payload: Schema<import("../schema.js").InferShape<{}>>;
note: string;
};
}, import("../schema.js").InferShape<{
/** Default: HEAT, COOL, AUTO, OFF. */
supportedModes: import("../schema.js").OptionalSchema<("ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT")[]>;
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: import("../schema.js").OptionalSchema<boolean>;
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: import("../schema.js").OptionalSchema<("targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "thermostatMode" | "adaptiveRecoveryStatus")[]>;
}>, false>;

View file

@ -0,0 +1,94 @@
import { mismatch, s } from "../schema.js";
import { DeclarationError, defineInterface } from "../types.js";
/** alexa-property-schemas.html, "ThermostatMode values". EM_HEAT, emergency heating, came with version 3.2. */
export const 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 = s.object({
targetSetpoint: s.optional(s.temperature()),
lowerSetpoint: s.optional(s.temperature()),
upperSetpoint: s.optional(s.temperature()),
holdUntil: s.optional(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 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).
*/
export const ThermostatController = 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: s.temperature() },
lowerSetpoint: { name: "lowerSetpoint", value: s.temperature() },
upperSetpoint: { name: "upperSetpoint", value: s.temperature() },
thermostatMode: { name: "thermostatMode", value: s.enum(...THERMOSTAT_MODES) },
adaptiveRecoveryStatus: {
name: "adaptiveRecoveryStatus",
value: 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: s.object({ targetSetpointDelta: s.temperature() }) },
SetThermostatMode: {
name: "SetThermostatMode",
payload: s.object({ thermostatMode: s.object({ value: s.enum(...THERMOSTAT_MODES) }) }),
},
ResumeSchedule: { name: "ResumeSchedule", payload: s.object({}), note: "en-US only" },
},
options: s.object({
/** Default: HEAT, COOL, AUTO, OFF. */
supportedModes: s.optional(s.array(s.enum(...THERMOSTAT_MODES), { min: 1 })),
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: s.optional(s.boolean()),
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: s.optional(s.array(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 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 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,142 @@
/**
* 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.
*/
export declare const ThermostatControllerSchedule: import("../types.js").InterfaceDescriptor<{
adaptiveRecoveryEnabled: {
name: string;
value: import("../schema.js").Schema<boolean>;
};
scheduleEnabled: {
name: string;
value: import("../schema.js").Schema<boolean>;
};
}, {
SetWeeklySchedule: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
weeklySchedule: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
temperatureScale: import("../schema.js").EnumSchema<"CELSIUS" | "FAHRENHEIT" | "KELVIN">;
Monday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Tuesday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Wednesday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Thursday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Friday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Saturday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Sunday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
}>>;
}>>;
note: string;
};
SetScheduleState: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
scheduleEnabled: import("../schema.js").Schema<boolean>;
}>>;
note: string;
};
SetAdaptiveRecovery: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
adaptiveRecoveryEnabled: import("../schema.js").Schema<boolean>;
}>>;
when: ({ options }: import("../types.js").Declared<any>) => boolean;
};
}, import("../schema.js").InferShape<{
supportedFanModes: import("../schema.js").Schema<("ON" | "AUTO" | "CIRCULATE")[]>;
/** The thermostat heats or cools ahead of an entry, to be at its temperature when it starts. */
supportsAdaptiveRecovery: import("../schema.js").Schema<boolean>;
maxEntryPerDay: import("../schema.js").OptionalSchema<number>;
}>, false>;

View file

@ -0,0 +1,77 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
const FAN_MODES = ["ON", "AUTO", "CIRCULATE"];
// alexa-thermostatcontroller-schedule.html, "ScheduleEntry object": an entry ends where the next one starts
const entry = s.object({
startTimeInMinutes: s.number({ min: 0, max: 1439, integer: true }),
setpoints: s.object({ upperSetpoint: s.optional(s.temperature()), lowerSetpoint: s.optional(s.temperature()) }),
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: s.optional(s.object({ mode: s.optional(s.enum(...FAN_MODES)) })),
activityType: s.optional(s.object({ type: s.enum("AWAY", "HOME", "SLEEP") })),
});
const day = s.array(entry);
// Same page, "WeeklySchedule object"
const weeklySchedule = s.object({
temperatureScale: 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.
*/
export const ThermostatControllerSchedule = 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: s.boolean() },
scheduleEnabled: { name: "scheduleEnabled", value: s.boolean() },
},
directives: {
SetWeeklySchedule: {
name: "SetWeeklySchedule",
payload: s.object({ weeklySchedule: 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: s.object({ scheduleEnabled: s.boolean() }),
note: "a disabled schedule is kept: the user can enable it again",
},
SetAdaptiveRecovery: {
name: "SetAdaptiveRecovery",
payload: s.object({ adaptiveRecoveryEnabled: s.boolean() }),
when: ({ options }) => options.supportsAdaptiveRecovery === true,
},
},
options: s.object({
supportedFanModes: s.array(s.enum(...FAN_MODES)),
/** The thermostat heats or cools ahead of an entry, to be at its temperature when it starts. */
supportsAdaptiveRecovery: s.boolean(),
maxEntryPerDay: s.optional(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

@ -56,10 +56,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"],
@ -67,16 +65,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"))

View file

@ -76,6 +76,8 @@ export interface CapabilityExtras {
topLevel?: Record<string, unknown>;
/** false: the capability has no properties object (the Alexa interface, a scene). */
properties?: false;
/** The properties the capability lists, where a declaration has some of those of the interface. Default: all. */
supported?: readonly string[];
}
/** A capability as declared on an endpoint: what discovery() and validate() of its descriptor are given. */
export interface Declared<O = unknown> {

View file

@ -51,7 +51,7 @@ export declare class AlexaInterface extends Capability<any, any, Options> {
getTypeString(): string;
/** @deprecated Read descriptor.version. */
getVersion(): string;
/** @deprecated Read the keys of descriptor.properties. */
/** @deprecated The properties discovery lists: read properties.supported of toJSON(). */
getProps(): string[];
getJSON(): CapabilityJson;
toJSON(): CapabilityJson;

View file

@ -199,7 +199,9 @@ export declare enum ThermostatMode {
COOL = "COOL",
AUTO = "AUTO",
ECO = "ECO",
CUSTOM = "CUSTOM"
CUSTOM = "CUSTOM",
/** Emergency heating, since 2.0. */
EM_HEAT = "EM_HEAT"
}
/** The scale of a temperature given to addTemperatureSensorProp() and addThermostatControllerProp(). */
export declare enum TemperatureSensorScale {

View file

@ -5,11 +5,11 @@ export type { EndpointDefinition, EndpointJson } from "./device/Device.js";
export { Capability } from "./device/Capability.js";
export type { CapabilityJson, CommonOptions, Declaration } from "./device/Capability.js";
export { registry, DeclarationError, SchemaError } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, } from "./registry/index.js";
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js";
export { PowerController, EndpointHealth } from "./compat/enums.js";
export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export * as messages from "./messages/index.js";
export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js";

View file

@ -13,6 +13,8 @@ import { PowerController } from "./interfaces/PowerController.js";
import { PowerLevelController } from "./interfaces/PowerLevelController.js";
import { RangeController } from "./interfaces/RangeController.js";
import { TemperatureSensor } from "./interfaces/TemperatureSensor.js";
import { ThermostatController } from "./interfaces/ThermostatController.js";
import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js";
import { ToggleController } from "./interfaces/ToggleController.js";
import type { AnyDescriptor } from "./types.js";
export declare const registry: {
@ -23,8 +25,10 @@ export declare const registry: {
/** Every descriptor, ordered by namespace. */
list(): AnyDescriptor[];
};
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, };
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, };
export type { Mode } from "./interfaces/ModeController.js";
export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js";
export type { ThermostatModeName } from "./interfaces/ThermostatController.js";
export { asset, text } from "./resources.js";
export { semantics, SemanticsBuilder } from "./semantics.js";
export type { ActionName, StateName } from "./semantics.js";

View file

@ -0,0 +1,71 @@
import type { Schema } from "../schema.js";
/** alexa-property-schemas.html, "ThermostatMode values". EM_HEAT, emergency heating, came with version 3.2. */
export declare const THERMOSTAT_MODES: readonly ["AUTO", "COOL", "ECO", "EM_HEAT", "HEAT", "OFF"];
export type ThermostatModeName = (typeof THERMOSTAT_MODES)[number];
/**
* 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).
*/
export declare const ThermostatController: import("../types.js").InterfaceDescriptor<{
targetSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
lowerSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
upperSetpoint: {
name: string;
value: Schema<import("../schema.js").Temperature>;
};
thermostatMode: {
name: string;
value: import("../schema.js").EnumSchema<"ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT">;
};
adaptiveRecoveryStatus: {
name: string;
value: import("../schema.js").EnumSchema<"PREHEATING" | "PRECOOLING" | "INACTIVE">;
note: string;
};
}, {
SetTargetTemperature: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
targetSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
holdUntil: import("../schema.js").OptionalSchema<import("../schema.js").TimeInterval>;
}>>;
note: string;
};
AdjustTargetTemperature: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
targetSetpointDelta: Schema<import("../schema.js").Temperature>;
}>>;
};
SetThermostatMode: {
name: string;
payload: Schema<import("../schema.js").InferShape<{
thermostatMode: Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT">;
}>>;
}>>;
};
ResumeSchedule: {
name: string;
payload: Schema<import("../schema.js").InferShape<{}>>;
note: string;
};
}, import("../schema.js").InferShape<{
/** Default: HEAT, COOL, AUTO, OFF. */
supportedModes: import("../schema.js").OptionalSchema<("ECO" | "OFF" | "AUTO" | "COOL" | "EM_HEAT" | "HEAT")[]>;
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: import("../schema.js").OptionalSchema<boolean>;
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: import("../schema.js").OptionalSchema<("targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "thermostatMode" | "adaptiveRecoveryStatus")[]>;
}>, false>;

View file

@ -0,0 +1,142 @@
/**
* 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.
*/
export declare const ThermostatControllerSchedule: import("../types.js").InterfaceDescriptor<{
adaptiveRecoveryEnabled: {
name: string;
value: import("../schema.js").Schema<boolean>;
};
scheduleEnabled: {
name: string;
value: import("../schema.js").Schema<boolean>;
};
}, {
SetWeeklySchedule: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
weeklySchedule: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
temperatureScale: import("../schema.js").EnumSchema<"CELSIUS" | "FAHRENHEIT" | "KELVIN">;
Monday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Tuesday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Wednesday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Thursday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Friday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Saturday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
Sunday: import("../schema.js").Schema<import("../schema.js").InferShape<{
startTimeInMinutes: import("../schema.js").Schema<number>;
setpoints: import("../schema.js").Schema<import("../schema.js").InferShape<{
upperSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
lowerSetpoint: import("../schema.js").OptionalSchema<import("../schema.js").Temperature>;
}>>;
/** Without a mode the fan runs as the manufacturer set it. */
fanSetting: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
mode: import("../schema.js").OptionalSchema<"ON" | "AUTO" | "CIRCULATE">;
}>>;
activityType: import("../schema.js").OptionalSchema<import("../schema.js").InferShape<{
type: import("../schema.js").EnumSchema<"AWAY" | "HOME" | "SLEEP">;
}>>;
}>[]>;
}>>;
}>>;
note: string;
};
SetScheduleState: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
scheduleEnabled: import("../schema.js").Schema<boolean>;
}>>;
note: string;
};
SetAdaptiveRecovery: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
adaptiveRecoveryEnabled: import("../schema.js").Schema<boolean>;
}>>;
when: ({ options }: import("../types.js").Declared<any>) => boolean;
};
}, import("../schema.js").InferShape<{
supportedFanModes: import("../schema.js").Schema<("ON" | "AUTO" | "CIRCULATE")[]>;
/** The thermostat heats or cools ahead of an entry, to be at its temperature when it starts. */
supportsAdaptiveRecovery: import("../schema.js").Schema<boolean>;
maxEntryPerDay: import("../schema.js").OptionalSchema<number>;
}>, false>;

View file

@ -76,6 +76,8 @@ export interface CapabilityExtras {
topLevel?: Record<string, unknown>;
/** false: the capability has no properties object (the Alexa interface, a scene). */
properties?: false;
/** The properties the capability lists, where a declaration has some of those of the interface. Default: all. */
supported?: readonly string[];
}
/** A capability as declared on an endpoint: what discovery() and validate() of its descriptor are given. */
export interface Declared<O = unknown> {