Alex2Node/dist/esm/registry/interfaces/DoorbellEventSource.js
David 4a3dd81bcf messages: DoorbellPress is sent with the empty context of its page
proactiveEvent() built every proactive event without a context, so doorbellPress() and
device.raise(DoorbellEventSource, "DoorbellPress") left out the "context": {} that the example of
alexa-doorbelleventsource.html has. The Event of Alexa.SimpleEventSource is printed without one, so
the event descriptor says which it is (emptyContext) and raise() passes it on to the builder.

A raised DoorbellPress is now { event, context: {} }, 13 bytes longer; the Event of a button is
unchanged. The tests compare the keys and the context of the built message with the fixture of the
page, for the builder, the descriptor and raise(). 267 tests pass.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 21:08:10 +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", emptyContext: true },
},
// 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");
}
},
});