import * as HAWS from 'home-assistant-js-websocket';

window.HAWS = HAWS;
window.HASS_DEMO = __DEMO__;

const init = window.createHassConnection = function (password) {
  const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
  const url = `${proto}://${window.location.host}/api/websocket`;
  const options = {};
  if (password !== undefined) {
    options.authToken = password;
  }

  return HAWS.createConnection(url, options)
    .then(function (conn) {
      HAWS.subscribeEntities(conn);
      HAWS.subscribeConfig(conn);
      return conn;
    });
};

if (window.noAuth) {
  window.hassConnection = init();
} else if (window.localStorage.authToken) {
  window.hassConnection = init(window.localStorage.authToken);
} else {
  window.hassConnection = null;
}

import * as HAWS from 'home-assistant-js-websocket';

window.HAWS = HAWS;
window.HASS_DEMO = __DEMO__;

const init = window.createHassConnection = function (password) {
  const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
  const url = `${proto}://${window.location.host}/api/websocket`;
  const options = {};
  if (password !== undefined) {
    options.authToken = password;
  }

  return HAWS.createConnection(url, options)
    .then(function (conn) {
      HAWS.subscribeEntities(conn);
      HAWS.subscribeConfig(conn);
      return conn;
    });
};

if (window.noAuth) {
  window.hassConnection = init();
} else if (window.localStorage.authToken) {
  window.hassConnection = init(window.localStorage.authToken);
} else {
  window.hassConnection = null;
}

if ('serviceWorker' in navigator) {
  window.addEventListener('load', function () {
    navigator.serviceWorker.register('/service_worker.js');
  });
}

Add service worker registration back
Add service worker registration back
