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>
71 lines
3 KiB
JavaScript
71 lines
3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.AlexaInterface = void 0;
|
|
const Capability_js_1 = require("../device/Capability.js");
|
|
const index_js_1 = require("../registry/index.js");
|
|
const resources_js_1 = require("../registry/resources.js");
|
|
/**
|
|
* A capability as 1.x declares it: device.addCapability(type, options), then the add and set methods below. It is a
|
|
* Capability, so what the methods set reaches discovery the same way as the options of device.add(). Nothing is
|
|
* refused here except an interface name the registry does not have: what Alexa would reject is logged by the bridge
|
|
* when it answers a discovery.
|
|
*/
|
|
class AlexaInterface extends Capability_js_1.Capability {
|
|
constructor(type, retrievable = true, proactivelyReported = false, instance = "") {
|
|
super(index_js_1.registry.get(type), { retrievable, proactivelyReported, instance, options: {} });
|
|
}
|
|
/** The namespace of the interface, which is the value of its AlexaInterfaceType member. */
|
|
get type() {
|
|
return this.descriptor.namespace;
|
|
}
|
|
addActionMapping(mapping) {
|
|
var _a;
|
|
const semantics = ((_a = this.options).semantics ?? (_a.semantics = {}));
|
|
(semantics.actionMappings ?? (semantics.actionMappings = [])).push(mapping.toJSON());
|
|
if (mapping.deprecation)
|
|
this.notes.push(mapping.deprecation);
|
|
}
|
|
addFriendlyName(name, locale) {
|
|
this.friendlyNames.push((0, resources_js_1.text)(name, locale));
|
|
}
|
|
/**
|
|
* The modes of a ModeController, as { value, modeResources } objects. A mode given as a string is announced as
|
|
* { value } and noted: Alexa wants friendly names for it. ordered is true unless options.ordered says otherwise,
|
|
* as 1.x announced every mode list; with device.add() the default is false.
|
|
*/
|
|
addSupportedModes(modes, options = {}) {
|
|
this.options.ordered = options.ordered ?? true;
|
|
this.options.supportedModes = modes.map((mode) => {
|
|
if (typeof mode !== "string")
|
|
return { value: mode.value, friendlyNames: (mode.modeResources?.friendlyNames ?? []) };
|
|
this.notes.push(`the mode ${mode} was given as a string, pass { value, modeResources }`);
|
|
return { value: mode, friendlyNames: [] };
|
|
});
|
|
}
|
|
setInstance(name) {
|
|
this.instance = name;
|
|
}
|
|
getType() {
|
|
return this.type;
|
|
}
|
|
/** @deprecated The same as getType(). */
|
|
getTypeString() {
|
|
return this.type;
|
|
}
|
|
/** @deprecated Read descriptor.version. */
|
|
getVersion() {
|
|
return this.descriptor.version;
|
|
}
|
|
/** @deprecated The properties discovery lists: read properties.supported of toJSON(). */
|
|
getProps() {
|
|
return (super.toJSON().properties?.supported ?? []).map(({ name }) => name);
|
|
}
|
|
getJSON() {
|
|
return super.toJSON();
|
|
}
|
|
// 1.x callers corrected the discovery JSON by replacing getJSON on the object: discovery goes through it
|
|
toJSON() {
|
|
return this.getJSON();
|
|
}
|
|
}
|
|
exports.AlexaInterface = AlexaInterface;
|