src/transport.ts has the Publisher interface, MqttPublisher (the client the bridge has at the time) and MemoryPublisher (tests without a broker); src/topics.ts names the four topics the library publishes to. Device, AlexaStatusMessage, AlexaErrorResponse and sendSceneResponse shared three copies of the publish-and-report code: they now call one send() that resolves the topic or "" and never rejects. registerDevice() and addDevice() work before connect(); a send() without a connection resolves "" and the "error" event says to call connect(). unregisterDevice() and clearDevices() take the publisher from the device. Device.setMqttClient() is gone, the first constructor argument of Device is ignored, and the message classes take a Publisher where they took the client. Tests: 108 -> 113. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
10 lines
472 B
JavaScript
10 lines
472 B
JavaScript
"use strict";
|
|
// A device that is on no bridge. What a device declares and the discovery JSON it answers with need no broker.
|
|
const { Device } = require("alex2node");
|
|
|
|
/** The arguments Device takes before the name are the broker client of 1.x, ignored, and the root topic of its bridge. */
|
|
function endpoint(endpointId = "lamp-1", name = "Lamp", categories = ["LIGHT"]) {
|
|
return new Device(null, "root", name, endpointId, categories);
|
|
}
|
|
|
|
module.exports = { endpoint };
|