Merge pull request #166 from klein0r/master

Use /core/ instead of /api/ when connecting to supervisor directly
This commit is contained in:
Bluefox
2026-05-16 19:06:18 +02:00
committed by GitHub
4 changed files with 12 additions and 3 deletions
+4
View File
@@ -9,3 +9,7 @@ package-lock.json
.commitinfo .commitinfo
.claude/settings.local.json .claude/settings.local.json
# ioBroker dev-server
.dev-server/
+4
View File
@@ -106,6 +106,10 @@ Please check it https://www.smarthomejetzt.de/mit-iobroker-auf-eine-home-assista
--> -->
## Changelog ## Changelog
### **WORK IN PROGRESS**
* (@klein0r) Use /core/ instead of /api/ when connecting to supervisor directly (e.g. in ha app)
* (@klein0r) Use ENV var SUPERVISOR_TOKEN as fallback for password
### 2.0.4 (2026-05-05) ### 2.0.4 (2026-05-05)
* (@GermanBluefox) Tried to keep the custom settings of the objects when updating them with new data from HASS * (@GermanBluefox) Tried to keep the custom settings of the objects when updating them with new data from HASS
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

+4 -3
View File
@@ -108,11 +108,12 @@ export default class HASS extends EventEmitter {
this.emit('state_changed', response.event.data.new_state); this.emit('state_changed', response.event.data.new_state);
} }
} else if (response.type === 'auth_required') { } 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'); this.emit('error', 'Password required. Connection closed');
socket.terminate(); socket.terminate();
} else { } else {
setTimeout(() => this.sendAuth(socket, this.options.password!), 50); setTimeout(() => this.sendAuth(socket, password), 50);
} }
} else if (response.type === 'auth_ok') { } else if (response.type === 'auth_ok') {
setImmediate(() => setImmediate(() =>
@@ -228,7 +229,7 @@ export default class HASS extends EventEmitter {
} }
this.socket = new WebSocket( this.socket = new WebSocket(
`ws${this.options.secure ? 's' : ''}://${this.options.host}:${this.options.port}/api/websocket`, `ws${this.options.secure ? 's' : ''}://${this.options.host}:${this.options.port}/${this.options.host === 'supervisor' ? 'core' : 'api'}/websocket`,
{ perMessageDeflate: false }, { perMessageDeflate: false },
); );