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"); } }, });