1.5.2: send() never rejects (status, error, scene, change report: resolves the topic or "" and reports the failure through the bridge's error event when listened to - 1.5.1 rejected, and an un-caught .send() killed the host on any broker hiccup); types ship (declaration: true, dist/*.d.ts tracked; addSupportedModes takes {value, modeResources}, ActionMapping payload optional, addHealthProp accepts EndpointHealth or the string); disconnect()/connect() re-binds devices to the new client; registerDevice returns the existing device on a duplicate endpointId (warning via the log hook, console.warn without one); ThermostatController discovery lists targetSetpoint and drops adaptiveRecoveryStatus; the UNSUPORTED INTERFACE TYPE stderr spam goes through the log hook. Examples: require("alex2node"), an error listener in each, EndpointHealth.OK, neutral endpoint ids, BlindControl reads correlationToken from the header, the thermostat reports Fahrenheit as Fahrenheit, ExamplePowerController is power-only again + new ExamplePowerControllerWithBrightness. readme (install from Forgejo, 1.5.2 changelog, table syntax), LICENSE (MIT); tests for the non-rejecting send, reconnect, duplicate, thermostat discovery and the shipped declaration signatures (8/8 on an in-process broker).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
717af632de
commit
275f00f8a7
35 changed files with 1011 additions and 176 deletions
60
dist/Device.d.ts
vendored
Normal file
60
dist/Device.d.ts
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { AlexaInterface, AlexaInterfaceType } from "./AlexaInterface";
|
||||
import { DisplayCategory } from "./DisplayCategory";
|
||||
import { EventEmitter } from "events";
|
||||
import { MqttClient } from "mqtt";
|
||||
import { AlexaStatusMessage, ChangeCause } from "./AlexaStatusMessage";
|
||||
import { AlexaErrorResponse } from "./AlexaErrorResponse";
|
||||
declare class Device extends EventEmitter {
|
||||
private mqttClient;
|
||||
private rootTopic;
|
||||
name: string;
|
||||
endpointId: string;
|
||||
displayCategory: Array<DisplayCategory> | null;
|
||||
description: string;
|
||||
manufacturerName: string;
|
||||
manufacturer: string;
|
||||
model: string;
|
||||
protected softwareVersion: string;
|
||||
private capabilities;
|
||||
/** Where a failed publish from this device or a message it built is reported; Alex2MQTT sets it (1.5.2). */
|
||||
onPublishError?: (err: Error) => void;
|
||||
constructor(mqttClient: MqttClient, rootTopic: string, name: string, endpointId: string, displayCategory: Array<DisplayCategory> | null, description?: string, manufacturerName?: string, manufacturer?: string, model?: string);
|
||||
/** Internal (1.5.2): Alex2MQTT.connect() re-binds every registered device to its new broker client after a disconnect(). */
|
||||
setMqttClient(client: MqttClient): void;
|
||||
getName(): string;
|
||||
setName(name: string): void;
|
||||
getEndpointId(): string;
|
||||
setDisplayCategory(category: DisplayCategory | DisplayCategory[]): void;
|
||||
getDisplayCategory(): Array<DisplayCategory>;
|
||||
setDescription(description: string): void;
|
||||
getDescription(): string;
|
||||
getErrorMessage(correlationToken: string): AlexaErrorResponse;
|
||||
getStatusMessage(correlationToken: string, isResponse?: boolean, isDeferred?: boolean): AlexaStatusMessage;
|
||||
/**
|
||||
* A proactive Alexa.ChangeReport (1.5.1): add the changed properties (the default target), optionally
|
||||
* .unchanged() then the others, and .send() - it goes to <root>/changeReport, which Alex2MQTT forwards to the Alexa
|
||||
* event gateway with the user's token. Alexa only accepts it for capabilities registered with proactivelyReported.
|
||||
*/
|
||||
getChangeReport(cause?: ChangeCause): AlexaStatusMessage;
|
||||
/**
|
||||
* Alexa.SceneController: answer an Activate / Deactivate directive with ActivationStarted / DeactivationStarted
|
||||
* (1.5.1). Resolves with the topic published to, or "" when the publish failed (never rejects, 1.5.2).
|
||||
*/
|
||||
sendSceneResponse(correlationToken: string, activated: boolean, cause?: ChangeCause, sendAsync?: boolean): Promise<string>;
|
||||
getCapabilities(): AlexaInterface[];
|
||||
setManufacturerName(name: string): void;
|
||||
getManufacturerName(): string;
|
||||
setManufacturer(manufacturer: string): void;
|
||||
getManufacturer(): string;
|
||||
setModel(model: string): void;
|
||||
getModel(): string;
|
||||
getSoftwareVersion(): string;
|
||||
/** Add a capability. 1.5.1: options.retrievable / proactivelyReported / instance (a change report needs proactivelyReported). */
|
||||
addCapability(type: AlexaInterfaceType, options?: {
|
||||
retrievable?: boolean;
|
||||
proactivelyReported?: boolean;
|
||||
instance?: string;
|
||||
}): AlexaInterface;
|
||||
getJSON(): Record<string, any>;
|
||||
}
|
||||
export default Device;
|
||||
Loading…
Add table
Add a link
Reference in a new issue