registry: Lock, Color, ColorTemperature, Percentage, PowerLevel, Contact, Motion, Humidity

Eight descriptors written from their pages, each with its version, the value of its property and the payload of
every directive. Seven replace a stub; Alexa.HumiditySensor is new, as AlexaInterfaceType.HUMIDITY_SENSOR.
LockController is deferrable: defer() on a lock logs no warning.

A 1.x declaration of LockController, MotionSensor, PercentageController or PowerLevelController now lists its
property in discovery, where 1.5.2 listed none: the zoo's lock, motion sensor and heater come out as the JSON
Alexa accepted. A payload that does not fit (hue 361, 900 K) is answered with INVALID_VALUE.

48 examples of the eight pages are saved as fixtures. 191 tests pass, 168 before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 20:29:04 +00:00
parent feff828ec1
commit af1489696d
111 changed files with 2971 additions and 45 deletions

View file

@ -1,8 +1,16 @@
import { Alexa } from "./interfaces/Alexa.js";
import { BrightnessController } from "./interfaces/BrightnessController.js";
import { ColorController } from "./interfaces/ColorController.js";
import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js";
import { ContactSensor } from "./interfaces/ContactSensor.js";
import { EndpointHealth } from "./interfaces/EndpointHealth.js";
import { HumiditySensor } from "./interfaces/HumiditySensor.js";
import { LockController } from "./interfaces/LockController.js";
import { ModeController } from "./interfaces/ModeController.js";
import { MotionSensor } from "./interfaces/MotionSensor.js";
import { PercentageController } from "./interfaces/PercentageController.js";
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 { ToggleController } from "./interfaces/ToggleController.js";
@ -15,7 +23,7 @@ export declare const registry: {
/** Every descriptor, ordered by namespace. */
list(): AnyDescriptor[];
};
export { Alexa, BrightnessController, EndpointHealth, ModeController, PowerController, RangeController, TemperatureSensor, ToggleController, };
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, };
export type { Mode } from "./interfaces/ModeController.js";
export { asset, text } from "./resources.js";
export { semantics, SemanticsBuilder } from "./semantics.js";

View file

@ -1,9 +1,17 @@
// The interfaces the library knows, by namespace.
import { Alexa } from "./interfaces/Alexa.js";
import { BrightnessController } from "./interfaces/BrightnessController.js";
import { ColorController } from "./interfaces/ColorController.js";
import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js";
import { ContactSensor } from "./interfaces/ContactSensor.js";
import { EndpointHealth } from "./interfaces/EndpointHealth.js";
import { HumiditySensor } from "./interfaces/HumiditySensor.js";
import { LockController } from "./interfaces/LockController.js";
import { ModeController } from "./interfaces/ModeController.js";
import { MotionSensor } from "./interfaces/MotionSensor.js";
import { PercentageController } from "./interfaces/PercentageController.js";
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 { ToggleController } from "./interfaces/ToggleController.js";
@ -12,9 +20,17 @@ import { DeclarationError } from "./types.js";
const described = [
Alexa,
BrightnessController,
ColorController,
ColorTemperatureController,
ContactSensor,
EndpointHealth,
HumiditySensor,
LockController,
ModeController,
MotionSensor,
PercentageController,
PowerController,
PowerLevelController,
RangeController,
TemperatureSensor,
ToggleController,
@ -43,7 +59,7 @@ export const registry = {
return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1));
},
};
export { Alexa, BrightnessController, EndpointHealth, ModeController, PowerController, RangeController, TemperatureSensor, ToggleController, };
export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, TemperatureSensor, ToggleController, };
export { asset, text } from "./resources.js";
export { semantics, SemanticsBuilder } from "./semantics.js";
export { DeclarationError, defineInterface } from "./types.js";

View file

@ -0,0 +1,25 @@
/**
* A light changes its hue and saturation and keeps the brightness it has: "ignore the brightness value of 1 in the
* directive" (alexa-colorcontroller.html, "SetColor directive example").
*/
export declare const ColorController: import("../types.js").InterfaceDescriptor<{
color: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
hue: import("../schema.js").Schema<number>;
saturation: import("../schema.js").Schema<number>;
brightness: import("../schema.js").Schema<number>;
}>>;
};
}, {
SetColor: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
color: import("../schema.js").Schema<import("../schema.js").InferShape<{
hue: import("../schema.js").Schema<number>;
saturation: import("../schema.js").Schema<number>;
brightness: import("../schema.js").Schema<number>;
}>>;
}>>;
};
}, {}, false>;

