UNPKG

node-red-contrib-home-assistant-websocket

Version:
2 lines (1 loc) 1.83 kB
"use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var E=(n,e)=>{for(var o in e)s(n,o,{get:e[o],enumerable:!0})},C=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!v.call(n,i)&&i!==o&&s(n,i,{get:()=>e[i],enumerable:!(r=h(e,i))||r.enumerable});return n};var c=n=>C(s({},"__esModule",{value:!0}),n);var S={};E(S,{default:()=>g});module.exports=c(S);var a=require("../../common/events/Events"),d=require("../../homeAssistant"),t=require("../../homeAssistant/Websocket");class g{constructor(e,o){this.onHaEventsOpen=()=>{this.#e.log(`Connected to ${this.#t}`)};this.onHaStatesLoaded=()=>{this.#e.debug("States Loaded")};this.onHaServicesLoaded=()=>{this.#e.debug("Services Loaded")};this.onHaEventsConnecting=()=>{this.#e.log(`Connecting to ${this.#t}`)};this.onHaEventsClose=()=>{this.#e.log(`Connection closed to ${this.#t}`)};this.onHaEventsRunning=()=>{this.#e.debug("HA State: running")};this.onHaEventsError=e=>{this.#e.debug(e)};this.onIntegrationEvent=e=>{this.#e.debug(`Integration: ${e}`)};this.onRegistriesLoaded=()=>{this.#e.debug("Registries Loaded")};this.#t=e.config.addon?d.SUPERVISOR_URL:e.credentials.host,this.#e=e,o.addListeners(this,[[t.ClientEvent.Close,this.onHaEventsClose],[t.ClientEvent.Open,this.onHaEventsOpen],[t.ClientEvent.Connecting,this.onHaEventsConnecting],[t.ClientEvent.Error,this.onHaEventsError],[t.ClientEvent.Running,this.onHaEventsRunning],[t.ClientEvent.StatesLoaded,this.onHaStatesLoaded],[t.ClientEvent.ServicesLoaded,this.onHaServicesLoaded],["integration",this.onIntegrationEvent],[t.ClientEvent.RegistriesLoaded,this.onRegistriesLoaded]]),e.on(a.NodeEvent.Close,this.onClose.bind(this))}#t;#e;onClose(e,o){this.#e.log(`Closing connection to ${this.#t}`),o()}}