How to use the home-assistant-js-websocket.getUser function in home-assistant-js-websocket

To help you get started, we’ve selected a few home-assistant-js-websocket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timmo001 / home-panel / src / Components / Root.js View on Github external
connection.then(({ conn }) => {
        localStorage.removeItem('auth_triggered');
        this.setState({ connected: true });
        conn.removeEventListener('ready', this.eventHandler);
        conn.addEventListener('ready', this.eventHandler);
        subscribeConfig(conn, this.updateConfig);
        subscribeEntities(conn, this.updateEntities);
        getUser(conn).then(user => {
          console.log('Logged into Home Assistant as', user.name);
          sessionStorage.setItem('hass_id', user.id);
        });
        connection = conn;
      });
    })();
github timmo001 / home-panel / src / Components / HomeAssistant / HomeAssistant.tsx View on Github external
hassUrl: props.url,
              saveTokens: saveTokens,
              loadTokens: () => Promise.resolve(loadTokens())
            });
            connection = await createConnection({ auth });
          } catch (err) {
            throw err;
          }
        }
        props.setConnected(true);
        connection.removeEventListener('ready', eventHandler);
        connection.addEventListener('ready', eventHandler);
        props.setAuth(auth);
        subscribeConfig(connection, updateConfig);
        subscribeEntities(connection, updateEntites);
        getUser(connection).then((user: HassUser) => {
          console.log('Logged into Home Assistant as', user.name);
        });
      })();
  }, [props, updateConfig, updateEntites]);
github home-assistant / home-assistant-polymer / src / data / ws-user.js View on Github external
export const subscribeUser = (conn, onChange) =>
  createCollection("_usr", (conn_) => getUser(conn_), null, conn, onChange);