Connect from frontend

This commit is contained in:
2019-06-26 23:51:59 +02:00
parent 1e0bc60220
commit f50a5a84f0
4 changed files with 43 additions and 4 deletions

View File

@@ -1,2 +1,26 @@
alert("Hello!")
import {deviceID} from "/card-tools/deviceId"
class BrowserMod {
constructor() {
window.hassConnection.then((conn) => this.connect(conn.conn));
}
connect(conn) {
console.log("Connection opened. Connecting to browser_mod");
this.connection = conn.subscribeMessage((msg) => this.callback(msg), {
type: 'browser_mod/connect',
deviceID: deviceID,
});
console.log("Connected");
console.log(this.connection);
}
callback(msg) {
console.log("Got ws message");
console.log(msg);
}
}
window.browser_mod = new BrowserMod();