Use ENV var SUPERVISOR_TOKEN as fallback for password

This commit is contained in:
Matthias Kleine
2026-04-28 11:15:02 +02:00
parent 7575b129c0
commit 5657211716
2 changed files with 4 additions and 2 deletions
+3 -2
View File
@@ -108,11 +108,12 @@ export default class HASS extends EventEmitter {
this.emit('state_changed', response.event.data.new_state);
}
} else if (response.type === 'auth_required') {
if (!this.options.password) {
const password = this.options.password || process.env.SUPERVISOR_TOKEN;
if (!password) {
this.emit('error', 'Password required. Connection closed');
socket.terminate();
} else {
setTimeout(() => this.sendAuth(socket, this.options.password!), 50);
setTimeout(() => this.sendAuth(socket, password), 50);
}
} else if (response.type === 'auth_ok') {
setImmediate(() =>