Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createSocket() {
const self = this.self;
if (!self.config.baseUrl) {
throw homeassistant.ERR_HASS_HOST_REQUIRED;
}
// Convert from http:// -> ws://, https:// -> wss://
const isHassio = self.config.baseUrl === 'http://hassio/homeassistant';
const url = `ws${self.config.baseUrl.substr(4)}${
isHassio ? '' : '/api'
}/websocket`;
const authObj = {
type: 'auth'
};
authObj[self.config.legacy ? 'api_password' : 'access_token'] =
self.config.apiPass;
debug('[Auth Phase] Initializing', url);