registry: SceneController events, DoorbellEventSource, SimpleEventSource, TimeHoldController, InventoryLevelSensor, WakeOnLANController

Six descriptors written from their pages replace the last stubs of tiers 1 and 2. A scene answers Activate and
Deactivate through ctx.respond() with ActivationStarted and DeactivationStarted, the time and the cause filled
in. device.raise(descriptor, name, payload) publishes DoorbellPress and the Event of a button on <root>/event
with the endpoint and a new messageId; it throws a MessageError for an interface or instance the device did
not declare, an event that answers a directive, a payload that does not fit and a message over 16000 bytes.
TurnOn of a device with WakeOnLANController is deferred without the warning.

On the wire: a doorbell has no properties object and proactivelyReported on the capability; SimpleEventSource
is version 1.0, InventoryLevelSensor and WakeOnLANController version 3 (1.5.2: 1). A scene declared without
options is announced as before. Alex2MQTT has no topic yet for the WakeUp event.
24 examples of the six pages are saved as fixtures. 267 tests pass, 241 before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 21:01:53 +00:00
parent d7dfc5b122
commit 3a07c861b1
116 changed files with 3136 additions and 166 deletions

View file

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleEventSource = void 0;
const events_js_1 = require("../events.js");
const resources_js_1 = require("../resources.js");
const schema_js_1 = require("../schema.js");
const types_js_1 = require("../types.js");
/**
* A button of a remote, or anything else that routines start on. Each instance is one button with the events it
* has, a single and a double push; device.raise(SimpleEventSource, "Event", { id }, { instance }) says that one
* happened. Alexa wants the instance to be unique among all endpoints, "preferably a version 4 UUID".
*
* The page folds its discovery example away. The capability is announced with the fields of its table and without a
* properties object, as the interface has no property.
*/
exports.SimpleEventSource = (0, types_js_1.defineInterface)({
namespace: "Alexa.SimpleEventSource",
version: "1.0",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-simpleeventsource.html",
kind: "eventSource",
tier: 2,
instanced: true,
properties: {},
directives: {},
events: {
Event: {
name: "Event",
/** id: the id of one of the supportedEvents of the instance. */
payload: schema_js_1.s.object({ id: schema_js_1.s.string({ min: 1 }), timestamp: events_js_1.timestamp }),
topic: "proactive",
},
},
options: schema_js_1.s.object({
/** For a REMOTE the names are assets of the catalog: Alexa.Button.SinglePush, Alexa.Gesture.Tap. */
supportedEvents: schema_js_1.s.array(schema_js_1.s.object({ id: schema_js_1.s.string({ min: 1 }), friendlyNames: resources_js_1.labels }, { unknownKeys: "reject" }), { min: 1 }),
}, { unknownKeys: "reject" }),
// A capability declared the 1.x way has no events; check() says so
discovery: ({ options: { supportedEvents } }) => ({
properties: false,
...(supportedEvents && { configuration: { supportedEvents } }),
}),
validate(capability) {
const { supportedEvents } = capability.options;
const ids = supportedEvents.map(({ id }) => id);
// "The first friendly name in the array must be unique per instance of the capability."
const names = supportedEvents.map(({ friendlyNames: [first] }) => (0, resources_js_1.shownAs)(first));
const twice = (list) => list.find((entry, i) => list.indexOf(entry) !== i);
if (twice(ids))
throw new types_js_1.DeclarationError(capability, `the event ${twice(ids)} is listed twice`);
if (twice(names))
throw new types_js_1.DeclarationError(capability, `two events have ${twice(names)} as their first friendly name, the Alexa app shows an event by it`);
},
});