import { s } from "../schema.js"; import { defineInterface } from "../types.js"; export const PowerController = defineInterface({ namespace: "Alexa.PowerController", version: "3", doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-powercontroller.html", kind: "controller", tier: 1, instanced: false, properties: { powerState: { name: "powerState", value: s.enum("ON", "OFF") }, }, directives: { TurnOn: { name: "TurnOn", payload: s.object({}) }, TurnOff: { name: "TurnOff", payload: s.object({}) }, }, options: s.object({ // The directives Alexa asks the user to confirm before it sends them. Amazon supports this for devices in Japan // only (alexa-discovery-objects.html, "VerificationsRequired object"). verificationsRequired: s.optional(s.array(s.enum("TurnOn", "TurnOff"), { min: 1 })), }, { unknownKeys: "reject" }), discovery({ options }) { if (!options.verificationsRequired) return {}; const confirmed = options.verificationsRequired.map((directive) => ({ directive, methods: [{ "@type": "Confirmation" }] })); return { topLevel: { verificationsRequired: confirmed } }; }, });