Skip to content

Releases: home-assistant/home-assistant-js-websocket

2.1.0

19 Aug 18:17
Compare
Choose a tag to compare
  • Check access token expires before we use (#21 - @awarecan)
  • Breaking Change Remove getting panels (#19 - @balloob)

3.0.0-rc3

14 Aug 20:52
Compare
Choose a tag to compare
3.0.0-rc3 Pre-release
Pre-release

What's Changed

3.0.0-rc2

09 Aug 20:20
Compare
Choose a tag to compare
3.0.0-rc2 Pre-release
Pre-release

What's Changed

3.0.0-rc1

09 Aug 08:53
468918c
Compare
Choose a tag to compare
3.0.0-rc1 Pre-release
Pre-release

Major upgrade of the lib.

The library will now only work with the new OAuth system in Home Assistant. It supports a full OAuth2 authentication flow with any Home Assistant instance out of the box.

The following code is all that is needed to ask the user for their Home Assistant instance url, navigate the user to their instance to authenticate your app, fetch the tokens once returned and connect to the WebSocket API and start logging the entities whenever they change.

import {
  getAuth,
  createConnection,
  subscribeEntities,
  ERR_HASS_HOST_REQUIRED
} from "home-assistant-js-websocket";

async function connect() {
  let auth;
  try {
    // If we came back from authentication flow, retrieve tokens and url
    auth = await getAuth();
  } catch (err) {
    if (err === ERR_HASS_HOST_REQUIRED) {
      // No host configured, ask user for host and initiate authentication flow
      const hassUrl = prompt(
        "What host to connect to?",
        "http://localhost:8123"
      );
      auth = await getAuth({ hassUrl });
    } else {
      alert(`Unknown error: ${err}`);
      return;
    }
  }
  const connection = await createConnection({ auth });
  subscribeEntities(connection, ent => console.log(ent));
}

connect();

Other changes

  • Bring your own WebSocket with the new createSocket connection option. Defined as: (auth, options) => promise<WebSocket>
  • Convert to TypeScript
  • Clean up of the subscription methods
  • Use prettier
  • Bundling using microbundle
  • async / await ! (but converted to promises in the output)

Breaking changes

  • Requires Home Assistant 0.76 or later with the new auth system enabled
  • connection.sendMessagePromise will now resolve to the result instead of returning the WebSocket API wrapper.
    const response = conn.sendMessagePromise({ type: 'ping' });
    // < 3.0.0
    response.then(message => console.log(message.result))
    // 3.0.0
    response.then(result => console.log(result))
  • Drop support for passing in access token or API password
  • The config returned by subscribeConfig no longer contains the services. To subscribe to services use the new subscribeServices method.
  • Subscribe methods now return the unsubscribe function immediately instead of returning a promise that resolves to the unsubscribe function once the initial data load has been done.

2.0.1

18 May 17:28
5ff9df7
Compare
Choose a tag to compare

Mark package as side effect free to help with Webpack treeshaking (docs)

2.0.0

18 May 17:07
9fc5013
Compare
Choose a tag to compare

Breaking change:

  • All group and view extraction helpers have been removed from this package (#16)

1.1.4

08 Mar 23:48
Compare
Choose a tag to compare
  • Don't spam the console with errors when trying to reconnect (@andrey-git - #13)

(the 1.1.3 release should be ignored due to a package publish fail)

1.1.2

09 Oct 04:03
Compare
Choose a tag to compare
  • Remove sorting groups from splitbyGroups (@abmantis - #9)

1.1.0

15 Mar 04:52
Compare
Choose a tag to compare
  • subscribeConfig will now process service_removed events (@pvizeli)

1.0.1

16 Feb 06:16
Compare
Choose a tag to compare

Fixes a bug that when extracting the entities of a view, we would incorrectly ignore the hidden attribute on group entities.