device: the client of new Device() and setMqttClient() warn once
2.0 ignored the first argument of the Device constructor in silence and had removed setMqttClient(), so a 1.x call threw a TypeError. Both are deprecated shims now, as the design lists them: setMqttClient() is back and does nothing, a client given to the constructor is ignored, and each says once in a process what to do. The line goes to the log hook of the bridge; a device on no bridge has none and emits a DeprecationWarning (ALEX2NODE_DEVICE_CLIENT, ALEX2NODE_SET_MQTT_CLIENT). null and undefined as the client warn nothing: the bridge passes null. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
29ee1a315e
commit
2f6730eb52
9 changed files with 188 additions and 5 deletions
17
dist/types/device/Device.d.ts
vendored
17
dist/types/device/Device.d.ts
vendored
|
|
@ -73,14 +73,29 @@ declare class Device extends EventEmitter {
|
|||
* is null every send() resolves "" and reports why.
|
||||
*/
|
||||
publisher: Publisher | null;
|
||||
/** Where the device says that a call of 1.x no longer does anything. The bridge sets it to its log hook. */
|
||||
log?: (message: string) => void;
|
||||
/** Set by state(). */
|
||||
stateProvider?: Fill;
|
||||
/** Set by onReportState(). */
|
||||
reportStateHandler?: DirectiveHandler<Record<string, never>>;
|
||||
/** Set by onDirective(). */
|
||||
directiveHandler?: DirectiveHandler;
|
||||
/** client is ignored: in 1.x it was the broker client, and a device could only be built after connect(). */
|
||||
/**
|
||||
* client is ignored and null is what to pass: in 1.x it was the broker client, and a device could only be built
|
||||
* after connect(). A device that is given one says once that it publishes through its bridge.
|
||||
*
|
||||
* @deprecated Removed in 3.0, with the device made by bridge.addDevice() or bridge.registerDevice().
|
||||
*/
|
||||
constructor(client: unknown, rootTopic: string, name: string, endpointId: string, displayCategory: Array<DisplayCategory> | null, description?: string, manufacturerName?: string, manufacturer?: string, model?: string);
|
||||
/**
|
||||
* Does nothing. In 1.5.2 the bridge gave its devices the new broker client after disconnect() and connect();
|
||||
* they now publish through the bridge and need no client.
|
||||
*
|
||||
* @deprecated Removed in 3.0. Remove the call, or set device.publisher to publish somewhere else.
|
||||
*/
|
||||
setMqttClient(_client: unknown): void;
|
||||
private deprecated;
|
||||
getName(): string;
|
||||
setName(name: string): void;
|
||||
getEndpointId(): string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue