How to use the home-assistant-js-websocket.subscribeConfig 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 zachowj / node-red-contrib-home-assistant-websocket / lib / ha-websocket.js View on Github external
'disconnected',
            this.onClientClose.bind(this)
        );
        this.client.addEventListener(
            'reconnect-error',
            this.onClientError.bind(this)
        );

        // Home Assistant Events
        homeassistant.subscribeEntities(this.client, ent =>
            this.onClientStates(ent)
        );
        homeassistant.subscribeServices(this.client, ent =>
            this.onClientServices(ent)
        );
        homeassistant.subscribeConfig(this.client, config =>
            this.onClientConfigUpdate(config)
        );

        return true;
    }
github home-assistant / home-assistant-polymer / src / state / connection-mixin.ts View on Github external
const conn = this.hass!.connection;

      broadcastConnectionStatus("connected");

      conn.addEventListener("ready", () => this.hassReconnected());
      conn.addEventListener("disconnected", () => this.hassDisconnected());
      // If we reconnect after losing connection and auth is no longer valid.
      conn.addEventListener("reconnect-error", (_conn, err) => {
        if (err === ERR_INVALID_AUTH) {
          broadcastConnectionStatus("auth-invalid");
          location.reload();
        }
      });

      subscribeEntities(conn, (states) => this._updateHass({ states }));
      subscribeConfig(conn, (config) => this._updateHass({ config }));
      subscribeServices(conn, (services) => this._updateHass({ services }));
      subscribePanels(conn, (panels) => this._updateHass({ panels }));
    }
github home-assistant / home-assistant-polymer / src / entrypoints / core.ts View on Github external
window.hassConnection.then(({ conn }) => {
  const noop = () => {
    // do nothing
  };
  subscribeEntities(conn, noop);
  subscribeConfig(conn, noop);
  subscribeServices(conn, noop);
  subscribePanels(conn, noop);
  subscribeThemes(conn, noop);
  subscribeUser(conn, noop);

  if (location.pathname === "/" || location.pathname.startsWith("/lovelace/")) {
    (window as WindowWithLovelaceProm).llConfProm = fetchConfig(conn, false);
  }
});
github timmo001 / home-panel / src / Components / HomeAssistant / HomeAssistant.tsx View on Github external
saveTokens();
            auth = await getAuth({
              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 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 home-assistant / home-assistant-polymer / js / core.js View on Github external
.then(function (conn) {
      HAWS.subscribeEntities(conn);
      HAWS.subscribeConfig(conn);
      return conn;
    });
};