View file

@ -0,0 +1,26 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
// alexa-property-schemas.html, "Color"
const color = s.object({
hue: s.number({ min: 0, max: 360 }),
saturation: s.number({ min: 0, max: 1 }),
brightness: s.number({ min: 0, max: 1 }),
});
/**
* A light changes its hue and saturation and keeps the brightness it has: "ignore the brightness value of 1 in the
* directive" (alexa-colorcontroller.html, "SetColor directive example").
*/
export const ColorController = defineInterface({
namespace: "Alexa.ColorController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-colorcontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
color: { name: "color", value: color },
},
directives: {
SetColor: { name: "SetColor", payload: s.object({ color }) },
},
});

View file

@ -0,0 +1,28 @@
/**
* The white of a tunable light. Alexa asks for 2200 (warm), 2700 (soft), 4000 (white), 5500 (daylight) and 7000
* (cool); a light that cannot show the value takes the nearest it can. A light that shows a colour answers
* NOT_SUPPORTED_IN_CURRENT_MODE with currentDeviceMode COLOR.
*/
export declare const ColorTemperatureController: import("../types.js").InterfaceDescriptor<{
colorTemperatureInKelvin: {
name: string;
value: import("../schema.js").Schema<number>;
};
}, {
SetColorTemperature: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
colorTemperatureInKelvin: import("../schema.js").Schema<number>;
}>>;
};
IncreaseColorTemperature: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{}>>;
note: string;
};
DecreaseColorTemperature: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{}>>;
note: string;
};
}, {}, false>;

View file

@ -0,0 +1,25 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
// alexa-colortemperaturecontroller.html, "Reportable properties": "Valid values range from 1,000 to 10,000"
const kelvin = s.number({ min: 1000, max: 10000, integer: true });
/**
* The white of a tunable light. Alexa asks for 2200 (warm), 2700 (soft), 4000 (white), 5500 (daylight) and 7000
* (cool); a light that cannot show the value takes the nearest it can. A light that shows a colour answers
* NOT_SUPPORTED_IN_CURRENT_MODE with currentDeviceMode COLOR.
*/
export const ColorTemperatureController = defineInterface({
namespace: "Alexa.ColorTemperatureController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-colortemperaturecontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
colorTemperatureInKelvin: { name: "colorTemperatureInKelvin", value: kelvin },
},
directives: {
SetColorTemperature: { name: "SetColorTemperature", payload: s.object({ colorTemperatureInKelvin: kelvin }) },
IncreaseColorTemperature: { name: "IncreaseColorTemperature", payload: s.object({}), note: "towards cool" },
DecreaseColorTemperature: { name: "DecreaseColorTemperature", payload: s.object({}), note: "towards warm" },
},
});

View file

@ -0,0 +1,10 @@
/**
* DETECTED is open: the two pieces of the sensor are apart. A sensor that cannot answer ReportState sends a
* ChangeReport right after discovery, so that the Alexa app shows its state (alexa-contactsensor.html).
*/
export declare const ContactSensor: import("../types.js").InterfaceDescriptor<{
detectionState: {
name: string;
value: import("../schema.js").EnumSchema<"DETECTED" | "NOT_DETECTED">;
};
}, {}, {}, false>;

View file

@ -0,0 +1,18 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/**
* DETECTED is open: the two pieces of the sensor are apart. A sensor that cannot answer ReportState sends a
* ChangeReport right after discovery, so that the Alexa app shows its state (alexa-contactsensor.html).
*/
export const ContactSensor = defineInterface({
namespace: "Alexa.ContactSensor",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-contactsensor.html",
kind: "sensor",
tier: 1,
instanced: false,
properties: {
detectionState: { name: "detectionState", value: s.enum("DETECTED", "NOT_DETECTED") },
},
directives: {},
});

View file

