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
|
|
@ -78,10 +78,16 @@ interface FriendlyName {
|
|||
locale: string;
|
||||
}
|
||||
|
||||
/** One ModeController mode as discovery lists it (configuration.supportedModes): the value plus its friendly names. */
|
||||
export interface SupportedMode {
|
||||
value: string;
|
||||
modeResources?: { friendlyNames: Array<{ "@type": string; value: { text?: string; locale?: string; assetId?: string } }> };
|
||||
}
|
||||
|
||||
export class AlexaInterface {
|
||||
private friendlyNames: FriendlyName[] = [];
|
||||
private actionMappings: ActionMapping[] = [];
|
||||
private supportedModes: string[] = [];
|
||||
private supportedModes: Array<string | SupportedMode> = [];
|
||||
|
||||
constructor(
|
||||
public type: AlexaInterfaceType,
|
||||
|
|
@ -97,7 +103,8 @@ export class AlexaInterface {
|
|||
addFriendlyName(name: string, locale: string): void {
|
||||
this.friendlyNames.push({ text: name, locale });
|
||||
}
|
||||
addSupportedModes(modes: string[]): void {
|
||||
/** The modes of a ModeController: { value, modeResources } objects as Alexa wants them (plain strings pass through as given). */
|
||||
addSupportedModes(modes: Array<string | SupportedMode>): void {
|
||||
this.supportedModes = modes;
|
||||
}
|
||||
setInstance(name: string): void {
|
||||
|
|
@ -218,10 +225,10 @@ export class AlexaInterface {
|
|||
return ["temperature"];
|
||||
case AlexaInterfaceType.THERMOSTAT_CONTROLLER:
|
||||
return [
|
||||
"targetSetpoint",
|
||||
"lowerSetpoint",
|
||||
"upperSetpoint",
|
||||
"thermostatMode",
|
||||
"adaptiveRecoveryStatus",
|
||||
];
|
||||
case AlexaInterfaceType.APPLICATION_STATE_REPORTER:
|
||||
case AlexaInterfaceType.AUDIO_PLAY_QUEUE:
|
||||
|
|
@ -272,7 +279,8 @@ export class AlexaInterface {
|
|||
case AlexaInterfaceType.USER_PREFERENCE:
|
||||
case AlexaInterfaceType.VIDEO_RECORDER:
|
||||
case AlexaInterfaceType.WAKE_ON_LAN_CONTROLLER:
|
||||
console.error("UNSUPORTED INTERFACE TYPE");
|
||||
// no property list known for these: discovery lists the capability with an empty "supported" (the bridge notes
|
||||
// it through its log hook; 1.5.1 wrote "UNSUPORTED INTERFACE TYPE" to stderr on every discovery)
|
||||
return [];
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue