From d7dfc5b12249e920beb6be72b07aa9314b9d2a91 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 28 Sep 2026 20:54:53 +0000 Subject: [PATCH] registry: Speaker, StepSpeaker, EqualizerController, PlaybackController, PlaybackStateReporter, InputController, ChannelController Seven descriptors written from their pages replace seven stubs. All are version 3; 1.5.2 announced Speaker, StepSpeaker, EqualizerController and PlaybackStateReporter as version 1, and all but ChannelController without a property. StepSpeaker has no properties object in discovery and PlaybackController one without fields, next to supportedOperations; a directive for an operation the device did not list is answered with INVALID_DIRECTIVE. The equalizer declares bands, modes or both under "configurations", a TV its inputs from the 61 names of the page. Not described: the lineup of ChannelController, whose discovery example the page folds away. The discovery examples of InputController spell one key "friendNames"; the fixtures have friendlyNames, as its table does. 62 examples of the six pages are saved as fixtures. 241 tests pass, 215 before. Co-Authored-By: Claude Fable 5.1 --- dist/cjs/index.js | 12 +- dist/cjs/registry/index.js | 25 +++- .../registry/interfaces/ChannelController.js | 43 +++++++ .../interfaces/EqualizerController.js | 72 ++++++++++++ .../registry/interfaces/InputController.js | 49 ++++++++ .../registry/interfaces/PlaybackController.js | 46 ++++++++ .../interfaces/PlaybackStateReporter.js | 18 +++ dist/cjs/registry/interfaces/Speaker.js | 27 +++++ dist/cjs/registry/interfaces/StepSpeaker.js | 27 +++++ dist/cjs/registry/interfaces/stubs.js | 9 +- dist/esm/index.d.ts | 6 +- dist/esm/index.js | 4 +- dist/esm/registry/index.d.ts | 11 +- dist/esm/registry/index.js | 17 ++- .../interfaces/ChannelController.d.ts | 41 +++++++ .../registry/interfaces/ChannelController.js | 40 +++++++ .../interfaces/EqualizerController.d.ts | 63 ++++++++++ .../interfaces/EqualizerController.js | 69 +++++++++++ .../registry/interfaces/InputController.d.ts | 26 +++++ .../registry/interfaces/InputController.js | 46 ++++++++ .../interfaces/PlaybackController.d.ts | 57 +++++++++ .../registry/interfaces/PlaybackController.js | 43 +++++++ .../interfaces/PlaybackStateReporter.d.ts | 9 ++ .../interfaces/PlaybackStateReporter.js | 15 +++ dist/esm/registry/interfaces/Speaker.d.ts | 32 ++++++ dist/esm/registry/interfaces/Speaker.js | 24 ++++ dist/esm/registry/interfaces/StepSpeaker.d.ts | 19 +++ dist/esm/registry/interfaces/StepSpeaker.js | 24 ++++ dist/esm/registry/interfaces/stubs.js | 9 +- dist/types/index.d.ts | 6 +- dist/types/registry/index.d.ts | 11 +- .../interfaces/ChannelController.d.ts | 41 +++++++ .../interfaces/EqualizerController.d.ts | 63 ++++++++++ .../registry/interfaces/InputController.d.ts | 26 +++++ .../interfaces/PlaybackController.d.ts | 57 +++++++++ .../interfaces/PlaybackStateReporter.d.ts | 9 ++ dist/types/registry/interfaces/Speaker.d.ts | 32 ++++++ .../registry/interfaces/StepSpeaker.d.ts | 19 +++ src/index.ts | 12 +- src/registry/index.ts | 24 +++- src/registry/interfaces/ChannelController.ts | 42 +++++++ .../interfaces/EqualizerController.ts | 69 +++++++++++ src/registry/interfaces/InputController.ts | 49 ++++++++ src/registry/interfaces/PlaybackController.ts | 52 +++++++++ .../interfaces/PlaybackStateReporter.ts | 16 +++ src/registry/interfaces/Speaker.ts | 25 ++++ src/registry/interfaces/StepSpeaker.ts | 25 ++++ src/registry/interfaces/stubs.ts | 9 +- .../ChangeChannel.directive.json | 31 +++++ .../ChangeChannel.response.json | 37 ++++++ .../alexa-channelcontroller/ChangeReport.json | 57 +++++++++ .../SkipChannels.directive.json | 14 +++ .../SkipChannels.response.json | 37 ++++++ .../alexa-channelcontroller/StateReport.json | 50 ++++++++ .../channel.property.json | 8 ++ .../discovery-addOrUpdateReport.json | 69 +++++++++++ .../AdjustBands.directive.json | 28 +++++ .../AdjustBands.response.json | 57 +++++++++ .../ChangeReport.json | 64 +++++++++++ .../ResetBands.directive.json | 32 ++++++ .../ResetBands.response.json | 57 +++++++++ .../SetBands.directive.json | 27 +++++ .../SetBands.response.json | 57 +++++++++ .../SetMode.directive.json | 22 ++++ .../SetMode.response.json | 57 +++++++++ .../StateReport.json | 57 +++++++++ .../bands.property.json | 17 +++ .../alexa-equalizercontroller/discovery.json | 94 +++++++++++++++ .../mode.property.json | 4 + .../alexa-inputcontroller/ChangeReport.json | 53 +++++++++ .../SelectInput.directive.json | 22 ++++ .../SelectInput.response.json | 42 +++++++ .../alexa-inputcontroller/StateReport.json | 46 ++++++++ .../discovery-addOrUpdateReport.json | 83 ++++++++++++++ .../alexa-inputcontroller/discovery.json | 88 ++++++++++++++ .../ChangeReport.json | 48 ++++++++ .../FastForward.directive.json | 20 ++++ .../FastForward.response.json | 37 ++++++ .../Next.directive.json | 20 ++++ .../Next.response.json | 37 ++++++ .../Pause.directive.json | 20 ++++ .../Pause.response.json | 37 ++++++ .../Play.directive.json | 20 ++++ .../Play.response.json | 37 ++++++ .../Previous.directive.json | 20 ++++ .../Previous.response.json | 37 ++++++ .../Rewind.directive.json | 20 ++++ .../Rewind.response.json | 37 ++++++ .../StartOver.directive.json | 20 ++++ .../StartOver.response.json | 37 ++++++ .../alexa-playbackcontroller/StateReport.json | 37 ++++++ .../Stop.directive.json | 20 ++++ .../Stop.response.json | 37 ++++++ .../alexa-playbackcontroller/discovery.json | 81 +++++++++++++ .../alexa-speaker/AdjustVolume.directive.json | 23 ++++ .../alexa-speaker/AdjustVolume.response.json | 40 +++++++ .../alexa-speaker/ChangeReport.json | 51 +++++++++ .../alexa-speaker/SetMute.directive.json | 22 ++++ .../alexa-speaker/SetMute.response.json | 40 +++++++ .../alexa-speaker/SetVolume.directive.json | 22 ++++ .../alexa-speaker/SetVolume.response.json | 40 +++++++ .../alexa-docs/alexa-speaker/StateReport.json | 44 +++++++ .../alexa-docs/alexa-speaker/discovery.json | 62 ++++++++++ .../alexa-speaker/muted.property.json | 4 + .../alexa-speaker/volume.property.json | 4 + .../AdjustVolume.directive.json | 22 ++++ .../AdjustVolume.response.json | 26 +++++ .../alexa-stepspeaker/SetMute.directive.json | 22 ++++ .../alexa-stepspeaker/SetMute.response.json | 26 +++++ .../alexa-stepspeaker/discovery.json | 50 ++++++++ test/fixtures/interfaces.js | 84 ++++++++++++++ test/registry/descriptors.test.js | 3 +- test/registry/entertainment.test.js | 108 ++++++++++++++++++ 113 files changed, 3948 insertions(+), 47 deletions(-) create mode 100644 dist/cjs/registry/interfaces/ChannelController.js create mode 100644 dist/cjs/registry/interfaces/EqualizerController.js create mode 100644 dist/cjs/registry/interfaces/InputController.js create mode 100644 dist/cjs/registry/interfaces/PlaybackController.js create mode 100644 dist/cjs/registry/interfaces/PlaybackStateReporter.js create mode 100644 dist/cjs/registry/interfaces/Speaker.js create mode 100644 dist/cjs/registry/interfaces/StepSpeaker.js create mode 100644 dist/esm/registry/interfaces/ChannelController.d.ts create mode 100644 dist/esm/registry/interfaces/ChannelController.js create mode 100644 dist/esm/registry/interfaces/EqualizerController.d.ts create mode 100644 dist/esm/registry/interfaces/EqualizerController.js create mode 100644 dist/esm/registry/interfaces/InputController.d.ts create mode 100644 dist/esm/registry/interfaces/InputController.js create mode 100644 dist/esm/registry/interfaces/PlaybackController.d.ts create mode 100644 dist/esm/registry/interfaces/PlaybackController.js create mode 100644 dist/esm/registry/interfaces/PlaybackStateReporter.d.ts create mode 100644 dist/esm/registry/interfaces/PlaybackStateReporter.js create mode 100644 dist/esm/registry/interfaces/Speaker.d.ts create mode 100644 dist/esm/registry/interfaces/Speaker.js create mode 100644 dist/esm/registry/interfaces/StepSpeaker.d.ts create mode 100644 dist/esm/registry/interfaces/StepSpeaker.js create mode 100644 dist/types/registry/interfaces/ChannelController.d.ts create mode 100644 dist/types/registry/interfaces/EqualizerController.d.ts create mode 100644 dist/types/registry/interfaces/InputController.d.ts create mode 100644 dist/types/registry/interfaces/PlaybackController.d.ts create mode 100644 dist/types/registry/interfaces/PlaybackStateReporter.d.ts create mode 100644 dist/types/registry/interfaces/Speaker.d.ts create mode 100644 dist/types/registry/interfaces/StepSpeaker.d.ts create mode 100644 src/registry/interfaces/ChannelController.ts create mode 100644 src/registry/interfaces/EqualizerController.ts create mode 100644 src/registry/interfaces/InputController.ts create mode 100644 src/registry/interfaces/PlaybackController.ts create mode 100644 src/registry/interfaces/PlaybackStateReporter.ts create mode 100644 src/registry/interfaces/Speaker.ts create mode 100644 src/registry/interfaces/StepSpeaker.ts create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.response.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/ChangeReport.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.response.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/StateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/channel.property.json create mode 100644 test/fixtures/alexa-docs/alexa-channelcontroller/discovery-addOrUpdateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.response.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/ChangeReport.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.response.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.response.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.response.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/StateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/bands.property.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/discovery.json create mode 100644 test/fixtures/alexa-docs/alexa-equalizercontroller/mode.property.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/ChangeReport.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.response.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/StateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/discovery-addOrUpdateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-inputcontroller/discovery.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/ChangeReport.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Next.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Next.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Play.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Play.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/StateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.response.json create mode 100644 test/fixtures/alexa-docs/alexa-playbackcontroller/discovery.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.response.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/ChangeReport.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/SetMute.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/SetMute.response.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/SetVolume.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/SetVolume.response.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/StateReport.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/discovery.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/muted.property.json create mode 100644 test/fixtures/alexa-docs/alexa-speaker/volume.property.json create mode 100644 test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.response.json create mode 100644 test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.directive.json create mode 100644 test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.response.json create mode 100644 test/fixtures/alexa-docs/alexa-stepspeaker/discovery.json create mode 100644 test/registry/entertainment.test.js diff --git a/dist/cjs/index.js b/dist/cjs/index.js index b52523f..9a2944b 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.DisplayCategory = exports.AlexaInterfaceType = exports.AlexaErrorType = exports.AlexaActions = exports.ActionMapping = exports.AlexaInterface = exports.MemoryPublisher = exports.topics = exports.property = exports.StateBuilder = exports.MessageError = exports.AlexaErrors = exports.AlexaError = exports.messages = exports.ThermostatModes = exports.DisplayCategories = exports.States = exports.Actions = exports.Units = exports.Assets = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.EndpointHealth = exports.PowerController = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.SecurityPanelController = exports.RangeController = exports.PowerLevelController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.SchemaError = exports.DeclarationError = exports.registry = exports.Capability = exports.Device = exports.DEFAULT_HOST = exports.Alex2MQTT = void 0; -exports.AlexaErrorResponse = exports.AlexaStatusMessage = exports.ThermostatMode = exports.TemperatureSensorScale = exports.PowerState = void 0; +exports.property = exports.StateBuilder = exports.MessageError = exports.AlexaErrors = exports.AlexaError = exports.messages = exports.ThermostatModes = exports.Inputs = exports.DisplayCategories = exports.States = exports.Actions = exports.Units = exports.Assets = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.EndpointHealth = exports.PowerController = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.StepSpeaker = exports.Speaker = exports.SecurityPanelController = exports.RangeController = exports.PowerLevelController = exports.PlaybackStateReporter = exports.PlaybackController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.InputController = exports.HumiditySensor = exports.EqualizerController = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.ChannelController = exports.BrightnessController = exports.Alexa = exports.SchemaError = exports.DeclarationError = exports.registry = exports.Capability = exports.Device = exports.DEFAULT_HOST = exports.Alex2MQTT = void 0; +exports.AlexaErrorResponse = exports.AlexaStatusMessage = exports.ThermostatMode = exports.TemperatureSensorScale = exports.PowerState = exports.DisplayCategory = exports.AlexaInterfaceType = exports.AlexaErrorType = exports.AlexaActions = exports.ActionMapping = exports.AlexaInterface = exports.MemoryPublisher = exports.topics = void 0; // Relative specifiers carry ".js": Node's ES module loader resolves no extension, and TypeScript maps it back to the .ts. var Alex2Node_js_1 = require("./Alex2Node.js"); Object.defineProperty(exports, "Alex2MQTT", { enumerable: true, get: function () { return __importDefault(Alex2Node_js_1).default; } }); @@ -54,17 +54,24 @@ Object.defineProperty(exports, "SchemaError", { enumerable: true, get: function var index_js_2 = require("./registry/index.js"); Object.defineProperty(exports, "Alexa", { enumerable: true, get: function () { return index_js_2.Alexa; } }); Object.defineProperty(exports, "BrightnessController", { enumerable: true, get: function () { return index_js_2.BrightnessController; } }); +Object.defineProperty(exports, "ChannelController", { enumerable: true, get: function () { return index_js_2.ChannelController; } }); Object.defineProperty(exports, "ColorController", { enumerable: true, get: function () { return index_js_2.ColorController; } }); Object.defineProperty(exports, "ColorTemperatureController", { enumerable: true, get: function () { return index_js_2.ColorTemperatureController; } }); Object.defineProperty(exports, "ContactSensor", { enumerable: true, get: function () { return index_js_2.ContactSensor; } }); +Object.defineProperty(exports, "EqualizerController", { enumerable: true, get: function () { return index_js_2.EqualizerController; } }); Object.defineProperty(exports, "HumiditySensor", { enumerable: true, get: function () { return index_js_2.HumiditySensor; } }); +Object.defineProperty(exports, "InputController", { enumerable: true, get: function () { return index_js_2.InputController; } }); Object.defineProperty(exports, "LockController", { enumerable: true, get: function () { return index_js_2.LockController; } }); Object.defineProperty(exports, "ModeController", { enumerable: true, get: function () { return index_js_2.ModeController; } }); Object.defineProperty(exports, "MotionSensor", { enumerable: true, get: function () { return index_js_2.MotionSensor; } }); Object.defineProperty(exports, "PercentageController", { enumerable: true, get: function () { return index_js_2.PercentageController; } }); +Object.defineProperty(exports, "PlaybackController", { enumerable: true, get: function () { return index_js_2.PlaybackController; } }); +Object.defineProperty(exports, "PlaybackStateReporter", { enumerable: true, get: function () { return index_js_2.PlaybackStateReporter; } }); Object.defineProperty(exports, "PowerLevelController", { enumerable: true, get: function () { return index_js_2.PowerLevelController; } }); Object.defineProperty(exports, "RangeController", { enumerable: true, get: function () { return index_js_2.RangeController; } }); Object.defineProperty(exports, "SecurityPanelController", { enumerable: true, get: function () { return index_js_2.SecurityPanelController; } }); +Object.defineProperty(exports, "Speaker", { enumerable: true, get: function () { return index_js_2.Speaker; } }); +Object.defineProperty(exports, "StepSpeaker", { enumerable: true, get: function () { return index_js_2.StepSpeaker; } }); Object.defineProperty(exports, "TemperatureSensor", { enumerable: true, get: function () { return index_js_2.TemperatureSensor; } }); Object.defineProperty(exports, "ThermostatController", { enumerable: true, get: function () { return index_js_2.ThermostatController; } }); Object.defineProperty(exports, "ThermostatControllerSchedule", { enumerable: true, get: function () { return index_js_2.ThermostatControllerSchedule; } }); @@ -84,6 +91,7 @@ Object.defineProperty(exports, "Units", { enumerable: true, get: function () { r Object.defineProperty(exports, "Actions", { enumerable: true, get: function () { return index_js_4.ACTIONS; } }); Object.defineProperty(exports, "States", { enumerable: true, get: function () { return index_js_4.STATES; } }); Object.defineProperty(exports, "DisplayCategories", { enumerable: true, get: function () { return index_js_4.DISPLAY_CATEGORIES; } }); +Object.defineProperty(exports, "Inputs", { enumerable: true, get: function () { return index_js_4.INPUTS; } }); Object.defineProperty(exports, "ThermostatModes", { enumerable: true, get: function () { return index_js_4.THERMOSTAT_MODES; } }); // The messages: what the bridge publishes, built from plain values exports.messages = __importStar(require("./messages/index.js")); diff --git a/dist/cjs/registry/index.js b/dist/cjs/registry/index.js index f1505c5..8da9f6c 100644 --- a/dist/cjs/registry/index.js +++ b/dist/cjs/registry/index.js @@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SchemaError = exports.s = exports.defineInterface = exports.DeclarationError = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.THERMOSTAT_MODES = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.SecurityPanelController = exports.RangeController = exports.PowerLevelController = exports.PowerController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.HumiditySensor = exports.EndpointHealth = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.BrightnessController = exports.Alexa = exports.registry = void 0; +exports.SchemaError = exports.s = exports.defineInterface = exports.DeclarationError = exports.SemanticsBuilder = exports.semantics = exports.text = exports.asset = exports.THERMOSTAT_MODES = exports.INPUTS = exports.ToggleController = exports.ThermostatControllerSchedule = exports.ThermostatController = exports.TemperatureSensor = exports.StepSpeaker = exports.Speaker = exports.SecurityPanelController = exports.RangeController = exports.PowerLevelController = exports.PowerController = exports.PlaybackStateReporter = exports.PlaybackController = exports.PercentageController = exports.MotionSensor = exports.ModeController = exports.LockController = exports.InputController = exports.HumiditySensor = exports.EqualizerController = exports.EndpointHealth = exports.ContactSensor = exports.ColorTemperatureController = exports.ColorController = exports.ChannelController = exports.BrightnessController = exports.Alexa = exports.registry = void 0; // The interfaces the library knows, by namespace. const Alexa_js_1 = require("./interfaces/Alexa.js"); Object.defineProperty(exports, "Alexa", { enumerable: true, get: function () { return Alexa_js_1.Alexa; } }); const BrightnessController_js_1 = require("./interfaces/BrightnessController.js"); Object.defineProperty(exports, "BrightnessController", { enumerable: true, get: function () { return BrightnessController_js_1.BrightnessController; } }); +const ChannelController_js_1 = require("./interfaces/ChannelController.js"); +Object.defineProperty(exports, "ChannelController", { enumerable: true, get: function () { return ChannelController_js_1.ChannelController; } }); const ColorController_js_1 = require("./interfaces/ColorController.js"); Object.defineProperty(exports, "ColorController", { enumerable: true, get: function () { return ColorController_js_1.ColorController; } }); const ColorTemperatureController_js_1 = require("./interfaces/ColorTemperatureController.js"); @@ -28,8 +30,12 @@ const ContactSensor_js_1 = require("./interfaces/ContactSensor.js"); Object.defineProperty(exports, "ContactSensor", { enumerable: true, get: function () { return ContactSensor_js_1.ContactSensor; } }); const EndpointHealth_js_1 = require("./interfaces/EndpointHealth.js"); Object.defineProperty(exports, "EndpointHealth", { enumerable: true, get: function () { return EndpointHealth_js_1.EndpointHealth; } }); +const EqualizerController_js_1 = require("./interfaces/EqualizerController.js"); +Object.defineProperty(exports, "EqualizerController", { enumerable: true, get: function () { return EqualizerController_js_1.EqualizerController; } }); const HumiditySensor_js_1 = require("./interfaces/HumiditySensor.js"); Object.defineProperty(exports, "HumiditySensor", { enumerable: true, get: function () { return HumiditySensor_js_1.HumiditySensor; } }); +const InputController_js_1 = require("./interfaces/InputController.js"); +Object.defineProperty(exports, "InputController", { enumerable: true, get: function () { return InputController_js_1.InputController; } }); const LockController_js_1 = require("./interfaces/LockController.js"); Object.defineProperty(exports, "LockController", { enumerable: true, get: function () { return LockController_js_1.LockController; } }); const ModeController_js_1 = require("./interfaces/ModeController.js"); @@ -38,6 +44,10 @@ const MotionSensor_js_1 = require("./interfaces/MotionSensor.js"); Object.defineProperty(exports, "MotionSensor", { enumerable: true, get: function () { return MotionSensor_js_1.MotionSensor; } }); const PercentageController_js_1 = require("./interfaces/PercentageController.js"); Object.defineProperty(exports, "PercentageController", { enumerable: true, get: function () { return PercentageController_js_1.PercentageController; } }); +const PlaybackController_js_1 = require("./interfaces/PlaybackController.js"); +Object.defineProperty(exports, "PlaybackController", { enumerable: true, get: function () { return PlaybackController_js_1.PlaybackController; } }); +const PlaybackStateReporter_js_1 = require("./interfaces/PlaybackStateReporter.js"); +Object.defineProperty(exports, "PlaybackStateReporter", { enumerable: true, get: function () { return PlaybackStateReporter_js_1.PlaybackStateReporter; } }); const PowerController_js_1 = require("./interfaces/PowerController.js"); Object.defineProperty(exports, "PowerController", { enumerable: true, get: function () { return PowerController_js_1.PowerController; } }); const PowerLevelController_js_1 = require("./interfaces/PowerLevelController.js"); @@ -46,6 +56,10 @@ const RangeController_js_1 = require("./interfaces/RangeController.js"); Object.defineProperty(exports, "RangeController", { enumerable: true, get: function () { return RangeController_js_1.RangeController; } }); const SecurityPanelController_js_1 = require("./interfaces/SecurityPanelController.js"); Object.defineProperty(exports, "SecurityPanelController", { enumerable: true, get: function () { return SecurityPanelController_js_1.SecurityPanelController; } }); +const Speaker_js_1 = require("./interfaces/Speaker.js"); +Object.defineProperty(exports, "Speaker", { enumerable: true, get: function () { return Speaker_js_1.Speaker; } }); +const StepSpeaker_js_1 = require("./interfaces/StepSpeaker.js"); +Object.defineProperty(exports, "StepSpeaker", { enumerable: true, get: function () { return StepSpeaker_js_1.StepSpeaker; } }); const TemperatureSensor_js_1 = require("./interfaces/TemperatureSensor.js"); Object.defineProperty(exports, "TemperatureSensor", { enumerable: true, get: function () { return TemperatureSensor_js_1.TemperatureSensor; } }); const ThermostatController_js_1 = require("./interfaces/ThermostatController.js"); @@ -59,19 +73,26 @@ const types_js_1 = require("./types.js"); const described = [ Alexa_js_1.Alexa, BrightnessController_js_1.BrightnessController, + ChannelController_js_1.ChannelController, ColorController_js_1.ColorController, ColorTemperatureController_js_1.ColorTemperatureController, ContactSensor_js_1.ContactSensor, EndpointHealth_js_1.EndpointHealth, + EqualizerController_js_1.EqualizerController, HumiditySensor_js_1.HumiditySensor, + InputController_js_1.InputController, LockController_js_1.LockController, ModeController_js_1.ModeController, MotionSensor_js_1.MotionSensor, PercentageController_js_1.PercentageController, + PlaybackController_js_1.PlaybackController, + PlaybackStateReporter_js_1.PlaybackStateReporter, PowerController_js_1.PowerController, PowerLevelController_js_1.PowerLevelController, RangeController_js_1.RangeController, SecurityPanelController_js_1.SecurityPanelController, + Speaker_js_1.Speaker, + StepSpeaker_js_1.StepSpeaker, TemperatureSensor_js_1.TemperatureSensor, ThermostatController_js_1.ThermostatController, ThermostatControllerSchedule_js_1.ThermostatControllerSchedule, @@ -101,6 +122,8 @@ exports.registry = { return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1)); }, }; +var InputController_js_2 = require("./interfaces/InputController.js"); +Object.defineProperty(exports, "INPUTS", { enumerable: true, get: function () { return InputController_js_2.INPUTS; } }); var ThermostatController_js_2 = require("./interfaces/ThermostatController.js"); Object.defineProperty(exports, "THERMOSTAT_MODES", { enumerable: true, get: function () { return ThermostatController_js_2.THERMOSTAT_MODES; } }); var resources_js_1 = require("./resources.js"); diff --git a/dist/cjs/registry/interfaces/ChannelController.js b/dist/cjs/registry/interfaces/ChannelController.js new file mode 100644 index 0000000..f64528a --- /dev/null +++ b/dist/cjs/registry/interfaces/ChannelController.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ChannelController = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +// None of the fields is required, a channel has one of them at least +const channel = schema_js_1.s.object({ + /** "256", "13.1" */ + number: schema_js_1.s.optional(schema_js_1.s.string()), + callSign: schema_js_1.s.optional(schema_js_1.s.string()), + affiliateCallSign: schema_js_1.s.optional(schema_js_1.s.string()), + uri: schema_js_1.s.optional(schema_js_1.s.string()), +}); +/** + * The channel of a TV. ChangeChannel names the channel by one or more of number, callSign, affiliateCallSign and + * uri, or by channelMetadata.name alone. The lineup of a TV provider is not described: the page folds the discovery + * example that has one. + */ +exports.ChannelController = (0, types_js_1.defineInterface)({ + namespace: "Alexa.ChannelController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-channelcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + channel: { name: "channel", value: channel }, + }, + directives: { + ChangeChannel: { + name: "ChangeChannel", + payload: schema_js_1.s.object({ + channel: schema_js_1.s.optional(channel), + channelMetadata: schema_js_1.s.optional(schema_js_1.s.object({ name: schema_js_1.s.optional(schema_js_1.s.string()), image: schema_js_1.s.optional(schema_js_1.s.string()) })), + }), + }, + SkipChannels: { + name: "SkipChannels", + payload: schema_js_1.s.object({ channelCount: schema_js_1.s.number({ integer: true }) }), + note: "above 0 up, below 0 down", + }, + }, +}); diff --git a/dist/cjs/registry/interfaces/EqualizerController.js b/dist/cjs/registry/interfaces/EqualizerController.js new file mode 100644 index 0000000..3d0b290 --- /dev/null +++ b/dist/cjs/registry/interfaces/EqualizerController.js @@ -0,0 +1,72 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EqualizerController = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +const BANDS = ["BASS", "MIDRANGE", "TREBLE"]; +const MODES = ["MOVIE", "MUSIC", "NIGHT", "SPORT", "TV"]; +const band = schema_js_1.s.enum(...BANDS); +const level = schema_js_1.s.number({ integer: true }); +/** + * The bands of an equalizer, its modes, or both. Discovery lists bands for a device declared with bands and mode + * for one declared with modes. A band or a mode the device does not have is answered with INVALID_VALUE. + */ +exports.EqualizerController = (0, types_js_1.defineInterface)({ + namespace: "Alexa.EqualizerController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-equalizercontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + bands: { name: "bands", value: schema_js_1.s.array(schema_js_1.s.object({ name: band, value: level })) }, + mode: { name: "mode", value: schema_js_1.s.enum(...MODES) }, + }, + directives: { + SetMode: { name: "SetMode", payload: schema_js_1.s.object({ mode: schema_js_1.s.enum(...MODES) }) }, + SetBands: { name: "SetBands", payload: schema_js_1.s.object({ bands: schema_js_1.s.array(schema_js_1.s.object({ name: band, value: level }), { min: 1 }) }) }, + AdjustBands: { + name: "AdjustBands", + payload: schema_js_1.s.object({ + bands: schema_js_1.s.array(schema_js_1.s.object({ name: band, levelDelta: schema_js_1.s.optional(level), levelDirection: schema_js_1.s.enum("UP", "DOWN") }), { min: 1 }), + }), + note: "without levelDelta the band moves by the step the device has for it", + }, + ResetBands: { name: "ResetBands", payload: schema_js_1.s.object({ bands: schema_js_1.s.array(schema_js_1.s.object({ name: band }), { min: 1 }) }) }, + }, + options: schema_js_1.s.object({ + /** The bands of the device and the levels they take. Left out for a device that has modes only. */ + bands: schema_js_1.s.optional(schema_js_1.s.object({ + supported: schema_js_1.s.array(band, { min: 1 }), + range: schema_js_1.s.object({ minimum: level, maximum: level }, { unknownKeys: "reject" }), + }, { unknownKeys: "reject" })), + /** Left out for a device that has bands only. */ + modes: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.enum(...MODES), { min: 1 })), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has neither; check() says so, discovery lists both properties + discovery({ options: { bands, modes } }) { + if (!bands && !modes) + return {}; + return { + supported: [...(bands ? ["bands"] : []), ...(modes ? ["mode"] : [])], + configurations: { + ...(bands && { bands: { supported: bands.supported.map((name) => ({ name })), range: bands.range } }), + ...(modes && { modes: { supported: modes.map((name) => ({ name })) } }), + }, + }; + }, + validate(capability) { + const { bands, modes = [] } = capability.options; + if (!bands && modes.length === 0) + throw new types_js_1.DeclarationError(capability, "needs bands, modes or both: declare what the equalizer has"); + if (bands && bands.range.maximum <= bands.range.minimum) { + throw new types_js_1.DeclarationError(capability, `bands.range.maximum ${bands.range.maximum} is not above bands.range.minimum ${bands.range.minimum}`); + } + const lists = [bands?.supported ?? [], modes]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) + throw new types_js_1.DeclarationError(capability, `${twice} is listed twice`); + } + }, +}); diff --git a/dist/cjs/registry/interfaces/InputController.js b/dist/cjs/registry/interfaces/InputController.js new file mode 100644 index 0000000..4873dea --- /dev/null +++ b/dist/cjs/registry/interfaces/InputController.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InputController = exports.INPUTS = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +/** alexa-inputcontroller.html, "Input property values". */ +exports.INPUTS = [ + "AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", + "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", + "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", + "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", + "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", + "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX", +]; +const input = schema_js_1.s.oneOf(exports.INPUTS, "an input like HDMI 1"); +/** + * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery + * example of the page has them; its table calls them a configuration object. + */ +exports.InputController = (0, types_js_1.defineInterface)({ + namespace: "Alexa.InputController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-inputcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + input: { name: "input", value: input }, + }, + directives: { + SelectInput: { name: "SelectInput", payload: schema_js_1.s.object({ input }) }, + }, + options: schema_js_1.s.object({ + /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ + inputs: schema_js_1.s.array(schema_js_1.s.object({ name: input, friendlyNames: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.string({ min: 1 }))) }, { unknownKeys: "reject" }), { min: 1 }), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has no inputs; check() says so + discovery: ({ options: { inputs } }) => (inputs ? { topLevel: { inputs } } : {}), + validate(capability) { + const names = capability.options.inputs.map(({ name }) => name); + const called = capability.options.inputs.flatMap(({ friendlyNames = [] }) => friendlyNames); + const lists = [names, called]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) + throw new types_js_1.DeclarationError(capability, `${twice} is listed twice, a name stands for one input`); + } + }, +}); diff --git a/dist/cjs/registry/interfaces/PlaybackController.js b/dist/cjs/registry/interfaces/PlaybackController.js new file mode 100644 index 0000000..33081cf --- /dev/null +++ b/dist/cjs/registry/interfaces/PlaybackController.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PlaybackController = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +// In the order of the discovery example +const OPERATIONS = ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"]; +// Alexa sends the operations the capability lists +const operation = (name) => ({ + name, + payload: schema_js_1.s.object({}), + when: ({ options }) => (options.supportedOperations ?? OPERATIONS).includes(name), +}); +/** + * Play, pause and the other buttons of a player. The interface reports nothing: what plays is the playbackState of + * Alexa.PlaybackStateReporter, which a Response to these directives has in its context. Errors of a video device go + * under Alexa.Video, the others under Alexa. + */ +exports.PlaybackController = (0, types_js_1.defineInterface)({ + namespace: "Alexa.PlaybackController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + Play: operation("Play"), + Pause: operation("Pause"), + Stop: operation("Stop"), + Next: operation("Next"), + Previous: operation("Previous"), + FastForward: operation("FastForward"), + Rewind: operation("Rewind"), + StartOver: operation("StartOver"), + }, + options: schema_js_1.s.object({ + /** Default: all eight. */ + supportedOperations: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.enum(...OPERATIONS), { min: 1 })), + }, { unknownKeys: "reject" }), + // The example has a properties object without fields, which topLevel puts where properties: false left none + discovery: ({ options: { supportedOperations = [...OPERATIONS] } }) => ({ + properties: false, + topLevel: { properties: {}, supportedOperations }, + }), +}); diff --git a/dist/cjs/registry/interfaces/PlaybackStateReporter.js b/dist/cjs/registry/interfaces/PlaybackStateReporter.js new file mode 100644 index 0000000..08bf4e8 --- /dev/null +++ b/dist/cjs/registry/interfaces/PlaybackStateReporter.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PlaybackStateReporter = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +/** What a player is doing, for an endpoint with Alexa.PlaybackController. Documented on the page of that interface. */ +exports.PlaybackStateReporter = (0, types_js_1.defineInterface)({ + namespace: "Alexa.PlaybackStateReporter", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "sensor", + tier: 2, + instanced: false, + properties: { + playbackState: { name: "playbackState", value: schema_js_1.s.object({ state: schema_js_1.s.enum("PLAYING", "PAUSED", "STOPPED") }) }, + }, + directives: {}, +}); diff --git a/dist/cjs/registry/interfaces/Speaker.js b/dist/cjs/registry/interfaces/Speaker.js new file mode 100644 index 0000000..1f13588 --- /dev/null +++ b/dist/cjs/registry/interfaces/Speaker.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Speaker = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +/** A speaker that can be set to a volume from 0 to 100. One that only takes steps is an Alexa.StepSpeaker. */ +exports.Speaker = (0, types_js_1.defineInterface)({ + namespace: "Alexa.Speaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-speaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + volume: { name: "volume", value: schema_js_1.s.number({ min: 0, max: 100, integer: true }) }, + muted: { name: "muted", value: schema_js_1.s.boolean() }, + }, + directives: { + SetVolume: { name: "SetVolume", payload: schema_js_1.s.object({ volume: schema_js_1.s.number({ min: 0, max: 100, integer: true }) }) }, + AdjustVolume: { + name: "AdjustVolume", + payload: schema_js_1.s.object({ volume: schema_js_1.s.number({ min: -100, max: 100, integer: true }), volumeDefault: schema_js_1.s.boolean() }), + note: "volume is the change. volumeDefault is true when the user named no amount", + }, + SetMute: { name: "SetMute", payload: schema_js_1.s.object({ mute: schema_js_1.s.boolean() }) }, + }, +}); diff --git a/dist/cjs/registry/interfaces/StepSpeaker.js b/dist/cjs/registry/interfaces/StepSpeaker.js new file mode 100644 index 0000000..cbd0851 --- /dev/null +++ b/dist/cjs/registry/interfaces/StepSpeaker.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StepSpeaker = void 0; +const schema_js_1 = require("../schema.js"); +const types_js_1 = require("../types.js"); +/** + * A speaker that is turned up and down by steps and does not know its volume. It reports nothing: the capability + * has no properties object in discovery. + */ +exports.StepSpeaker = (0, types_js_1.defineInterface)({ + namespace: "Alexa.StepSpeaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-stepspeaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + AdjustVolume: { + name: "AdjustVolume", + payload: schema_js_1.s.object({ volumeSteps: schema_js_1.s.number({ min: -100, max: 100, integer: true }) }), + note: "above 0 louder, below 0 quieter", + }, + SetMute: { name: "SetMute", payload: schema_js_1.s.object({ mute: schema_js_1.s.boolean() }) }, + }, + discovery: () => ({ properties: false }), +}); diff --git a/dist/cjs/registry/interfaces/stubs.js b/dist/cjs/registry/interfaces/stubs.js index 0ab04f3..c9a2a83 100644 --- a/dist/cjs/registry/interfaces/stubs.js +++ b/dist/cjs/registry/interfaces/stubs.js @@ -4,7 +4,7 @@ exports.STUBS = void 0; // Interfaces without a descriptor of their own. A stub names the interface with the version and the properties // alex2node 1.5.2 put in discovery, so an endpoint that declares one is announced as before. Nothing about it is // checked, and the version is the one 1.5.2 sent, which is not always the one on the page of the interface -// (Alexa.Speaker is "3" there). A row leaves this table when a descriptor is written from that page. +// (Alexa.Cooking is "3" there). A row leaves this table when a descriptor is written from that page. const schema_js_1 = require("../schema.js"); const DEVICE_APIS = "https://developer.amazon.com/docs/alexaplus/device-apis"; const LIST_OF_INTERFACES = `${DEVICE_APIS}/list-of-interfaces.html`; @@ -20,7 +20,6 @@ const TABLE = [ // 1.5.2 announced the version "UNKNOWN"; 1.7 is what the list of interfaces gives ["Alexa.Camera.LiveViewController", "1.7", [], LIST_OF_INTERFACES], ["Alexa.CameraStreamController", "3", [], "alexa-camerastreamcontroller.html"], - ["Alexa.ChannelController", "3", ["channel"], "alexa-channelcontroller.html"], ["Alexa.Commissionable", "1", [], "alexa-commissionable.html"], ["Alexa.ConsentManagement.ConsentRequiredReporter", "1", [], "alexa-consentrequiredreporter.html"], ["Alexa.Cooking", "1", [], "alexa-cooking.html"], @@ -34,8 +33,6 @@ const TABLE = [ ["Alexa.DeviceUsage.Estimation", "1", [], "alexa-deviceusage-estimation.html"], ["Alexa.DeviceUsage.Meter", "1", [], "alexa-deviceusage-meter.html"], ["Alexa.DoorbellEventSource", "3", [], "alexa-doorbelleventsource.html"], - ["Alexa.EqualizerController", "1", [], "alexa-equalizercontroller.html"], - ["Alexa.InputController", "3", [], "alexa-inputcontroller.html"], ["Alexa.InventoryLevelSensor", "1", [], "alexa-inventorylevelsensor.html"], ["Alexa.InventoryLevelUsageSensor", "1", [], "alexa-inventorylevelusagesensor.html"], ["Alexa.InventoryUsageSensor", "1", [], "alexa-inventoryusagesensor.html"], @@ -44,8 +41,6 @@ const TABLE = [ ["Alexa.Media.PlayQueue", "1", [], "alexa-media-playqueue.html"], ["Alexa.Media.Playback", "1", [], "alexa-media-playback.html"], ["Alexa.Media.Search", "1", [], "alexa-media-search.html"], - ["Alexa.PlaybackController", "3", [], "alexa-playbackcontroller.html"], - ["Alexa.PlaybackStateReporter", "1", [], "alexa-playbackcontroller.html"], ["Alexa.ProactiveNotificationSource", "1", [], "alexa-proactivenotificationsource.html"], ["Alexa.RTCSessionController", "1", [], "alexa-rtcsessioncontroller.html"], ["Alexa.RecordController", "3", [], "alexa-recordcontroller.html"], @@ -56,8 +51,6 @@ const TABLE = [ ["Alexa.SimpleEventSource", "1", [], "alexa-simpleeventsource.html"], ["Alexa.SmartVision.ObjectDetectionSensor", "1", [], "alexa-smartvision-objectdetectionsensor.html"], ["Alexa.SmartVision.SnapshotProvider", "1", [], "alexa-smartvision-snapshotprovider.html"], - ["Alexa.Speaker", "1", [], "alexa-speaker.html"], - ["Alexa.StepSpeaker", "1", [], "alexa-stepspeaker.html"], ["Alexa.ThermostatController.Configuration", "1", [], "alexa-thermostatcontroller-configuration.html"], ["Alexa.ThermostatController.HVAC.Components", "1", [], "alexa-thermostatcontroller-hvac-components.html"], // "UNKNOWN" in 1.5.2 as well; the page is titled "Interface 3" diff --git a/dist/esm/index.d.ts b/dist/esm/index.d.ts index 719331e..6caa0e7 100644 --- a/dist/esm/index.d.ts +++ b/dist/esm/index.d.ts @@ -5,11 +5,11 @@ export type { EndpointDefinition, EndpointJson } from "./device/Device.js"; export { Capability } from "./device/Capability.js"; export type { CapabilityJson, CommonOptions, Declaration } from "./device/Capability.js"; export { registry, DeclarationError, SchemaError } from "./registry/index.js"; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; export { PowerController, EndpointHealth } from "./compat/enums.js"; export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js"; -export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; -export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js"; +export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; +export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, InputName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js"; export * as messages from "./messages/index.js"; export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js"; export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js"; diff --git a/dist/esm/index.js b/dist/esm/index.js index 56e13a2..6bbaf62 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -4,11 +4,11 @@ export { default as Device } from "./device/Device.js"; export { Capability } from "./device/Capability.js"; // The interfaces, for device.add(), and the registry that holds them by name export { registry, DeclarationError, SchemaError } from "./registry/index.js"; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; export { PowerController, EndpointHealth } from "./compat/enums.js"; export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js"; // The vocabularies of the Smart Home API -export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; +export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; // The messages: what the bridge publishes, built from plain values export * as messages from "./messages/index.js"; export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js"; diff --git a/dist/esm/registry/index.d.ts b/dist/esm/registry/index.d.ts index aff5619..e1db8d6 100644 --- a/dist/esm/registry/index.d.ts +++ b/dist/esm/registry/index.d.ts @@ -1,18 +1,25 @@ import { Alexa } from "./interfaces/Alexa.js"; import { BrightnessController } from "./interfaces/BrightnessController.js"; +import { ChannelController } from "./interfaces/ChannelController.js"; import { ColorController } from "./interfaces/ColorController.js"; import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js"; import { ContactSensor } from "./interfaces/ContactSensor.js"; import { EndpointHealth } from "./interfaces/EndpointHealth.js"; +import { EqualizerController } from "./interfaces/EqualizerController.js"; import { HumiditySensor } from "./interfaces/HumiditySensor.js"; +import { InputController } from "./interfaces/InputController.js"; import { LockController } from "./interfaces/LockController.js"; import { ModeController } from "./interfaces/ModeController.js"; import { MotionSensor } from "./interfaces/MotionSensor.js"; import { PercentageController } from "./interfaces/PercentageController.js"; +import { PlaybackController } from "./interfaces/PlaybackController.js"; +import { PlaybackStateReporter } from "./interfaces/PlaybackStateReporter.js"; import { PowerController } from "./interfaces/PowerController.js"; import { PowerLevelController } from "./interfaces/PowerLevelController.js"; import { RangeController } from "./interfaces/RangeController.js"; import { SecurityPanelController } from "./interfaces/SecurityPanelController.js"; +import { Speaker } from "./interfaces/Speaker.js"; +import { StepSpeaker } from "./interfaces/StepSpeaker.js"; import { TemperatureSensor } from "./interfaces/TemperatureSensor.js"; import { ThermostatController } from "./interfaces/ThermostatController.js"; import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js"; @@ -26,7 +33,9 @@ export declare const registry: { /** Every descriptor, ordered by namespace. */ list(): AnyDescriptor[]; }; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerController, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { INPUTS } from "./interfaces/InputController.js"; +export type { InputName } from "./interfaces/InputController.js"; export type { Mode } from "./interfaces/ModeController.js"; export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js"; export type { ThermostatModeName } from "./interfaces/ThermostatController.js"; diff --git a/dist/esm/registry/index.js b/dist/esm/registry/index.js index 6bc9b24..777213d 100644 --- a/dist/esm/registry/index.js +++ b/dist/esm/registry/index.js @@ -1,19 +1,26 @@ // The interfaces the library knows, by namespace. import { Alexa } from "./interfaces/Alexa.js"; import { BrightnessController } from "./interfaces/BrightnessController.js"; +import { ChannelController } from "./interfaces/ChannelController.js"; import { ColorController } from "./interfaces/ColorController.js"; import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js"; import { ContactSensor } from "./interfaces/ContactSensor.js"; import { EndpointHealth } from "./interfaces/EndpointHealth.js"; +import { EqualizerController } from "./interfaces/EqualizerController.js"; import { HumiditySensor } from "./interfaces/HumiditySensor.js"; +import { InputController } from "./interfaces/InputController.js"; import { LockController } from "./interfaces/LockController.js"; import { ModeController } from "./interfaces/ModeController.js"; import { MotionSensor } from "./interfaces/MotionSensor.js"; import { PercentageController } from "./interfaces/PercentageController.js"; +import { PlaybackController } from "./interfaces/PlaybackController.js"; +import { PlaybackStateReporter } from "./interfaces/PlaybackStateReporter.js"; import { PowerController } from "./interfaces/PowerController.js"; import { PowerLevelController } from "./interfaces/PowerLevelController.js"; import { RangeController } from "./interfaces/RangeController.js"; import { SecurityPanelController } from "./interfaces/SecurityPanelController.js"; +import { Speaker } from "./interfaces/Speaker.js"; +import { StepSpeaker } from "./interfaces/StepSpeaker.js"; import { TemperatureSensor } from "./interfaces/TemperatureSensor.js"; import { ThermostatController } from "./interfaces/ThermostatController.js"; import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js"; @@ -23,19 +30,26 @@ import { DeclarationError } from "./types.js"; const described = [ Alexa, BrightnessController, + ChannelController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, + EqualizerController, HumiditySensor, + InputController, LockController, ModeController, MotionSensor, PercentageController, + PlaybackController, + PlaybackStateReporter, PowerController, PowerLevelController, RangeController, SecurityPanelController, + Speaker, + StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, @@ -65,7 +79,8 @@ export const registry = { return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1)); }, }; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerController, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { INPUTS } from "./interfaces/InputController.js"; export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js"; export { asset, text } from "./resources.js"; export { semantics, SemanticsBuilder } from "./semantics.js"; diff --git a/dist/esm/registry/interfaces/ChannelController.d.ts b/dist/esm/registry/interfaces/ChannelController.d.ts new file mode 100644 index 0000000..a331cef --- /dev/null +++ b/dist/esm/registry/interfaces/ChannelController.d.ts @@ -0,0 +1,41 @@ +/** + * The channel of a TV. ChangeChannel names the channel by one or more of number, callSign, affiliateCallSign and + * uri, or by channelMetadata.name alone. The lineup of a TV provider is not described: the page folds the discovery + * example that has one. + */ +export declare const ChannelController: import("../types.js").InterfaceDescriptor<{ + channel: { + name: string; + value: import("../schema.js").Schema; + callSign: import("../schema.js").OptionalSchema; + affiliateCallSign: import("../schema.js").OptionalSchema; + uri: import("../schema.js").OptionalSchema; + }>>; + }; +}, { + ChangeChannel: { + name: string; + payload: import("../schema.js").Schema; + callSign: import("../schema.js").OptionalSchema; + affiliateCallSign: import("../schema.js").OptionalSchema; + uri: import("../schema.js").OptionalSchema; + }>>; + channelMetadata: import("../schema.js").OptionalSchema; + image: import("../schema.js").OptionalSchema; + }>>; + }>>; + }; + SkipChannels: { + name: string; + payload: import("../schema.js").Schema; + }>>; + note: string; + }; +}, {}, false>; diff --git a/dist/esm/registry/interfaces/ChannelController.js b/dist/esm/registry/interfaces/ChannelController.js new file mode 100644 index 0000000..b435229 --- /dev/null +++ b/dist/esm/registry/interfaces/ChannelController.js @@ -0,0 +1,40 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +// None of the fields is required, a channel has one of them at least +const channel = s.object({ + /** "256", "13.1" */ + number: s.optional(s.string()), + callSign: s.optional(s.string()), + affiliateCallSign: s.optional(s.string()), + uri: s.optional(s.string()), +}); +/** + * The channel of a TV. ChangeChannel names the channel by one or more of number, callSign, affiliateCallSign and + * uri, or by channelMetadata.name alone. The lineup of a TV provider is not described: the page folds the discovery + * example that has one. + */ +export const ChannelController = defineInterface({ + namespace: "Alexa.ChannelController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-channelcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + channel: { name: "channel", value: channel }, + }, + directives: { + ChangeChannel: { + name: "ChangeChannel", + payload: s.object({ + channel: s.optional(channel), + channelMetadata: s.optional(s.object({ name: s.optional(s.string()), image: s.optional(s.string()) })), + }), + }, + SkipChannels: { + name: "SkipChannels", + payload: s.object({ channelCount: s.number({ integer: true }) }), + note: "above 0 up, below 0 down", + }, + }, +}); diff --git a/dist/esm/registry/interfaces/EqualizerController.d.ts b/dist/esm/registry/interfaces/EqualizerController.d.ts new file mode 100644 index 0000000..be87632 --- /dev/null +++ b/dist/esm/registry/interfaces/EqualizerController.d.ts @@ -0,0 +1,63 @@ +/** + * The bands of an equalizer, its modes, or both. Discovery lists bands for a device declared with bands and mode + * for one declared with modes. A band or a mode the device does not have is answered with INVALID_VALUE. + */ +export declare const EqualizerController: import("../types.js").InterfaceDescriptor<{ + bands: { + name: string; + value: import("../schema.js").Schema; + value: import("../schema.js").Schema; + }>[]>; + }; + mode: { + name: string; + value: import("../schema.js").EnumSchema<"TV" | "MOVIE" | "MUSIC" | "NIGHT" | "SPORT">; + }; +}, { + SetMode: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; + SetBands: { + name: string; + payload: import("../schema.js").Schema; + value: import("../schema.js").Schema; + }>[]>; + }>>; + }; + AdjustBands: { + name: string; + payload: import("../schema.js").Schema; + levelDelta: import("../schema.js").OptionalSchema; + levelDirection: import("../schema.js").EnumSchema<"UP" | "DOWN">; + }>[]>; + }>>; + note: string; + }; + ResetBands: { + name: string; + payload: import("../schema.js").Schema; + }>[]>; + }>>; + }; +}, import("../schema.js").InferShape<{ + /** The bands of the device and the levels they take. Left out for a device that has modes only. */ + bands: import("../schema.js").OptionalSchema; + range: import("../schema.js").Schema; + maximum: import("../schema.js").Schema; + }>>; + }>>; + /** Left out for a device that has bands only. */ + modes: import("../schema.js").OptionalSchema<("TV" | "MOVIE" | "MUSIC" | "NIGHT" | "SPORT")[]>; +}>, false>; diff --git a/dist/esm/registry/interfaces/EqualizerController.js b/dist/esm/registry/interfaces/EqualizerController.js new file mode 100644 index 0000000..cb7f06e --- /dev/null +++ b/dist/esm/registry/interfaces/EqualizerController.js @@ -0,0 +1,69 @@ +import { s } from "../schema.js"; +import { DeclarationError, defineInterface } from "../types.js"; +const BANDS = ["BASS", "MIDRANGE", "TREBLE"]; +const MODES = ["MOVIE", "MUSIC", "NIGHT", "SPORT", "TV"]; +const band = s.enum(...BANDS); +const level = s.number({ integer: true }); +/** + * The bands of an equalizer, its modes, or both. Discovery lists bands for a device declared with bands and mode + * for one declared with modes. A band or a mode the device does not have is answered with INVALID_VALUE. + */ +export const EqualizerController = defineInterface({ + namespace: "Alexa.EqualizerController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-equalizercontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + bands: { name: "bands", value: s.array(s.object({ name: band, value: level })) }, + mode: { name: "mode", value: s.enum(...MODES) }, + }, + directives: { + SetMode: { name: "SetMode", payload: s.object({ mode: s.enum(...MODES) }) }, + SetBands: { name: "SetBands", payload: s.object({ bands: s.array(s.object({ name: band, value: level }), { min: 1 }) }) }, + AdjustBands: { + name: "AdjustBands", + payload: s.object({ + bands: s.array(s.object({ name: band, levelDelta: s.optional(level), levelDirection: s.enum("UP", "DOWN") }), { min: 1 }), + }), + note: "without levelDelta the band moves by the step the device has for it", + }, + ResetBands: { name: "ResetBands", payload: s.object({ bands: s.array(s.object({ name: band }), { min: 1 }) }) }, + }, + options: s.object({ + /** The bands of the device and the levels they take. Left out for a device that has modes only. */ + bands: s.optional(s.object({ + supported: s.array(band, { min: 1 }), + range: s.object({ minimum: level, maximum: level }, { unknownKeys: "reject" }), + }, { unknownKeys: "reject" })), + /** Left out for a device that has bands only. */ + modes: s.optional(s.array(s.enum(...MODES), { min: 1 })), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has neither; check() says so, discovery lists both properties + discovery({ options: { bands, modes } }) { + if (!bands && !modes) + return {}; + return { + supported: [...(bands ? ["bands"] : []), ...(modes ? ["mode"] : [])], + configurations: { + ...(bands && { bands: { supported: bands.supported.map((name) => ({ name })), range: bands.range } }), + ...(modes && { modes: { supported: modes.map((name) => ({ name })) } }), + }, + }; + }, + validate(capability) { + const { bands, modes = [] } = capability.options; + if (!bands && modes.length === 0) + throw new DeclarationError(capability, "needs bands, modes or both: declare what the equalizer has"); + if (bands && bands.range.maximum <= bands.range.minimum) { + throw new DeclarationError(capability, `bands.range.maximum ${bands.range.maximum} is not above bands.range.minimum ${bands.range.minimum}`); + } + const lists = [bands?.supported ?? [], modes]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) + throw new DeclarationError(capability, `${twice} is listed twice`); + } + }, +}); diff --git a/dist/esm/registry/interfaces/InputController.d.ts b/dist/esm/registry/interfaces/InputController.d.ts new file mode 100644 index 0000000..ab84056 --- /dev/null +++ b/dist/esm/registry/interfaces/InputController.d.ts @@ -0,0 +1,26 @@ +/** alexa-inputcontroller.html, "Input property values". */ +export declare const INPUTS: readonly ["AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX"]; +export type InputName = (typeof INPUTS)[number]; +/** + * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery + * example of the page has them; its table calls them a configuration object. + */ +export declare const InputController: import("../types.js").InterfaceDescriptor<{ + input: { + name: string; + value: import("../schema.js").EnumSchema<"TV" | "AUX 1" | "AUX 2" | "AUX 3" | "AUX 4" | "AUX 5" | "AUX 6" | "AUX 7" | "BLURAY" | "CABLE" | "CD" | "COAX 1" | "COAX 2" | "COMPOSITE 1" | "DVD" | "GAME" | "HD RADIO" | "HDMI 1" | "HDMI 2" | "HDMI 3" | "HDMI 4" | "HDMI 5" | "HDMI 6" | "HDMI 7" | "HDMI 8" | "HDMI 9" | "HDMI 10" | "HDMI ARC" | "INPUT 1" | "INPUT 2" | "INPUT 3" | "INPUT 4" | "INPUT 5" | "INPUT 6" | "INPUT 7" | "INPUT 8" | "INPUT 9" | "INPUT 10" | "IPOD" | "LINE 1" | "LINE 2" | "LINE 3" | "LINE 4" | "LINE 5" | "LINE 6" | "LINE 7" | "MEDIA PLAYER" | "OPTICAL 1" | "OPTICAL 2" | "PHONO" | "PLAYSTATION" | "PLAYSTATION 3" | "PLAYSTATION 4" | "SATELLITE" | "SMARTCAST" | "TUNER" | "USB DAC" | "VIDEO 1" | "VIDEO 2" | "VIDEO 3" | "XBOX">; + }; +}, { + SelectInput: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, import("../schema.js").InferShape<{ + /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ + inputs: import("../schema.js").Schema; + friendlyNames: import("../schema.js").OptionalSchema; + }>[]>; +}>, false>; diff --git a/dist/esm/registry/interfaces/InputController.js b/dist/esm/registry/interfaces/InputController.js new file mode 100644 index 0000000..76d9e03 --- /dev/null +++ b/dist/esm/registry/interfaces/InputController.js @@ -0,0 +1,46 @@ +import { s } from "../schema.js"; +import { DeclarationError, defineInterface } from "../types.js"; +/** alexa-inputcontroller.html, "Input property values". */ +export const INPUTS = [ + "AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", + "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", + "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", + "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", + "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", + "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX", +]; +const input = s.oneOf(INPUTS, "an input like HDMI 1"); +/** + * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery + * example of the page has them; its table calls them a configuration object. + */ +export const InputController = defineInterface({ + namespace: "Alexa.InputController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-inputcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + input: { name: "input", value: input }, + }, + directives: { + SelectInput: { name: "SelectInput", payload: s.object({ input }) }, + }, + options: s.object({ + /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ + inputs: s.array(s.object({ name: input, friendlyNames: s.optional(s.array(s.string({ min: 1 }))) }, { unknownKeys: "reject" }), { min: 1 }), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has no inputs; check() says so + discovery: ({ options: { inputs } }) => (inputs ? { topLevel: { inputs } } : {}), + validate(capability) { + const names = capability.options.inputs.map(({ name }) => name); + const called = capability.options.inputs.flatMap(({ friendlyNames = [] }) => friendlyNames); + const lists = [names, called]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) + throw new DeclarationError(capability, `${twice} is listed twice, a name stands for one input`); + } + }, +}); diff --git a/dist/esm/registry/interfaces/PlaybackController.d.ts b/dist/esm/registry/interfaces/PlaybackController.d.ts new file mode 100644 index 0000000..da29884 --- /dev/null +++ b/dist/esm/registry/interfaces/PlaybackController.d.ts @@ -0,0 +1,57 @@ +import type { Declared } from "../types.js"; +declare const OPERATIONS: readonly ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"]; +type Operation = (typeof OPERATIONS)[number]; +interface Options { + supportedOperations?: Operation[]; +} +/** + * Play, pause and the other buttons of a player. The interface reports nothing: what plays is the playbackState of + * Alexa.PlaybackStateReporter, which a Response to these directives has in its context. Errors of a video device go + * under Alexa.Video, the others under Alexa. + */ +export declare const PlaybackController: import("../types.js").InterfaceDescriptor<{}, { + Play: { + name: "Play"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Pause: { + name: "Pause"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Stop: { + name: "Stop"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Next: { + name: "Next"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Previous: { + name: "Previous"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + FastForward: { + name: "FastForward"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Rewind: { + name: "Rewind"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + StartOver: { + name: "StartOver"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; +}, import("../schema.js").InferShape<{ + /** Default: all eight. */ + supportedOperations: import("../schema.js").OptionalSchema<("Play" | "Pause" | "Stop" | "Next" | "Previous" | "FastForward" | "Rewind" | "StartOver")[]>; +}>, false>; +export {}; diff --git a/dist/esm/registry/interfaces/PlaybackController.js b/dist/esm/registry/interfaces/PlaybackController.js new file mode 100644 index 0000000..495f6b5 --- /dev/null +++ b/dist/esm/registry/interfaces/PlaybackController.js @@ -0,0 +1,43 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +// In the order of the discovery example +const OPERATIONS = ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"]; +// Alexa sends the operations the capability lists +const operation = (name) => ({ + name, + payload: s.object({}), + when: ({ options }) => (options.supportedOperations ?? OPERATIONS).includes(name), +}); +/** + * Play, pause and the other buttons of a player. The interface reports nothing: what plays is the playbackState of + * Alexa.PlaybackStateReporter, which a Response to these directives has in its context. Errors of a video device go + * under Alexa.Video, the others under Alexa. + */ +export const PlaybackController = defineInterface({ + namespace: "Alexa.PlaybackController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + Play: operation("Play"), + Pause: operation("Pause"), + Stop: operation("Stop"), + Next: operation("Next"), + Previous: operation("Previous"), + FastForward: operation("FastForward"), + Rewind: operation("Rewind"), + StartOver: operation("StartOver"), + }, + options: s.object({ + /** Default: all eight. */ + supportedOperations: s.optional(s.array(s.enum(...OPERATIONS), { min: 1 })), + }, { unknownKeys: "reject" }), + // The example has a properties object without fields, which topLevel puts where properties: false left none + discovery: ({ options: { supportedOperations = [...OPERATIONS] } }) => ({ + properties: false, + topLevel: { properties: {}, supportedOperations }, + }), +}); diff --git a/dist/esm/registry/interfaces/PlaybackStateReporter.d.ts b/dist/esm/registry/interfaces/PlaybackStateReporter.d.ts new file mode 100644 index 0000000..685e10d --- /dev/null +++ b/dist/esm/registry/interfaces/PlaybackStateReporter.d.ts @@ -0,0 +1,9 @@ +/** What a player is doing, for an endpoint with Alexa.PlaybackController. Documented on the page of that interface. */ +export declare const PlaybackStateReporter: import("../types.js").InterfaceDescriptor<{ + playbackState: { + name: string; + value: import("../schema.js").Schema; + }>>; + }; +}, {}, {}, false>; diff --git a/dist/esm/registry/interfaces/PlaybackStateReporter.js b/dist/esm/registry/interfaces/PlaybackStateReporter.js new file mode 100644 index 0000000..02ebca2 --- /dev/null +++ b/dist/esm/registry/interfaces/PlaybackStateReporter.js @@ -0,0 +1,15 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +/** What a player is doing, for an endpoint with Alexa.PlaybackController. Documented on the page of that interface. */ +export const PlaybackStateReporter = defineInterface({ + namespace: "Alexa.PlaybackStateReporter", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "sensor", + tier: 2, + instanced: false, + properties: { + playbackState: { name: "playbackState", value: s.object({ state: s.enum("PLAYING", "PAUSED", "STOPPED") }) }, + }, + directives: {}, +}); diff --git a/dist/esm/registry/interfaces/Speaker.d.ts b/dist/esm/registry/interfaces/Speaker.d.ts new file mode 100644 index 0000000..efd064c --- /dev/null +++ b/dist/esm/registry/interfaces/Speaker.d.ts @@ -0,0 +1,32 @@ +/** A speaker that can be set to a volume from 0 to 100. One that only takes steps is an Alexa.StepSpeaker. */ +export declare const Speaker: import("../types.js").InterfaceDescriptor<{ + volume: { + name: string; + value: import("../schema.js").Schema; + }; + muted: { + name: string; + value: import("../schema.js").Schema; + }; +}, { + SetVolume: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; + AdjustVolume: { + name: string; + payload: import("../schema.js").Schema; + volumeDefault: import("../schema.js").Schema; + }>>; + note: string; + }; + SetMute: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, {}, false>; diff --git a/dist/esm/registry/interfaces/Speaker.js b/dist/esm/registry/interfaces/Speaker.js new file mode 100644 index 0000000..007d962 --- /dev/null +++ b/dist/esm/registry/interfaces/Speaker.js @@ -0,0 +1,24 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +/** A speaker that can be set to a volume from 0 to 100. One that only takes steps is an Alexa.StepSpeaker. */ +export const Speaker = defineInterface({ + namespace: "Alexa.Speaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-speaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + volume: { name: "volume", value: s.number({ min: 0, max: 100, integer: true }) }, + muted: { name: "muted", value: s.boolean() }, + }, + directives: { + SetVolume: { name: "SetVolume", payload: s.object({ volume: s.number({ min: 0, max: 100, integer: true }) }) }, + AdjustVolume: { + name: "AdjustVolume", + payload: s.object({ volume: s.number({ min: -100, max: 100, integer: true }), volumeDefault: s.boolean() }), + note: "volume is the change. volumeDefault is true when the user named no amount", + }, + SetMute: { name: "SetMute", payload: s.object({ mute: s.boolean() }) }, + }, +}); diff --git a/dist/esm/registry/interfaces/StepSpeaker.d.ts b/dist/esm/registry/interfaces/StepSpeaker.d.ts new file mode 100644 index 0000000..455de92 --- /dev/null +++ b/dist/esm/registry/interfaces/StepSpeaker.d.ts @@ -0,0 +1,19 @@ +/** + * A speaker that is turned up and down by steps and does not know its volume. It reports nothing: the capability + * has no properties object in discovery. + */ +export declare const StepSpeaker: import("../types.js").InterfaceDescriptor<{}, { + AdjustVolume: { + name: string; + payload: import("../schema.js").Schema; + }>>; + note: string; + }; + SetMute: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, {}, false>; diff --git a/dist/esm/registry/interfaces/StepSpeaker.js b/dist/esm/registry/interfaces/StepSpeaker.js new file mode 100644 index 0000000..1a5ebcb --- /dev/null +++ b/dist/esm/registry/interfaces/StepSpeaker.js @@ -0,0 +1,24 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +/** + * A speaker that is turned up and down by steps and does not know its volume. It reports nothing: the capability + * has no properties object in discovery. + */ +export const StepSpeaker = defineInterface({ + namespace: "Alexa.StepSpeaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-stepspeaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + AdjustVolume: { + name: "AdjustVolume", + payload: s.object({ volumeSteps: s.number({ min: -100, max: 100, integer: true }) }), + note: "above 0 louder, below 0 quieter", + }, + SetMute: { name: "SetMute", payload: s.object({ mute: s.boolean() }) }, + }, + discovery: () => ({ properties: false }), +}); diff --git a/dist/esm/registry/interfaces/stubs.js b/dist/esm/registry/interfaces/stubs.js index 07029a9..6024766 100644 --- a/dist/esm/registry/interfaces/stubs.js +++ b/dist/esm/registry/interfaces/stubs.js @@ -1,7 +1,7 @@ // Interfaces without a descriptor of their own. A stub names the interface with the version and the properties // alex2node 1.5.2 put in discovery, so an endpoint that declares one is announced as before. Nothing about it is // checked, and the version is the one 1.5.2 sent, which is not always the one on the page of the interface -// (Alexa.Speaker is "3" there). A row leaves this table when a descriptor is written from that page. +// (Alexa.Cooking is "3" there). A row leaves this table when a descriptor is written from that page. import { s } from "../schema.js"; const DEVICE_APIS = "https://developer.amazon.com/docs/alexaplus/device-apis"; const LIST_OF_INTERFACES = `${DEVICE_APIS}/list-of-interfaces.html`; @@ -17,7 +17,6 @@ const TABLE = [ // 1.5.2 announced the version "UNKNOWN"; 1.7 is what the list of interfaces gives ["Alexa.Camera.LiveViewController", "1.7", [], LIST_OF_INTERFACES], ["Alexa.CameraStreamController", "3", [], "alexa-camerastreamcontroller.html"], - ["Alexa.ChannelController", "3", ["channel"], "alexa-channelcontroller.html"], ["Alexa.Commissionable", "1", [], "alexa-commissionable.html"], ["Alexa.ConsentManagement.ConsentRequiredReporter", "1", [], "alexa-consentrequiredreporter.html"], ["Alexa.Cooking", "1", [], "alexa-cooking.html"], @@ -31,8 +30,6 @@ const TABLE = [ ["Alexa.DeviceUsage.Estimation", "1", [], "alexa-deviceusage-estimation.html"], ["Alexa.DeviceUsage.Meter", "1", [], "alexa-deviceusage-meter.html"], ["Alexa.DoorbellEventSource", "3", [], "alexa-doorbelleventsource.html"], - ["Alexa.EqualizerController", "1", [], "alexa-equalizercontroller.html"], - ["Alexa.InputController", "3", [], "alexa-inputcontroller.html"], ["Alexa.InventoryLevelSensor", "1", [], "alexa-inventorylevelsensor.html"], ["Alexa.InventoryLevelUsageSensor", "1", [], "alexa-inventorylevelusagesensor.html"], ["Alexa.InventoryUsageSensor", "1", [], "alexa-inventoryusagesensor.html"], @@ -41,8 +38,6 @@ const TABLE = [ ["Alexa.Media.PlayQueue", "1", [], "alexa-media-playqueue.html"], ["Alexa.Media.Playback", "1", [], "alexa-media-playback.html"], ["Alexa.Media.Search", "1", [], "alexa-media-search.html"], - ["Alexa.PlaybackController", "3", [], "alexa-playbackcontroller.html"], - ["Alexa.PlaybackStateReporter", "1", [], "alexa-playbackcontroller.html"], ["Alexa.ProactiveNotificationSource", "1", [], "alexa-proactivenotificationsource.html"], ["Alexa.RTCSessionController", "1", [], "alexa-rtcsessioncontroller.html"], ["Alexa.RecordController", "3", [], "alexa-recordcontroller.html"], @@ -53,8 +48,6 @@ const TABLE = [ ["Alexa.SimpleEventSource", "1", [], "alexa-simpleeventsource.html"], ["Alexa.SmartVision.ObjectDetectionSensor", "1", [], "alexa-smartvision-objectdetectionsensor.html"], ["Alexa.SmartVision.SnapshotProvider", "1", [], "alexa-smartvision-snapshotprovider.html"], - ["Alexa.Speaker", "1", [], "alexa-speaker.html"], - ["Alexa.StepSpeaker", "1", [], "alexa-stepspeaker.html"], ["Alexa.ThermostatController.Configuration", "1", [], "alexa-thermostatcontroller-configuration.html"], ["Alexa.ThermostatController.HVAC.Components", "1", [], "alexa-thermostatcontroller-hvac-components.html"], // "UNKNOWN" in 1.5.2 as well; the page is titled "Interface 3" diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts index 719331e..6caa0e7 100644 --- a/dist/types/index.d.ts +++ b/dist/types/index.d.ts @@ -5,11 +5,11 @@ export type { EndpointDefinition, EndpointJson } from "./device/Device.js"; export { Capability } from "./device/Capability.js"; export type { CapabilityJson, CommonOptions, Declaration } from "./device/Capability.js"; export { registry, DeclarationError, SchemaError } from "./registry/index.js"; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; export { PowerController, EndpointHealth } from "./compat/enums.js"; export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js"; -export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; -export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js"; +export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; +export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, InputName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js"; export * as messages from "./messages/index.js"; export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js"; export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js"; diff --git a/dist/types/registry/index.d.ts b/dist/types/registry/index.d.ts index aff5619..e1db8d6 100644 --- a/dist/types/registry/index.d.ts +++ b/dist/types/registry/index.d.ts @@ -1,18 +1,25 @@ import { Alexa } from "./interfaces/Alexa.js"; import { BrightnessController } from "./interfaces/BrightnessController.js"; +import { ChannelController } from "./interfaces/ChannelController.js"; import { ColorController } from "./interfaces/ColorController.js"; import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js"; import { ContactSensor } from "./interfaces/ContactSensor.js"; import { EndpointHealth } from "./interfaces/EndpointHealth.js"; +import { EqualizerController } from "./interfaces/EqualizerController.js"; import { HumiditySensor } from "./interfaces/HumiditySensor.js"; +import { InputController } from "./interfaces/InputController.js"; import { LockController } from "./interfaces/LockController.js"; import { ModeController } from "./interfaces/ModeController.js"; import { MotionSensor } from "./interfaces/MotionSensor.js"; import { PercentageController } from "./interfaces/PercentageController.js"; +import { PlaybackController } from "./interfaces/PlaybackController.js"; +import { PlaybackStateReporter } from "./interfaces/PlaybackStateReporter.js"; import { PowerController } from "./interfaces/PowerController.js"; import { PowerLevelController } from "./interfaces/PowerLevelController.js"; import { RangeController } from "./interfaces/RangeController.js"; import { SecurityPanelController } from "./interfaces/SecurityPanelController.js"; +import { Speaker } from "./interfaces/Speaker.js"; +import { StepSpeaker } from "./interfaces/StepSpeaker.js"; import { TemperatureSensor } from "./interfaces/TemperatureSensor.js"; import { ThermostatController } from "./interfaces/ThermostatController.js"; import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js"; @@ -26,7 +33,9 @@ export declare const registry: { /** Every descriptor, ordered by namespace. */ list(): AnyDescriptor[]; }; -export { Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, PercentageController, PlaybackController, PlaybackStateReporter, PowerController, PowerLevelController, RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, }; +export { INPUTS } from "./interfaces/InputController.js"; +export type { InputName } from "./interfaces/InputController.js"; export type { Mode } from "./interfaces/ModeController.js"; export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js"; export type { ThermostatModeName } from "./interfaces/ThermostatController.js"; diff --git a/dist/types/registry/interfaces/ChannelController.d.ts b/dist/types/registry/interfaces/ChannelController.d.ts new file mode 100644 index 0000000..a331cef --- /dev/null +++ b/dist/types/registry/interfaces/ChannelController.d.ts @@ -0,0 +1,41 @@ +/** + * The channel of a TV. ChangeChannel names the channel by one or more of number, callSign, affiliateCallSign and + * uri, or by channelMetadata.name alone. The lineup of a TV provider is not described: the page folds the discovery + * example that has one. + */ +export declare const ChannelController: import("../types.js").InterfaceDescriptor<{ + channel: { + name: string; + value: import("../schema.js").Schema; + callSign: import("../schema.js").OptionalSchema; + affiliateCallSign: import("../schema.js").OptionalSchema; + uri: import("../schema.js").OptionalSchema; + }>>; + }; +}, { + ChangeChannel: { + name: string; + payload: import("../schema.js").Schema; + callSign: import("../schema.js").OptionalSchema; + affiliateCallSign: import("../schema.js").OptionalSchema; + uri: import("../schema.js").OptionalSchema; + }>>; + channelMetadata: import("../schema.js").OptionalSchema; + image: import("../schema.js").OptionalSchema; + }>>; + }>>; + }; + SkipChannels: { + name: string; + payload: import("../schema.js").Schema; + }>>; + note: string; + }; +}, {}, false>; diff --git a/dist/types/registry/interfaces/EqualizerController.d.ts b/dist/types/registry/interfaces/EqualizerController.d.ts new file mode 100644 index 0000000..be87632 --- /dev/null +++ b/dist/types/registry/interfaces/EqualizerController.d.ts @@ -0,0 +1,63 @@ +/** + * The bands of an equalizer, its modes, or both. Discovery lists bands for a device declared with bands and mode + * for one declared with modes. A band or a mode the device does not have is answered with INVALID_VALUE. + */ +export declare const EqualizerController: import("../types.js").InterfaceDescriptor<{ + bands: { + name: string; + value: import("../schema.js").Schema; + value: import("../schema.js").Schema; + }>[]>; + }; + mode: { + name: string; + value: import("../schema.js").EnumSchema<"TV" | "MOVIE" | "MUSIC" | "NIGHT" | "SPORT">; + }; +}, { + SetMode: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; + SetBands: { + name: string; + payload: import("../schema.js").Schema; + value: import("../schema.js").Schema; + }>[]>; + }>>; + }; + AdjustBands: { + name: string; + payload: import("../schema.js").Schema; + levelDelta: import("../schema.js").OptionalSchema; + levelDirection: import("../schema.js").EnumSchema<"UP" | "DOWN">; + }>[]>; + }>>; + note: string; + }; + ResetBands: { + name: string; + payload: import("../schema.js").Schema; + }>[]>; + }>>; + }; +}, import("../schema.js").InferShape<{ + /** The bands of the device and the levels they take. Left out for a device that has modes only. */ + bands: import("../schema.js").OptionalSchema; + range: import("../schema.js").Schema; + maximum: import("../schema.js").Schema; + }>>; + }>>; + /** Left out for a device that has bands only. */ + modes: import("../schema.js").OptionalSchema<("TV" | "MOVIE" | "MUSIC" | "NIGHT" | "SPORT")[]>; +}>, false>; diff --git a/dist/types/registry/interfaces/InputController.d.ts b/dist/types/registry/interfaces/InputController.d.ts new file mode 100644 index 0000000..ab84056 --- /dev/null +++ b/dist/types/registry/interfaces/InputController.d.ts @@ -0,0 +1,26 @@ +/** alexa-inputcontroller.html, "Input property values". */ +export declare const INPUTS: readonly ["AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX"]; +export type InputName = (typeof INPUTS)[number]; +/** + * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery + * example of the page has them; its table calls them a configuration object. + */ +export declare const InputController: import("../types.js").InterfaceDescriptor<{ + input: { + name: string; + value: import("../schema.js").EnumSchema<"TV" | "AUX 1" | "AUX 2" | "AUX 3" | "AUX 4" | "AUX 5" | "AUX 6" | "AUX 7" | "BLURAY" | "CABLE" | "CD" | "COAX 1" | "COAX 2" | "COMPOSITE 1" | "DVD" | "GAME" | "HD RADIO" | "HDMI 1" | "HDMI 2" | "HDMI 3" | "HDMI 4" | "HDMI 5" | "HDMI 6" | "HDMI 7" | "HDMI 8" | "HDMI 9" | "HDMI 10" | "HDMI ARC" | "INPUT 1" | "INPUT 2" | "INPUT 3" | "INPUT 4" | "INPUT 5" | "INPUT 6" | "INPUT 7" | "INPUT 8" | "INPUT 9" | "INPUT 10" | "IPOD" | "LINE 1" | "LINE 2" | "LINE 3" | "LINE 4" | "LINE 5" | "LINE 6" | "LINE 7" | "MEDIA PLAYER" | "OPTICAL 1" | "OPTICAL 2" | "PHONO" | "PLAYSTATION" | "PLAYSTATION 3" | "PLAYSTATION 4" | "SATELLITE" | "SMARTCAST" | "TUNER" | "USB DAC" | "VIDEO 1" | "VIDEO 2" | "VIDEO 3" | "XBOX">; + }; +}, { + SelectInput: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, import("../schema.js").InferShape<{ + /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ + inputs: import("../schema.js").Schema; + friendlyNames: import("../schema.js").OptionalSchema; + }>[]>; +}>, false>; diff --git a/dist/types/registry/interfaces/PlaybackController.d.ts b/dist/types/registry/interfaces/PlaybackController.d.ts new file mode 100644 index 0000000..da29884 --- /dev/null +++ b/dist/types/registry/interfaces/PlaybackController.d.ts @@ -0,0 +1,57 @@ +import type { Declared } from "../types.js"; +declare const OPERATIONS: readonly ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"]; +type Operation = (typeof OPERATIONS)[number]; +interface Options { + supportedOperations?: Operation[]; +} +/** + * Play, pause and the other buttons of a player. The interface reports nothing: what plays is the playbackState of + * Alexa.PlaybackStateReporter, which a Response to these directives has in its context. Errors of a video device go + * under Alexa.Video, the others under Alexa. + */ +export declare const PlaybackController: import("../types.js").InterfaceDescriptor<{}, { + Play: { + name: "Play"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Pause: { + name: "Pause"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Stop: { + name: "Stop"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Next: { + name: "Next"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Previous: { + name: "Previous"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + FastForward: { + name: "FastForward"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + Rewind: { + name: "Rewind"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; + StartOver: { + name: "StartOver"; + payload: import("../schema.js").Schema>; + when: ({ options }: Declared) => boolean; + }; +}, import("../schema.js").InferShape<{ + /** Default: all eight. */ + supportedOperations: import("../schema.js").OptionalSchema<("Play" | "Pause" | "Stop" | "Next" | "Previous" | "FastForward" | "Rewind" | "StartOver")[]>; +}>, false>; +export {}; diff --git a/dist/types/registry/interfaces/PlaybackStateReporter.d.ts b/dist/types/registry/interfaces/PlaybackStateReporter.d.ts new file mode 100644 index 0000000..685e10d --- /dev/null +++ b/dist/types/registry/interfaces/PlaybackStateReporter.d.ts @@ -0,0 +1,9 @@ +/** What a player is doing, for an endpoint with Alexa.PlaybackController. Documented on the page of that interface. */ +export declare const PlaybackStateReporter: import("../types.js").InterfaceDescriptor<{ + playbackState: { + name: string; + value: import("../schema.js").Schema; + }>>; + }; +}, {}, {}, false>; diff --git a/dist/types/registry/interfaces/Speaker.d.ts b/dist/types/registry/interfaces/Speaker.d.ts new file mode 100644 index 0000000..efd064c --- /dev/null +++ b/dist/types/registry/interfaces/Speaker.d.ts @@ -0,0 +1,32 @@ +/** A speaker that can be set to a volume from 0 to 100. One that only takes steps is an Alexa.StepSpeaker. */ +export declare const Speaker: import("../types.js").InterfaceDescriptor<{ + volume: { + name: string; + value: import("../schema.js").Schema; + }; + muted: { + name: string; + value: import("../schema.js").Schema; + }; +}, { + SetVolume: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; + AdjustVolume: { + name: string; + payload: import("../schema.js").Schema; + volumeDefault: import("../schema.js").Schema; + }>>; + note: string; + }; + SetMute: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, {}, false>; diff --git a/dist/types/registry/interfaces/StepSpeaker.d.ts b/dist/types/registry/interfaces/StepSpeaker.d.ts new file mode 100644 index 0000000..455de92 --- /dev/null +++ b/dist/types/registry/interfaces/StepSpeaker.d.ts @@ -0,0 +1,19 @@ +/** + * A speaker that is turned up and down by steps and does not know its volume. It reports nothing: the capability + * has no properties object in discovery. + */ +export declare const StepSpeaker: import("../types.js").InterfaceDescriptor<{}, { + AdjustVolume: { + name: string; + payload: import("../schema.js").Schema; + }>>; + note: string; + }; + SetMute: { + name: string; + payload: import("../schema.js").Schema; + }>>; + }; +}, {}, false>; diff --git a/src/index.ts b/src/index.ts index acec3d7..517269b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,9 +9,11 @@ export type { CapabilityJson, CommonOptions, Declaration } from "./device/Capabi // The interfaces, for device.add(), and the registry that holds them by name export { registry, DeclarationError, SchemaError } from "./registry/index.js"; export { - Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, HumiditySensor, LockController, - ModeController, MotionSensor, PercentageController, PowerLevelController, RangeController, SecurityPanelController, - TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, + Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, + EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, + PercentageController, PlaybackController, PlaybackStateReporter, PowerLevelController, RangeController, + SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, + ThermostatControllerSchedule, ToggleController, } from "./registry/index.js"; export { PowerController, EndpointHealth } from "./compat/enums.js"; export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js"; @@ -19,13 +21,13 @@ export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js"; // The vocabularies of the Smart Home API export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, - DISPLAY_CATEGORIES as DisplayCategories, THERMOSTAT_MODES as ThermostatModes, + DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js"; export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, - ActionName, StateName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, + ActionName, StateName, InputName, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js"; // The messages: what the bridge publishes, built from plain values diff --git a/src/registry/index.ts b/src/registry/index.ts index f172525..70cb66c 100644 --- a/src/registry/index.ts +++ b/src/registry/index.ts @@ -1,19 +1,26 @@ // The interfaces the library knows, by namespace. import { Alexa } from "./interfaces/Alexa.js"; import { BrightnessController } from "./interfaces/BrightnessController.js"; +import { ChannelController } from "./interfaces/ChannelController.js"; import { ColorController } from "./interfaces/ColorController.js"; import { ColorTemperatureController } from "./interfaces/ColorTemperatureController.js"; import { ContactSensor } from "./interfaces/ContactSensor.js"; import { EndpointHealth } from "./interfaces/EndpointHealth.js"; +import { EqualizerController } from "./interfaces/EqualizerController.js"; import { HumiditySensor } from "./interfaces/HumiditySensor.js"; +import { InputController } from "./interfaces/InputController.js"; import { LockController } from "./interfaces/LockController.js"; import { ModeController } from "./interfaces/ModeController.js"; import { MotionSensor } from "./interfaces/MotionSensor.js"; import { PercentageController } from "./interfaces/PercentageController.js"; +import { PlaybackController } from "./interfaces/PlaybackController.js"; +import { PlaybackStateReporter } from "./interfaces/PlaybackStateReporter.js"; import { PowerController } from "./interfaces/PowerController.js"; import { PowerLevelController } from "./interfaces/PowerLevelController.js"; import { RangeController } from "./interfaces/RangeController.js"; import { SecurityPanelController } from "./interfaces/SecurityPanelController.js"; +import { Speaker } from "./interfaces/Speaker.js"; +import { StepSpeaker } from "./interfaces/StepSpeaker.js"; import { TemperatureSensor } from "./interfaces/TemperatureSensor.js"; import { ThermostatController } from "./interfaces/ThermostatController.js"; import { ThermostatControllerSchedule } from "./interfaces/ThermostatControllerSchedule.js"; @@ -25,19 +32,26 @@ import type { AnyDescriptor } from "./types.js"; const described: readonly AnyDescriptor[] = [ Alexa, BrightnessController, + ChannelController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, + EqualizerController, HumiditySensor, + InputController, LockController, ModeController, MotionSensor, PercentageController, + PlaybackController, + PlaybackStateReporter, PowerController, PowerLevelController, RangeController, SecurityPanelController, + Speaker, + StepSpeaker, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, @@ -71,10 +85,14 @@ export const registry = { }; export { - Alexa, BrightnessController, ColorController, ColorTemperatureController, ContactSensor, EndpointHealth, HumiditySensor, - LockController, ModeController, MotionSensor, PercentageController, PowerController, PowerLevelController, RangeController, - SecurityPanelController, TemperatureSensor, ThermostatController, ThermostatControllerSchedule, ToggleController, + Alexa, BrightnessController, ChannelController, ColorController, ColorTemperatureController, ContactSensor, + EndpointHealth, EqualizerController, HumiditySensor, InputController, LockController, ModeController, MotionSensor, + PercentageController, PlaybackController, PlaybackStateReporter, PowerController, PowerLevelController, + RangeController, SecurityPanelController, Speaker, StepSpeaker, TemperatureSensor, ThermostatController, + ThermostatControllerSchedule, ToggleController, }; +export { INPUTS } from "./interfaces/InputController.js"; +export type { InputName } from "./interfaces/InputController.js"; export type { Mode } from "./interfaces/ModeController.js"; export { THERMOSTAT_MODES } from "./interfaces/ThermostatController.js"; export type { ThermostatModeName } from "./interfaces/ThermostatController.js"; diff --git a/src/registry/interfaces/ChannelController.ts b/src/registry/interfaces/ChannelController.ts new file mode 100644 index 0000000..9175eb9 --- /dev/null +++ b/src/registry/interfaces/ChannelController.ts @@ -0,0 +1,42 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; + +// None of the fields is required, a channel has one of them at least +const channel = s.object({ + /** "256", "13.1" */ + number: s.optional(s.string()), + callSign: s.optional(s.string()), + affiliateCallSign: s.optional(s.string()), + uri: s.optional(s.string()), +}); + +/** + * The channel of a TV. ChangeChannel names the channel by one or more of number, callSign, affiliateCallSign and + * uri, or by channelMetadata.name alone. The lineup of a TV provider is not described: the page folds the discovery + * example that has one. + */ +export const ChannelController = defineInterface({ + namespace: "Alexa.ChannelController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-channelcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + channel: { name: "channel", value: channel }, + }, + directives: { + ChangeChannel: { + name: "ChangeChannel", + payload: s.object({ + channel: s.optional(channel), + channelMetadata: s.optional(s.object({ name: s.optional(s.string()), image: s.optional(s.string()) })), + }), + }, + SkipChannels: { + name: "SkipChannels", + payload: s.object({ channelCount: s.number({ integer: true }) }), + note: "above 0 up, below 0 down", + }, + }, +}); diff --git a/src/registry/interfaces/EqualizerController.ts b/src/registry/interfaces/EqualizerController.ts new file mode 100644 index 0000000..571366a --- /dev/null +++ b/src/registry/interfaces/EqualizerController.ts @@ -0,0 +1,69 @@ +import { s } from "../schema.js"; +import { DeclarationError, defineInterface } from "../types.js"; + +const BANDS = ["BASS", "MIDRANGE", "TREBLE"] as const; +const MODES = ["MOVIE", "MUSIC", "NIGHT", "SPORT", "TV"] as const; + +const band = s.enum(...BANDS); +const level = s.number({ integer: true }); + +/** + * The bands of an equalizer, its modes, or both. Discovery lists bands for a device declared with bands and mode + * for one declared with modes. A band or a mode the device does not have is answered with INVALID_VALUE. + */ +export const EqualizerController = defineInterface({ + namespace: "Alexa.EqualizerController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-equalizercontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + bands: { name: "bands", value: s.array(s.object({ name: band, value: level })) }, + mode: { name: "mode", value: s.enum(...MODES) }, + }, + directives: { + SetMode: { name: "SetMode", payload: s.object({ mode: s.enum(...MODES) }) }, + SetBands: { name: "SetBands", payload: s.object({ bands: s.array(s.object({ name: band, value: level }), { min: 1 }) }) }, + AdjustBands: { + name: "AdjustBands", + payload: s.object({ + bands: s.array(s.object({ name: band, levelDelta: s.optional(level), levelDirection: s.enum("UP", "DOWN") }), { min: 1 }), + }), + note: "without levelDelta the band moves by the step the device has for it", + }, + ResetBands: { name: "ResetBands", payload: s.object({ bands: s.array(s.object({ name: band }), { min: 1 }) }) }, + }, + options: s.object({ + /** The bands of the device and the levels they take. Left out for a device that has modes only. */ + bands: s.optional(s.object({ + supported: s.array(band, { min: 1 }), + range: s.object({ minimum: level, maximum: level }, { unknownKeys: "reject" }), + }, { unknownKeys: "reject" })), + /** Left out for a device that has bands only. */ + modes: s.optional(s.array(s.enum(...MODES), { min: 1 })), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has neither; check() says so, discovery lists both properties + discovery({ options: { bands, modes } }) { + if (!bands && !modes) return {}; + return { + supported: [...(bands ? ["bands"] : []), ...(modes ? ["mode"] : [])], + configurations: { + ...(bands && { bands: { supported: bands.supported.map((name) => ({ name })), range: bands.range } }), + ...(modes && { modes: { supported: modes.map((name) => ({ name })) } }), + }, + }; + }, + validate(capability) { + const { bands, modes = [] } = capability.options; + if (!bands && modes.length === 0) throw new DeclarationError(capability, "needs bands, modes or both: declare what the equalizer has"); + if (bands && bands.range.maximum <= bands.range.minimum) { + throw new DeclarationError(capability, `bands.range.maximum ${bands.range.maximum} is not above bands.range.minimum ${bands.range.minimum}`); + } + const lists: ReadonlyArray = [bands?.supported ?? [], modes]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) throw new DeclarationError(capability, `${twice} is listed twice`); + } + }, +}); diff --git a/src/registry/interfaces/InputController.ts b/src/registry/interfaces/InputController.ts new file mode 100644 index 0000000..5d7d6ce --- /dev/null +++ b/src/registry/interfaces/InputController.ts @@ -0,0 +1,49 @@ +import { s } from "../schema.js"; +import { DeclarationError, defineInterface } from "../types.js"; + +/** alexa-inputcontroller.html, "Input property values". */ +export const INPUTS = [ + "AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", + "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", + "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", + "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", + "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", + "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX", +] as const; +export type InputName = (typeof INPUTS)[number]; + +const input = s.oneOf(INPUTS, "an input like HDMI 1"); + +/** + * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery + * example of the page has them; its table calls them a configuration object. + */ +export const InputController = defineInterface({ + namespace: "Alexa.InputController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-inputcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + input: { name: "input", value: input }, + }, + directives: { + SelectInput: { name: "SelectInput", payload: s.object({ input }) }, + }, + options: s.object({ + /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ + inputs: s.array(s.object({ name: input, friendlyNames: s.optional(s.array(s.string({ min: 1 }))) }, { unknownKeys: "reject" }), { min: 1 }), + }, { unknownKeys: "reject" }), + // A capability declared the 1.x way has no inputs; check() says so + discovery: ({ options: { inputs } }) => (inputs ? { topLevel: { inputs } } : {}), + validate(capability) { + const names = capability.options.inputs.map(({ name }) => name); + const called = capability.options.inputs.flatMap(({ friendlyNames = [] }) => friendlyNames); + const lists: ReadonlyArray = [names, called]; + for (const list of lists) { + const twice = list.find((entry, i) => list.indexOf(entry) !== i); + if (twice) throw new DeclarationError(capability, `${twice} is listed twice, a name stands for one input`); + } + }, +}); diff --git a/src/registry/interfaces/PlaybackController.ts b/src/registry/interfaces/PlaybackController.ts new file mode 100644 index 0000000..03530a7 --- /dev/null +++ b/src/registry/interfaces/PlaybackController.ts @@ -0,0 +1,52 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; +import type { Declared } from "../types.js"; + +// In the order of the discovery example +const OPERATIONS = ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"] as const; +type Operation = (typeof OPERATIONS)[number]; + +interface Options { + supportedOperations?: Operation[]; +} + +// Alexa sends the operations the capability lists +const operation = (name: N) => ({ + name, + payload: s.object({}), + when: ({ options }: Declared) => (options.supportedOperations ?? OPERATIONS).includes(name), +}); + +/** + * Play, pause and the other buttons of a player. The interface reports nothing: what plays is the playbackState of + * Alexa.PlaybackStateReporter, which a Response to these directives has in its context. Errors of a video device go + * under Alexa.Video, the others under Alexa. + */ +export const PlaybackController = defineInterface({ + namespace: "Alexa.PlaybackController", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + Play: operation("Play"), + Pause: operation("Pause"), + Stop: operation("Stop"), + Next: operation("Next"), + Previous: operation("Previous"), + FastForward: operation("FastForward"), + Rewind: operation("Rewind"), + StartOver: operation("StartOver"), + }, + options: s.object({ + /** Default: all eight. */ + supportedOperations: s.optional(s.array(s.enum(...OPERATIONS), { min: 1 })), + }, { unknownKeys: "reject" }), + // The example has a properties object without fields, which topLevel puts where properties: false left none + discovery: ({ options: { supportedOperations = [...OPERATIONS] } }) => ({ + properties: false, + topLevel: { properties: {}, supportedOperations }, + }), +}); diff --git a/src/registry/interfaces/PlaybackStateReporter.ts b/src/registry/interfaces/PlaybackStateReporter.ts new file mode 100644 index 0000000..b3e53ef --- /dev/null +++ b/src/registry/interfaces/PlaybackStateReporter.ts @@ -0,0 +1,16 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; + +/** What a player is doing, for an endpoint with Alexa.PlaybackController. Documented on the page of that interface. */ +export const PlaybackStateReporter = defineInterface({ + namespace: "Alexa.PlaybackStateReporter", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-playbackcontroller.html", + kind: "sensor", + tier: 2, + instanced: false, + properties: { + playbackState: { name: "playbackState", value: s.object({ state: s.enum("PLAYING", "PAUSED", "STOPPED") }) }, + }, + directives: {}, +}); diff --git a/src/registry/interfaces/Speaker.ts b/src/registry/interfaces/Speaker.ts new file mode 100644 index 0000000..85703ce --- /dev/null +++ b/src/registry/interfaces/Speaker.ts @@ -0,0 +1,25 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; + +/** A speaker that can be set to a volume from 0 to 100. One that only takes steps is an Alexa.StepSpeaker. */ +export const Speaker = defineInterface({ + namespace: "Alexa.Speaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-speaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: { + volume: { name: "volume", value: s.number({ min: 0, max: 100, integer: true }) }, + muted: { name: "muted", value: s.boolean() }, + }, + directives: { + SetVolume: { name: "SetVolume", payload: s.object({ volume: s.number({ min: 0, max: 100, integer: true }) }) }, + AdjustVolume: { + name: "AdjustVolume", + payload: s.object({ volume: s.number({ min: -100, max: 100, integer: true }), volumeDefault: s.boolean() }), + note: "volume is the change. volumeDefault is true when the user named no amount", + }, + SetMute: { name: "SetMute", payload: s.object({ mute: s.boolean() }) }, + }, +}); diff --git a/src/registry/interfaces/StepSpeaker.ts b/src/registry/interfaces/StepSpeaker.ts new file mode 100644 index 0000000..8610dd9 --- /dev/null +++ b/src/registry/interfaces/StepSpeaker.ts @@ -0,0 +1,25 @@ +import { s } from "../schema.js"; +import { defineInterface } from "../types.js"; + +/** + * A speaker that is turned up and down by steps and does not know its volume. It reports nothing: the capability + * has no properties object in discovery. + */ +export const StepSpeaker = defineInterface({ + namespace: "Alexa.StepSpeaker", + version: "3", + doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-stepspeaker.html", + kind: "controller", + tier: 2, + instanced: false, + properties: {}, + directives: { + AdjustVolume: { + name: "AdjustVolume", + payload: s.object({ volumeSteps: s.number({ min: -100, max: 100, integer: true }) }), + note: "above 0 louder, below 0 quieter", + }, + SetMute: { name: "SetMute", payload: s.object({ mute: s.boolean() }) }, + }, + discovery: () => ({ properties: false }), +}); diff --git a/src/registry/interfaces/stubs.ts b/src/registry/interfaces/stubs.ts index be9fb66..9db1323 100644 --- a/src/registry/interfaces/stubs.ts +++ b/src/registry/interfaces/stubs.ts @@ -1,7 +1,7 @@ // Interfaces without a descriptor of their own. A stub names the interface with the version and the properties // alex2node 1.5.2 put in discovery, so an endpoint that declares one is announced as before. Nothing about it is // checked, and the version is the one 1.5.2 sent, which is not always the one on the page of the interface -// (Alexa.Speaker is "3" there). A row leaves this table when a descriptor is written from that page. +// (Alexa.Cooking is "3" there). A row leaves this table when a descriptor is written from that page. import { s } from "../schema.js"; import type { AnyDescriptor } from "../types.js"; @@ -23,7 +23,6 @@ const TABLE: readonly Row[] = [ // 1.5.2 announced the version "UNKNOWN"; 1.7 is what the list of interfaces gives ["Alexa.Camera.LiveViewController", "1.7", [], LIST_OF_INTERFACES], ["Alexa.CameraStreamController", "3", [], "alexa-camerastreamcontroller.html"], - ["Alexa.ChannelController", "3", ["channel"], "alexa-channelcontroller.html"], ["Alexa.Commissionable", "1", [], "alexa-commissionable.html"], ["Alexa.ConsentManagement.ConsentRequiredReporter", "1", [], "alexa-consentrequiredreporter.html"], ["Alexa.Cooking", "1", [], "alexa-cooking.html"], @@ -37,8 +36,6 @@ const TABLE: readonly Row[] = [ ["Alexa.DeviceUsage.Estimation", "1", [], "alexa-deviceusage-estimation.html"], ["Alexa.DeviceUsage.Meter", "1", [], "alexa-deviceusage-meter.html"], ["Alexa.DoorbellEventSource", "3", [], "alexa-doorbelleventsource.html"], - ["Alexa.EqualizerController", "1", [], "alexa-equalizercontroller.html"], - ["Alexa.InputController", "3", [], "alexa-inputcontroller.html"], ["Alexa.InventoryLevelSensor", "1", [], "alexa-inventorylevelsensor.html"], ["Alexa.InventoryLevelUsageSensor", "1", [], "alexa-inventorylevelusagesensor.html"], ["Alexa.InventoryUsageSensor", "1", [], "alexa-inventoryusagesensor.html"], @@ -47,8 +44,6 @@ const TABLE: readonly Row[] = [ ["Alexa.Media.PlayQueue", "1", [], "alexa-media-playqueue.html"], ["Alexa.Media.Playback", "1", [], "alexa-media-playback.html"], ["Alexa.Media.Search", "1", [], "alexa-media-search.html"], - ["Alexa.PlaybackController", "3", [], "alexa-playbackcontroller.html"], - ["Alexa.PlaybackStateReporter", "1", [], "alexa-playbackcontroller.html"], ["Alexa.ProactiveNotificationSource", "1", [], "alexa-proactivenotificationsource.html"], ["Alexa.RTCSessionController", "1", [], "alexa-rtcsessioncontroller.html"], ["Alexa.RecordController", "3", [], "alexa-recordcontroller.html"], @@ -59,8 +54,6 @@ const TABLE: readonly Row[] = [ ["Alexa.SimpleEventSource", "1", [], "alexa-simpleeventsource.html"], ["Alexa.SmartVision.ObjectDetectionSensor", "1", [], "alexa-smartvision-objectdetectionsensor.html"], ["Alexa.SmartVision.SnapshotProvider", "1", [], "alexa-smartvision-snapshotprovider.html"], - ["Alexa.Speaker", "1", [], "alexa-speaker.html"], - ["Alexa.StepSpeaker", "1", [], "alexa-stepspeaker.html"], ["Alexa.ThermostatController.Configuration", "1", [], "alexa-thermostatcontroller-configuration.html"], ["Alexa.ThermostatController.HVAC.Components", "1", [], "alexa-thermostatcontroller-hvac-components.html"], // "UNKNOWN" in 1.5.2 as well; the page is titled "Interface 3" diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.directive.json b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.directive.json new file mode 100644 index 0000000..4499a74 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.directive.json @@ -0,0 +1,31 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.ChannelController", + "name": "ChangeChannel", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "channel": { + "number": "9", + "callSign": "KCTS-TV", + "affiliateCallSign": "KCTS", + "uri": "channel uri" + }, + "channelMetadata": { + "name": "Alternate channel name", + "image": "url for image" + } + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.response.json b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.response.json new file mode 100644 index 0000000..17c796e --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeChannel.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.ChannelController", + "name": "channel", + "value": { + "number": "9", + "callSign": "KCTS-TV", + "affiliateCallSign": "KCTS" + }, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeReport.json b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeReport.json new file mode 100644 index 0000000..8110e3e --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/ChangeReport.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "ChangeReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": { + "change": { + "cause": { + "type": "VOICE_INTERACTION" + }, + "properties": [ + { + "namespace": "Alexa.ChannelController", + "name": "channel", + "value": { + "number": "9", + "callSign": "KCTS-TV", + "affiliateCallSign": "KCTS" + }, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + } + ] + } + } + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2017-02-03T16:15:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.directive.json b/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.directive.json new file mode 100644 index 0000000..0bc77b4 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.directive.json @@ -0,0 +1,14 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.ChannelController", + "name": "SkipChannels", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "payload": { + "channelCount": 1 + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.response.json b/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.response.json new file mode 100644 index 0000000..997379e --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/SkipChannels.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.ChannelController", + "name": "channel", + "value": { + "number": "7", + "callSign": "KIRO-TV", + "affiliateCallSign": "KIRO" + }, + "timeOfSample": "2017-02-03T16:25:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/StateReport.json b/test/fixtures/alexa-docs/alexa-channelcontroller/StateReport.json new file mode 100644 index 0000000..0933a21 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/StateReport.json @@ -0,0 +1,50 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "StateReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.ChannelController", + "name": "channel", + "value": { + "number": "7", + "callSign": "KIRO-TV", + "affiliateCallSign": "KIRO" + }, + "timeOfSample": "2017-02-03T17:00:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2017-02-03T16:15:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/channel.property.json b/test/fixtures/alexa-docs/alexa-channelcontroller/channel.property.json new file mode 100644 index 0000000..06856cb --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/channel.property.json @@ -0,0 +1,8 @@ +{ + "name": "channel", + "value": { + "number": "9", + "callSign": "KCTS-TV", + "affiliateCallSign": "KCTS" + } +} diff --git a/test/fixtures/alexa-docs/alexa-channelcontroller/discovery-addOrUpdateReport.json b/test/fixtures/alexa-docs/alexa-channelcontroller/discovery-addOrUpdateReport.json new file mode 100644 index 0000000..9783e16 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-channelcontroller/discovery-addOrUpdateReport.json @@ -0,0 +1,69 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "AddOrUpdateReport", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "unique ID of the new endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Description to be shown in the Alexa app", + "friendlyName": "Living Room TV", + "displayCategories": [ + "TV" + ], + "additionalAttributes": { + "manufacturer": "Manufacturer of the endpoint", + "model": "Model of the device", + "serialNumber": "Serial number of the device", + "firmwareVersion": "Firmware version of the device", + "softwareVersion": "Software version of the device" + }, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.ChannelController", + "version": "3", + "properties": { + "supported": [ + { + "name": "channel" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa.EndpointHealth", + "version": "3.1", + "properties": { + "supported": [ + { + "name": "connectivity" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ], + "scope": { + "type": "BearerToken", + "token": "access-token-from-Amazon" + } + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.directive.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.directive.json new file mode 100644 index 0000000..e359ad4 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.directive.json @@ -0,0 +1,28 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.EqualizerController", + "name": "AdjustBands", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "bands": [ + { + "name": "BASS", + "levelDelta": 3, + "levelDirection": "UP" + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.response.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.response.json new file mode 100644 index 0000000..19b7a15 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/AdjustBands.response.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "MOVIE", + "timeOfSample": "2017-02-03T16:32:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 1 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/ChangeReport.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/ChangeReport.json new file mode 100644 index 0000000..28c3203 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/ChangeReport.json @@ -0,0 +1,64 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "ChangeReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": { + "change": { + "cause": { + "type": "VOICE_INTERACTION" + }, + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "SPORT", + "timeOfSample": "2017-02-03T18:20:50.52Z", + "uncertaintyInMilliseconds": 0 + } + ] + } + } + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 0 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.directive.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.directive.json new file mode 100644 index 0000000..7848aa1 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.directive.json @@ -0,0 +1,32 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.EqualizerController", + "name": "ResetBands", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "bands": [ + { + "name": "BASS" + }, + { + "name": "MIDRANGE" + }, + { + "name": "TREBLE" + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.response.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.response.json new file mode 100644 index 0000000..dd80f55 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/ResetBands.response.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "MOVIE", + "timeOfSample": "2017-02-03T16:40:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 0 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.directive.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.directive.json new file mode 100644 index 0000000..d4237ee --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.directive.json @@ -0,0 +1,27 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.EqualizerController", + "name": "SetBands", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "bands": [ + { + "name": "BASS", + "value": -2 + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.response.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.response.json new file mode 100644 index 0000000..fb05d18 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetBands.response.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "MOVIE", + "timeOfSample": "2017-02-03T16:25:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": -2 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.directive.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.directive.json new file mode 100644 index 0000000..1d103a8 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.EqualizerController", + "name": "SetMode", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "mode": "MOVIE" + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.response.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.response.json new file mode 100644 index 0000000..951ccec --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/SetMode.response.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "MOVIE", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 0 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:30.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/StateReport.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/StateReport.json new file mode 100644 index 0000000..9100917 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/StateReport.json @@ -0,0 +1,57 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "StateReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EqualizerController", + "name": "mode", + "value": "MOVIE", + "timeOfSample": "2017-02-03T17:50:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EqualizerController", + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 0 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ], + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/bands.property.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/bands.property.json new file mode 100644 index 0000000..e5700e8 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/bands.property.json @@ -0,0 +1,17 @@ +{ + "name": "bands", + "value": [ + { + "name": "BASS", + "value": 0 + }, + { + "name": "MIDRANGE", + "value": 3 + }, + { + "name": "TREBLE", + "value": 1 + } + ] +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/discovery.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/discovery.json new file mode 100644 index 0000000..1199634 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/discovery.json @@ -0,0 +1,94 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "Discover.Response", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Smart Television by Television Maker", + "friendlyName": "Living Room TV", + "displayCategories": [ + "TV" + ], + "cookie": {}, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.EqualizerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "bands" + }, + { + "name": "mode" + } + ], + "retrievable": true, + "proactivelyReported": true + }, + "configurations": { + "bands": { + "supported": [ + { + "name": "BASS" + }, + { + "name": "MIDRANGE" + }, + { + "name": "TREBLE" + } + ], + "range": { + "minimum": -6, + "maximum": 6 + } + }, + "modes": { + "supported": [ + { + "name": "MOVIE" + }, + { + "name": "MUSIC" + }, + { + "name": "SPORT" + } + ] + } + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PowerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "powerState" + } + ], + "retrievable": true, + "proactivelyReported": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-equalizercontroller/mode.property.json b/test/fixtures/alexa-docs/alexa-equalizercontroller/mode.property.json new file mode 100644 index 0000000..014039f --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-equalizercontroller/mode.property.json @@ -0,0 +1,4 @@ +{ + "name": "mode", + "value": "MOVIE" +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/ChangeReport.json b/test/fixtures/alexa-docs/alexa-inputcontroller/ChangeReport.json new file mode 100644 index 0000000..f717f90 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/ChangeReport.json @@ -0,0 +1,53 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "ChangeReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": { + "change": { + "cause": { + "type": "VOICE_INTERACTION" + }, + "properties": [ + { + "namespace": "Alexa.InputController", + "name": "input", + "value": "HDMI 2", + "timeOfSample": "2017-02-03T16:40:50.52Z", + "uncertaintyInMilliseconds": 0 + } + ] + } + } + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2017-02-03T16:15:40.12Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.directive.json b/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.directive.json new file mode 100644 index 0000000..b51729f --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.InputController", + "name": "SelectInput", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "input": "HDMI 1" + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.response.json b/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.response.json new file mode 100644 index 0000000..4f23df3 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/SelectInput.response.json @@ -0,0 +1,42 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.InputController", + "name": "input", + "value": "HDMI 1", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2017-02-03T16:15:40.12Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/StateReport.json b/test/fixtures/alexa-docs/alexa-inputcontroller/StateReport.json new file mode 100644 index 0000000..e833c84 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/StateReport.json @@ -0,0 +1,46 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "StateReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.InputController", + "name": "input", + "value": "HDMI 1", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2017-02-03T16:20:50Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/discovery-addOrUpdateReport.json b/test/fixtures/alexa-docs/alexa-inputcontroller/discovery-addOrUpdateReport.json new file mode 100644 index 0000000..deccac4 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/discovery-addOrUpdateReport.json @@ -0,0 +1,83 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "AddOrUpdateReport", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Smart Television by Television Maker", + "friendlyName": "Living Room TV", + "displayCategories": [ + "TV" + ], + "cookie": {}, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.InputController", + "version": "3", + "properties": { + "supported": [ + { + "name": "input" + } + ], + "proactivelyReported": true, + "retrievable": true + }, + "inputs": [ + { + "name": "HDMI 1", + "friendlyNames": [ + "AnyCompany TV" + ] + }, + { + "name": "HDMI 2", + "friendlyNames": [ + "Cable", + "AnyCompany Cable" + ] + }, + { + "name": "AUX 1", + "friendlyNames": [ + "DVD Player" + ] + }, + { + "name": "AUX 2" + } + ] + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PowerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "powerState" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-inputcontroller/discovery.json b/test/fixtures/alexa-docs/alexa-inputcontroller/discovery.json new file mode 100644 index 0000000..7cecaa2 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-inputcontroller/discovery.json @@ -0,0 +1,88 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "Discover.Response", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer name of the endpoint", + "description": "Smart Television by Television Maker", + "friendlyName": "Living Room TV", + "displayCategories": [ + "TV" + ], + "cookie": {}, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.InputController", + "version": "3", + "properties": { + "supported": [ + { + "name": "input" + } + ], + "proactivelyReported": true, + "retrievable": true + }, + "inputs": [ + { + "name": "HDMI 1", + "friendlyNames": [ + "AnyCompany TV" + ] + }, + { + "name": "HDMI 2", + "friendlyNames": [ + "Cable", + "AnyCompany Cable" + ] + } + ] + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PowerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "powerState" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa.EndpointHealth", + "version": "3.1", + "properties": { + "supported": [ + { + "name": "connectivity" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/ChangeReport.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/ChangeReport.json new file mode 100644 index 0000000..f46229d --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/ChangeReport.json @@ -0,0 +1,48 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "ChangeReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "endpoint id" + }, + "payload": { + "change": { + "cause": { + "type": "PHYSICAL_INTERACTION" + }, + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "STOPPED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 500 + } + ] + } + } + }, + "context": { + "properties": [ + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.directive.json new file mode 100644 index 0000000..10785e5 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "FastForward", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.response.json new file mode 100644 index 0000000..db8c0bb --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/FastForward.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PAUSED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.directive.json new file mode 100644 index 0000000..318df0e --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Next", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.response.json new file mode 100644 index 0000000..77fd3bc --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Next.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "STOPPED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.directive.json new file mode 100644 index 0000000..b4d481c --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Pause", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.response.json new file mode 100644 index 0000000..b0a89c6 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Pause.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PAUSED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.directive.json new file mode 100644 index 0000000..2b39f1e --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Play", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.response.json new file mode 100644 index 0000000..a763bf6 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Play.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PLAYING" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.directive.json new file mode 100644 index 0000000..f0b642b --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Previous", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.response.json new file mode 100644 index 0000000..77fd3bc --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Previous.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "STOPPED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.directive.json new file mode 100644 index 0000000..4dd23ad --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Rewind", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.response.json new file mode 100644 index 0000000..b0a89c6 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Rewind.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PAUSED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.directive.json new file mode 100644 index 0000000..4f58125 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "StartOver", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.response.json new file mode 100644 index 0000000..a763bf6 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/StartOver.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PLAYING" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/StateReport.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/StateReport.json new file mode 100644 index 0000000..61dfbdc --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/StateReport.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "StateReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "PLAYING" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 500 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.directive.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.directive.json new file mode 100644 index 0000000..71d17c8 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.directive.json @@ -0,0 +1,20 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.PlaybackController", + "name": "Stop", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint id", + "cookie": {} + }, + "payload": {} + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.response.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.response.json new file mode 100644 index 0000000..77fd3bc --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/Stop.response.json @@ -0,0 +1,37 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "endpoint id" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PlaybackStateReporter", + "name": "playbackState", + "value": { + "state": "STOPPED" + }, + "timeOfSample": "2021-12-01T18:20:00.00Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.EndpointHealth", + "name": "connectivity", + "value": { + "value": "OK" + }, + "timeOfSample": "2021-12-01T18:00:00.00Z", + "uncertaintyInMilliseconds": 0 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-playbackcontroller/discovery.json b/test/fixtures/alexa-docs/alexa-playbackcontroller/discovery.json new file mode 100644 index 0000000..029a693 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-playbackcontroller/discovery.json @@ -0,0 +1,81 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "Discover.Response", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Description to be shown in the Alexa app", + "friendlyName": "Living Room TV", + "displayCategories": [ + "TV" + ], + "additionalAttributes": { + "manufacturer": "Manufacturer of the endpoint", + "model": "Model of the device", + "serialNumber": "Serial number of the device", + "firmwareVersion": "Firmware version of the device", + "softwareVersion": "Software version of the device" + }, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.PlaybackController", + "version": "3", + "properties": {}, + "supportedOperations": [ + "Play", + "Pause", + "Stop", + "Next", + "Previous", + "FastForward", + "Rewind", + "StartOver" + ] + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PlaybackStateReporter", + "version": "3", + "properties": { + "supported": [ + { + "name": "playbackState" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa.EndpointHealth", + "version": "3.1", + "properties": { + "supported": [ + { + "name": "connectivity" + } + ], + "proactivelyReported": true, + "retrievable": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.directive.json b/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.directive.json new file mode 100644 index 0000000..e69b5d7 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.directive.json @@ -0,0 +1,23 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.Speaker", + "name": "AdjustVolume", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "volume": -20, + "volumeDefault": false + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.response.json b/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.response.json new file mode 100644 index 0000000..ff011b5 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/AdjustVolume.response.json @@ -0,0 +1,40 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "volume", + "value": 30, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.Speaker", + "name": "muted", + "value": false, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/ChangeReport.json b/test/fixtures/alexa-docs/alexa-speaker/ChangeReport.json new file mode 100644 index 0000000..0b45784 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/ChangeReport.json @@ -0,0 +1,51 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "ChangeReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": { + "change": { + "cause": { + "type": "VOICE_INTERACTION" + }, + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "volume", + "value": 40, + "timeOfSample": "2017-02-03T16:52:50.52Z", + "uncertaintyInMilliseconds": 0 + } + ] + } + } + }, + "context": { + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "muted", + "value": false, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/SetMute.directive.json b/test/fixtures/alexa-docs/alexa-speaker/SetMute.directive.json new file mode 100644 index 0000000..b403cdc --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/SetMute.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.Speaker", + "name": "SetMute", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "mute": true + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/SetMute.response.json b/test/fixtures/alexa-docs/alexa-speaker/SetMute.response.json new file mode 100644 index 0000000..789fa67 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/SetMute.response.json @@ -0,0 +1,40 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "volume", + "value": 30, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.Speaker", + "name": "muted", + "value": true, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/SetVolume.directive.json b/test/fixtures/alexa-docs/alexa-speaker/SetVolume.directive.json new file mode 100644 index 0000000..485ecd1 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/SetVolume.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.Speaker", + "name": "SetVolume", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "volume": 50 + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/SetVolume.response.json b/test/fixtures/alexa-docs/alexa-speaker/SetVolume.response.json new file mode 100644 index 0000000..94a8ccd --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/SetVolume.response.json @@ -0,0 +1,40 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "volume", + "value": 50, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.Speaker", + "name": "muted", + "value": false, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/StateReport.json b/test/fixtures/alexa-docs/alexa-speaker/StateReport.json new file mode 100644 index 0000000..675c3bd --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/StateReport.json @@ -0,0 +1,44 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "StateReport", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.Speaker", + "name": "volume", + "value": 30, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.Speaker", + "name": "muted", + "value": false, + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 0 + }, + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:18:40.12Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/discovery.json b/test/fixtures/alexa-docs/alexa-speaker/discovery.json new file mode 100644 index 0000000..c62fd0b --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/discovery.json @@ -0,0 +1,62 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "Discover.Response", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Smart Speaker by Speaker Maker", + "friendlyName": "Computer speaker", + "displayCategories": [ + "SPEAKER" + ], + "cookie": {}, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.Speaker", + "version": "3", + "properties": { + "supported": [ + { + "name": "volume" + }, + { + "name": "muted" + } + ], + "retrievable": true, + "proactivelyReported": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PowerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "powerState" + } + ], + "retrievable": true, + "proactivelyReported": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/muted.property.json b/test/fixtures/alexa-docs/alexa-speaker/muted.property.json new file mode 100644 index 0000000..30b1dee --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/muted.property.json @@ -0,0 +1,4 @@ +{ + "name": "muted", + "value": false +} diff --git a/test/fixtures/alexa-docs/alexa-speaker/volume.property.json b/test/fixtures/alexa-docs/alexa-speaker/volume.property.json new file mode 100644 index 0000000..49e1c59 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-speaker/volume.property.json @@ -0,0 +1,4 @@ +{ + "name": "volume", + "value": 50 +} diff --git a/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.directive.json b/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.directive.json new file mode 100644 index 0000000..94dab85 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.StepSpeaker", + "name": "AdjustVolume", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "volumeSteps": 20 + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.response.json b/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.response.json new file mode 100644 index 0000000..79fcc58 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-stepspeaker/AdjustVolume.response.json @@ -0,0 +1,26 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.directive.json b/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.directive.json new file mode 100644 index 0000000..7f7551c --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.directive.json @@ -0,0 +1,22 @@ +{ + "directive": { + "header": { + "namespace": "Alexa.StepSpeaker", + "name": "SetMute", + "messageId": "Unique version 4 UUID", + "correlationToken": "Opaque correlation token", + "payloadVersion": "3" + }, + "endpoint": { + "scope": { + "type": "BearerToken", + "token": "OAuth2.0 bearer token" + }, + "endpointId": "Endpoint ID", + "cookie": {} + }, + "payload": { + "mute": true + } + } +} diff --git a/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.response.json b/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.response.json new file mode 100644 index 0000000..79fcc58 --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-stepspeaker/SetMute.response.json @@ -0,0 +1,26 @@ +{ + "event": { + "header": { + "namespace": "Alexa", + "name": "Response", + "messageId": "Unique identifier, preferably a version 4 UUID", + "correlationToken": "Opaque correlation token that matches the request", + "payloadVersion": "3" + }, + "endpoint": { + "endpointId": "Endpoint ID" + }, + "payload": {} + }, + "context": { + "properties": [ + { + "namespace": "Alexa.PowerController", + "name": "powerState", + "value": "ON", + "timeOfSample": "2017-02-03T16:20:50.52Z", + "uncertaintyInMilliseconds": 500 + } + ] + } +} diff --git a/test/fixtures/alexa-docs/alexa-stepspeaker/discovery.json b/test/fixtures/alexa-docs/alexa-stepspeaker/discovery.json new file mode 100644 index 0000000..e74ba4b --- /dev/null +++ b/test/fixtures/alexa-docs/alexa-stepspeaker/discovery.json @@ -0,0 +1,50 @@ +{ + "event": { + "header": { + "namespace": "Alexa.Discovery", + "name": "Discover.Response", + "payloadVersion": "3", + "messageId": "Unique identifier, preferably a version 4 UUID" + }, + "payload": { + "endpoints": [ + { + "endpointId": "Unique ID of the endpoint", + "manufacturerName": "Manufacturer of the endpoint", + "description": "Smart Speaker by Speaker Maker", + "friendlyName": "Computer speaker", + "displayCategories": [ + "SPEAKER" + ], + "cookie": {}, + "capabilities": [ + { + "type": "AlexaInterface", + "interface": "Alexa.StepSpeaker", + "version": "3" + }, + { + "type": "AlexaInterface", + "interface": "Alexa.PowerController", + "version": "3", + "properties": { + "supported": [ + { + "name": "powerState" + } + ], + "retrievable": true, + "proactivelyReported": true + } + }, + { + "type": "AlexaInterface", + "interface": "Alexa", + "version": "3" + } + ] + } + ] + } + } +} diff --git a/test/fixtures/interfaces.js b/test/fixtures/interfaces.js index ede2f58..12a5b49 100644 --- a/test/fixtures/interfaces.js +++ b/test/fixtures/interfaces.js @@ -27,6 +27,18 @@ const inThreeLanguages = (english, spanish, french) => [text(english, "en-US"), module.exports = [ { namespace: "Alexa", page: "alexa-interface", declared: [{ options: {}, example: "discovery" }] }, + { + namespace: "Alexa.ChannelController", + page: "alexa-channelcontroller", + // The page folds its two discovery examples away; the one of its AddOrUpdateReport has the same endpoint + declared: [{ options: reported, example: "discovery-addOrUpdateReport" }], + refused: [ + ["ChangeChannel", { channel: { number: 9 } }, "payload.channel.number: expected a string, got 9"], + ["ChangeChannel", { channel: "KCTS" }, 'payload.channel: expected an object with number, callSign, affiliateCallSign, uri, got "KCTS"'], + ["SkipChannels", { channelCount: 1.5 }, "payload.channelCount: expected an integer, got 1.5"], + ], + unfit: [["channel", "9"], ["channel", { number: 9 }]], + }, { namespace: "Alexa.BrightnessController", page: "alexa-brightnesscontroller", declared: [{ options: reported, example: "discovery" }] }, { namespace: "Alexa.ColorController", @@ -50,7 +62,44 @@ module.exports = [ }, { namespace: "Alexa.ContactSensor", page: "alexa-contactsensor", declared, unfit: [["detectionState", "OPEN"], ["detectionState", true]] }, { namespace: "Alexa.EndpointHealth", page: "alexa-endpointhealth", declared: [{ options: reported, example: "discovery" }] }, + { + namespace: "Alexa.EqualizerController", + page: "alexa-equalizercontroller", + declared: [{ + example: "discovery", + options: { + ...reported, + bands: { supported: ["BASS", "MIDRANGE", "TREBLE"], range: { minimum: -6, maximum: 6 } }, + modes: ["MOVIE", "MUSIC", "SPORT"], + }, + }], + refused: [ + ["SetMode", { mode: "OPERA" }, 'payload.mode: expected MOVIE | MUSIC | NIGHT | SPORT | TV, got "OPERA"'], + ["SetBands", { bands: [{ name: "BASS", value: 1.5 }] }, "payload.bands[0].value: expected an integer, got 1.5"], + ["AdjustBands", { bands: [{ name: "BASS", levelDelta: 3 }] }, "payload.bands[0].levelDirection: expected UP | DOWN, got nothing"], + ["ResetBands", { bands: [] }, "payload.bands: expected a list with 1 or more entries, got []"], + ], + unfit: [["mode", "OPERA"], ["bands", { name: "BASS", value: 0 }], ["bands", [{ name: "SUB", value: 0 }]]], + }, { namespace: "Alexa.HumiditySensor", page: "alexa-humiditysensor", declared, unfit: [["relativeHumidity", 45], ["relativeHumidity", { value: 101 }]] }, + { + namespace: "Alexa.InputController", + page: "alexa-inputcontroller", + // The two discovery examples of the page spell the friendlyNames of HDMI 1 "friendNames". The fixtures have the + // name of the table of the page. + declared: [{ + example: "discovery", + options: { + ...reported, + inputs: [{ name: "HDMI 1", friendlyNames: ["AnyCompany TV"] }, { name: "HDMI 2", friendlyNames: ["Cable", "AnyCompany Cable"] }], + }, + }], + refused: [ + ["SelectInput", { input: "HDMI 11" }, 'payload.input: expected an input like HDMI 1, got "HDMI 11"'], + ["SelectInput", {}, "payload.input: expected an input like HDMI 1, got nothing"], + ], + unfit: [["input", "hdmi 1"], ["input", 1]], + }, { namespace: "Alexa.LockController", page: "alexa-lockcontroller", @@ -70,6 +119,21 @@ module.exports = [ ], unfit: [["percentage", -1], ["percentage", 50.5]], }, + { + namespace: "Alexa.PlaybackController", + page: "alexa-playbackcontroller", + declared: [{ + example: "discovery", + options: { supportedOperations: ["Play", "Pause", "Stop", "Next", "Previous", "FastForward", "Rewind", "StartOver"] }, + }], + refused: [["Play", "now", 'payload: expected an object, got "now"']], + }, + { + namespace: "Alexa.PlaybackStateReporter", + page: "alexa-playbackcontroller", + declared, + unfit: [["playbackState", "PLAYING"], ["playbackState", { state: "REWINDING" }]], + }, { namespace: "Alexa.PowerController", page: "alexa-powercontroller", declared: [{ options: reported, example: "discovery" }] }, { namespace: "Alexa.PowerLevelController", @@ -132,6 +196,26 @@ module.exports = [ ], unfit: [["armState", "ARMED"], ["burglaryAlarm", "ALARM"], ["fireAlarm", { value: "FIRE" }]], }, + { + namespace: "Alexa.Speaker", + page: "alexa-speaker", + declared, + refused: [ + ["SetVolume", { volume: 101 }, "payload.volume: expected an integer from 0 to 100, got 101"], + ["AdjustVolume", { volume: -20 }, "payload.volumeDefault: expected true or false, got nothing"], + ["SetMute", { mute: "yes" }, 'payload.mute: expected true or false, got "yes"'], + ], + unfit: [["volume", 50.5], ["volume", -1], ["muted", "no"]], + }, + { + namespace: "Alexa.StepSpeaker", + page: "alexa-stepspeaker", + declared: [{ options: {}, example: "discovery" }], + refused: [ + ["AdjustVolume", { volumeSteps: 101 }, "payload.volumeSteps: expected an integer from -100 to 100, got 101"], + ["SetMute", {}, "payload.mute: expected true or false, got nothing"], + ], + }, { namespace: "Alexa.TemperatureSensor", page: "alexa-temperaturesensor", declared: [{ options: reported, example: "discovery" }] }, { namespace: "Alexa.ThermostatController", diff --git a/test/registry/descriptors.test.js b/test/registry/descriptors.test.js index 4b59bed..5864ed7 100644 --- a/test/registry/descriptors.test.js +++ b/test/registry/descriptors.test.js @@ -42,7 +42,8 @@ for (const { namespace, page, declared, unfit = [], chosen = false, folded = [] for (const capability of capabilities(from, namespace, example)) { assert.equal(capability.version, descriptor.version, `${example}: version`); assert.equal("instance" in capability, descriptor.instanced, `${example}: instance`); - const supported = capability.properties ? capability.properties.supported.map((property) => property.name) : []; + // Without a properties object, or with one without fields as the PlaybackController has: no property + const supported = ((capability.properties || {}).supported || []).map((property) => property.name); const known = Object.keys(descriptor.properties); assert.deepEqual(supported, chosen ? known.filter((name) => supported.includes(name)) : known, `${example}: properties`); } diff --git a/test/registry/entertainment.test.js b/test/registry/entertainment.test.js new file mode 100644 index 0000000..8ed2f77 --- /dev/null +++ b/test/registry/entertainment.test.js @@ -0,0 +1,108 @@ +"use strict"; +// The interfaces of a TV and a speaker: what the examples of their pages do not show. The examples themselves are +// run by descriptors.test.js, device/discovery.test.js and dispatch/interfaces.test.js. +const { test } = require("node:test"); +const assert = require("node:assert/strict"); +const { + Alex2MQTT, AlexaInterfaceType, DeclarationError, EqualizerController, InputController, Inputs, MemoryPublisher, + PlaybackController, PlaybackStateReporter, Speaker, StepSpeaker, +} = require("alex2node"); +const { endpoint } = require("../helpers/endpoint.js"); +const { directive } = require("../helpers/harness.js"); + +const tv = () => endpoint("tv-1", "TV", ["TV"]); +const refused = (descriptor, options, message) => assert.throws( + () => tv().add(descriptor, options), + (err) => err instanceof DeclarationError && err.message === `tv-1: ${descriptor.namespace}: ${message}` +); + +test("1.x declarations: the version and the properties are those of the pages, where 1.5.2 had version 1 and no property", () => { + const T = AlexaInterfaceType; + const announced = (type) => { + const { version, properties } = tv().addCapability(type).getJSON(); + return [version, properties && properties.supported]; + }; + assert.deepEqual(announced(T.SPEAKER), ["3", [{ name: "volume" }, { name: "muted" }]]); + assert.deepEqual(announced(T.STEP_SPEAKER), ["3", undefined]); + assert.deepEqual(announced(T.EQUALIZER_CONTROLLER), ["3", [{ name: "bands" }, { name: "mode" }]]); + assert.deepEqual(announced(T.PLAYBACK_CONTROLLER), ["3", undefined]); + assert.deepEqual(announced(T.PLAYBACK_STATE_REPORTER), ["3", [{ name: "playbackState" }]]); + assert.deepEqual(announced(T.INPUT_CONTROLLER), ["3", [{ name: "input" }]]); + assert.deepEqual(announced(T.CHANNEL_CONTROLLER), ["3", [{ name: "channel" }]]); +}); + +test("1.x declarations of an equalizer and of inputs have no way to say what the device has: check() says it", () => { + const device = tv(); + device.addCapability(AlexaInterfaceType.EQUALIZER_CONTROLLER); + device.addCapability(AlexaInterfaceType.INPUT_CONTROLLER); + device.addCapability(AlexaInterfaceType.SPEAKER); + assert.deepEqual(device.check(), [ + "tv-1: Alexa.EqualizerController: needs bands, modes or both: declare what the equalizer has", + "tv-1: Alexa.InputController: inputs: expected a list with 1 or more entries, got nothing", + ]); +}); + +test("Speaker and StepSpeaker: neither has options, and the StepSpeaker has no properties object", () => { + assert.deepEqual(tv().add(StepSpeaker).toJSON(), { type: "AlexaInterface", interface: "Alexa.StepSpeaker", version: "3" }); + refused(Speaker, { maximum: 11 }, "maximum: not an option of the interface"); + assert.deepEqual(Object.keys(PlaybackStateReporter.directives), []); +}); + +test("EqualizerController: a device with bands, with modes or with both lists the property of what it has", () => { + const bands = { supported: ["BASS", "TREBLE"], range: { minimum: -10, maximum: 10 } }; + const onlyBands = tv().add(EqualizerController, { bands }).toJSON(); + assert.deepEqual(onlyBands.properties.supported, [{ name: "bands" }]); + assert.deepEqual(onlyBands.configurations, { bands: { supported: [{ name: "BASS" }, { name: "TREBLE" }], range: bands.range } }); + const onlyModes = tv().add(EqualizerController, { modes: ["NIGHT", "TV"] }).toJSON(); + assert.deepEqual(onlyModes.properties.supported, [{ name: "mode" }]); + assert.deepEqual(onlyModes.configurations, { modes: { supported: [{ name: "NIGHT" }, { name: "TV" }] } }); + assert.equal("configuration" in onlyModes, false, "the interface spells it configurations"); + + refused(EqualizerController, {}, "needs bands, modes or both: declare what the equalizer has"); + refused(EqualizerController, { bands: { ...bands, range: { minimum: 6, maximum: -6 } } }, "bands.range.maximum -6 is not above bands.range.minimum 6"); + refused(EqualizerController, { bands: { ...bands, supported: ["BASS", "BASS"] } }, "BASS is listed twice"); + refused(EqualizerController, { modes: ["CINEMA"] }, 'modes[0]: expected MOVIE | MUSIC | NIGHT | SPORT | TV, got "CINEMA"'); +}); + +test("PlaybackController: all eight operations unless the declaration lists some, and only those reach the handler", async () => { + assert.deepEqual(tv().add(PlaybackController).toJSON().supportedOperations, Object.keys(PlaybackController.directives)); + refused( + PlaybackController, + { supportedOperations: ["Eject"] }, + 'supportedOperations[0]: expected Play | Pause | Stop | Next | Previous | FastForward | Rewind | StartOver, got "Eject"' + ); + + const sent = new MemoryPublisher(); + const bridge = new Alex2MQTT("u", "p", "root", false, { publisher: sent, log: () => {} }); + const player = bridge.addDevice({ endpointId: "player-1", name: "Player", categories: ["STREAMING_DEVICE"] }); + const state = player.add(PlaybackStateReporter); + const seen = []; + player.add(PlaybackController, { supportedOperations: ["Play", "Pause"] }).on("*", (ctx) => { + seen.push(ctx.name); + return ctx.respond((s) => s.set(state, "playbackState", { state: ctx.name === "Play" ? "PLAYING" : "PAUSED" })); + }); + for (const [name, token] of [["Play", "ct-1"], ["Rewind", "ct-2"], ["Pause", "ct-3"]]) { + await bridge.receive("root/player-1/alexaDirective", JSON.stringify(directive("Alexa.PlaybackController", name, "player-1", token))); + } + assert.deepEqual(seen, ["Play", "Pause"]); + const answers = sent.published.map(({ message: { event, context } }) => [ + event.header.name, + context ? context.properties.filter(({ name }) => name === "playbackState").map(({ value }) => value.state) : event.payload.type, + ]); + assert.deepEqual(answers, [["Response", ["PLAYING"]], ["ErrorResponse", "INVALID_DIRECTIVE"], ["Response", ["PAUSED"]]]); +}); + +test("InputController: the inputs are on the capability, each name and friendly name stands for one input", () => { + assert.equal(Inputs.length, 61); + assert.equal(new Set(Inputs).size, 61); + const inputs = [{ name: "HDMI 1", friendlyNames: ["Console"] }, { name: "TUNER" }]; + assert.deepEqual(tv().add(InputController, { inputs }).toJSON().inputs, inputs); + refused(InputController, { inputs: [] }, "inputs: expected a list with 1 or more entries, got []"); + refused(InputController, { inputs: [{ name: "SCART" }] }, 'inputs[0].name: expected an input like HDMI 1, got "SCART"'); + refused(InputController, { inputs: [{ name: "TV" }, { name: "TV" }] }, "TV is listed twice, a name stands for one input"); + refused( + InputController, + { inputs: [{ name: "HDMI 1", friendlyNames: ["Console"] }, { name: "HDMI 2", friendlyNames: ["Console"] }] }, + "Console is listed twice, a name stands for one input" + ); +});