@ -0,0 +1,9 @@
/** The value is an object, { value: 45.5 }, as the reports of alexa-humiditysensor.html print it. */
export declare const HumiditySensor: import("../types.js").InterfaceDescriptor<{
relativeHumidity: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").Schema<number>;
}>>;
};
}, {}, {}, false>;

View file

@ -0,0 +1,15 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/** The value is an object, { value: 45.5 }, as the reports of alexa-humiditysensor.html print it. */
export const HumiditySensor = defineInterface({
namespace: "Alexa.HumiditySensor",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-humiditysensor.html",
kind: "sensor",
tier: 1,
instanced: false,
properties: {
relativeHumidity: { name: "relativeHumidity", value: s.object({ value: s.number({ min: 0, max: 100 }) }) },
},
directives: {},
});

View file

@ -0,0 +1,20 @@
/**
* A lock that takes more than five seconds answers with a DeferredResponse first and the Response when the bolt has
* moved (alexa-lockcontroller.html, "Lock response"). The user enables unlocking by voice per device, in the Alexa app.
*/
export declare const LockController: import("../types.js").InterfaceDescriptor<{
lockState: {
name: string;
value: import("../schema.js").EnumSchema<"LOCKED" | "UNLOCKED" | "JAMMED">;
note: string;
};
}, {
Lock: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{}>>;
};
Unlock: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{}>>;
};
}, {}, false>;

View file

@ -0,0 +1,26 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/**
* A lock that takes more than five seconds answers with a DeferredResponse first and the Response when the bolt has
* moved (alexa-lockcontroller.html, "Lock response"). The user enables unlocking by voice per device, in the Alexa app.
*/
export const LockController = defineInterface({
namespace: "Alexa.LockController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-lockcontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
lockState: {
name: "lockState",
value: s.enum("LOCKED", "UNLOCKED", "JAMMED"),
note: "JAMMED: the mechanism can reach neither LOCKED nor UNLOCKED",
},
},
directives: {
Lock: { name: "Lock", payload: s.object({}) },
Unlock: { name: "Unlock", payload: s.object({}) },
},
deferrable: true,
});

View file

@ -0,0 +1,10 @@
/**
* "When a motion sensor changes to DETECTED, and then changes to NOT_DETECTED, you must wait at least 30 seconds
* before sending the second change report" (alexa-motionsensor.html, "Change reporting").
*/
export declare const MotionSensor: import("../types.js").InterfaceDescriptor<{
detectionState: {
name: string;
value: import("../schema.js").EnumSchema<"DETECTED" | "NOT_DETECTED">;
};
}, {}, {}, false>;

View file

@ -0,0 +1,18 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/**
* "When a motion sensor changes to DETECTED, and then changes to NOT_DETECTED, you must wait at least 30 seconds
* before sending the second change report" (alexa-motionsensor.html, "Change reporting").
*/
export const MotionSensor = defineInterface({
namespace: "Alexa.MotionSensor",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-motionsensor.html",
kind: "sensor",
tier: 1,
instanced: false,
properties: {
detectionState: { name: "detectionState", value: s.enum("DETECTED", "NOT_DETECTED") },
},
directives: {},
});

View file

@ -0,0 +1,23 @@
/**
* For a device no other interface fits: "Use this interface only if there isn't a more specific controller
* interface that applies to your device" (alexa-percentagecontroller.html).
*/
export declare const PercentageController: import("../types.js").InterfaceDescriptor<{
percentage: {
name: string;
value: import("../schema.js").Schema<number>;
};
}, {
SetPercentage: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
percentage: import("../schema.js").Schema<number>;
}>>;
};
AdjustPercentage: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
percentageDelta: import("../schema.js").Schema<number>;
}>>;
};
}, {}, false>;

View file

@ -0,0 +1,27 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/**
* For a device no other interface fits: "Use this interface only if there isn't a more specific controller
* interface that applies to your device" (alexa-percentagecontroller.html).
*/
export const PercentageController = defineInterface({
namespace: "Alexa.PercentageController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-percentagecontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
percentage: { name: "percentage", value: s.number({ min: 0, max: 100, integer: true }) },
},
directives: {
SetPercentage: {
name: "SetPercentage",
payload: s.object({ percentage: s.number({ min: 0, max: 100, integer: true }) }),
},
AdjustPercentage: {
name: "AdjustPercentage",
payload: s.object({ percentageDelta: s.number({ min: -100, max: 100, integer: true }) }),
},
},
});

