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:
David 2026-09-28 21:19:10 +00:00
parent 29ee1a315e
commit 2f6730eb52
9 changed files with 188 additions and 5 deletions

View file

@ -239,6 +239,7 @@ class Alex2MQTT extends EventEmitter {
register(device, endpointHealth) {
device.alexaInterface = this.options.alexaInterface !== false;
device.endpointHealth = endpointHealth;
device.log = (message) => this.log(message);
device.onPublishError = (err) => this.fail(err); // a failed publish is an "error" event (when listened to), never a rejected send()
// Through the dispatcher, which lets one answer to a directive pass
device.publisher = this.dispatcher.publisher;