Alex2Node/dist/esm/registry/interfaces/DoorbellEventSource.js
David 3a07c861b1 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>
2026-09-28 21:01:53 +00:00

31 lines
1.5 KiB
JavaScript

import { happened } from "../events.js";
import { DeclarationError, defineInterface } from "../types.js";
/**
* A doorbell. It takes no directive and reports nothing; device.raise(DoorbellEventSource, "DoorbellPress") says
* that somebody rang. Alexa wants 30 seconds between two presses of one doorbell, and announces a press when the
* user switched the announcements on for the doorbell in the Alexa app.
*/
export const DoorbellEventSource = defineInterface({
namespace: "Alexa.DoorbellEventSource",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-doorbelleventsource.html",
kind: "eventSource",
tier: 2,
instanced: false,
properties: {},
directives: {},
events: {
DoorbellPress: { name: "DoorbellPress", payload: happened("PHYSICAL_INTERACTION"), topic: "proactive" },
},
// The capability is the announcement that the endpoint raises the event: proactivelyReported whatever was declared
discovery: () => ({ properties: false, topLevel: { proactivelyReported: true } }),
// alexa-doorbelleventsource.html, "Discovery"
validate(capability, { displayCategories }) {
const doorbell = displayCategories.indexOf("DOORBELL");
if (doorbell < 0)
throw new DeclarationError(capability, "a doorbell has the display category DOORBELL");
if (displayCategories.indexOf("CAMERA") > doorbell) {
throw new DeclarationError(capability, "a video doorbell lists the display category CAMERA before DOORBELL");
}
},
});