View file

@ -0,0 +1,20 @@
/** The power of a device as a percentage, a dimmer switch for one (alexa-powerlevelcontroller.html). */
export declare const PowerLevelController: import("../types.js").InterfaceDescriptor<{
powerLevel: {
name: string;
value: import("../schema.js").Schema<number>;
};
}, {
SetPowerLevel: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
powerLevel: import("../schema.js").Schema<number>;
}>>;
};
AdjustPowerLevel: {
name: string;
payload: import("../schema.js").Schema<import("../schema.js").InferShape<{
powerLevelDelta: import("../schema.js").Schema<number>;
}>>;
};
}, {}, false>;

View file

@ -0,0 +1,24 @@
import { s } from "../schema.js";
import { defineInterface } from "../types.js";
/** The power of a device as a percentage, a dimmer switch for one (alexa-powerlevelcontroller.html). */
export const PowerLevelController = defineInterface({
namespace: "Alexa.PowerLevelController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-powerlevelcontroller.html",
kind: "controller",
tier: 1,
instanced: false,
properties: {
powerLevel: { name: "powerLevel", value: s.number({ min: 0, max: 100, integer: true }) },
},
directives: {
SetPowerLevel: {
name: "SetPowerLevel",
payload: s.object({ powerLevel: s.number({ min: 0, max: 100, integer: true }) }),
},
AdjustPowerLevel: {
name: "AdjustPowerLevel",
payload: s.object({ powerLevelDelta: s.number({ min: -100, max: 100, integer: true }) }),
},
},
});

View file

@ -18,11 +18,8 @@ const TABLE = [
["Alexa.Camera.LiveViewController", "1.7", [], LIST_OF_INTERFACES],
["Alexa.CameraStreamController", "3", [], "alexa-camerastreamcontroller.html"],
["Alexa.ChannelController", "3", ["channel"], "alexa-channelcontroller.html"],
["Alexa.ColorController", "3", ["color"], "alexa-colorcontroller.html"],
["Alexa.ColorTemperatureController", "3", ["colorTemperatureInKelvin"], "alexa-colortemperaturecontroller.html"],
["Alexa.Commissionable", "1", [], "alexa-commissionable.html"],
["Alexa.ConsentManagement.ConsentRequiredReporter", "1", [], "alexa-consentrequiredreporter.html"],
["Alexa.ContactSensor", "3", ["detectionState"], "alexa-contactsensor.html"],
["Alexa.Cooking", "1", [], "alexa-cooking.html"],
["Alexa.Cooking.FoodTemperatureController", "1", [], "alexa-cooking-foodtemperaturecontroller.html"],
["Alexa.Cooking.FoodTemperatureSensor", "1", [], "alexa-cooking-foodtemperaturesensor.html"],
@ -41,15 +38,11 @@ const TABLE = [
["Alexa.InventoryUsageSensor", "1", [], "alexa-inventoryusagesensor.html"],
["Alexa.KeypadController", "1", [], "alexa-keypadcontroller.html"],
["Alexa.Launcher", "1.1", [], "alexa-launcher.html"],
["Alexa.LockController", "3", [], "alexa-lockcontroller.html"],
["Alexa.Media.PlayQueue", "1", [], "alexa-media-playqueue.html"],
["Alexa.Media.Playback", "1", [], "alexa-media-playback.html"],
["Alexa.Media.Search", "1", [], "alexa-media-search.html"],
["Alexa.MotionSensor", "3", [], "alexa-motionsensor.html"],
["Alexa.PercentageController", "3", [], "alexa-percentagecontroller.html"],
["Alexa.PlaybackController", "3", [], "alexa-playbackcontroller.html"],
["Alexa.PlaybackStateReporter", "1", [], "alexa-playbackcontroller.html"],
["Alexa.PowerLevelController", "3", [], "alexa-powerlevelcontroller.html"],
["Alexa.ProactiveNotificationSource", "1", [], "alexa-proactivenotificationsource.html"],
["Alexa.RTCSessionController", "1", [], "alexa-rtcsessioncontroller.html"],
["Alexa.RecordController", "3", [], "alexa-recordcontroller.html"],