lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 3.49 kB
JavaScript
;(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[756],{7756:(e,n,i)=>{i.r(n),i.d(n,{DiagnosticService:()=>h});var t,r,o=i(1061),a=i(8883),c=i(6823);class s{constructor(){this.DeviceGuid="",this.DeviceDiagnosticsStatus=t.Unknown,this.CanBeFixed=!1}}!function(e){e[e.Unknown=0]="Unknown",e[e.Healthy=1]="Healthy",e[e.Unpaired=2]="Unpaired",e[e.FirmwareUpdateMode=3]="FirmwareUpdateMode",e[e.NotResponding=4]="NotResponding",e[e.NotSupported=5]="NotSupported"}(t||(t={})),function(e){e.Success="Success",e.CannotFindDevice="CannotFindDevice",e.OtherError="OtherError",e.FatalError="FatalError",e.DeviceRepairFailed="DeviceRepairFailed",e.RepairingIsUnsupported="RepairingIsUnsupported"}(r||(r={}));var u=i(4756),d=i(9595),l=i(4268),v=i(3386),p=function(e,n,i,t){return new(i||(i=Promise))((function(r,o){function a(e){try{s(t.next(e))}catch(e){o(e)}}function c(e){try{s(t.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?r(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(a,c)}s((t=t.apply(e,n||[])).next())}))};class h{constructor(){this._connection=o.j.Get(d.G.ServiceName),this._controllerConfigurationService=o.j.Get(v.u.ServiceName)}RunDiagnosticAsync(e){return p(this,void 0,void 0,(function*(){var n;try{let i;if("string"==typeof e){const n=yield o.j.Get(a.N7.ServiceName).GetDevice(e);if(null==n)return new c.ZR(r.CannotFindDevice,`Device with specified GUID ${e} does not exists.`);i=n}else i=e;yield this._controllerConfigurationService.EnterConfigurationModeAsync();const d=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new f(i.Guid),6e4,!1);if(null==d)return new c.ZR(r.OtherError,"Cannot run diagnostic - unknown error.");if(d.Status!==u.nW.OK||null==d.Data)return new c.ZR(r.OtherError,`Cannot run diagnostic - device responded with code ${d.Status}, data: ${d.Data}`);const l=new s;return l.DeviceDiagnosticsStatus=d.Data,l.DeviceGuid=i.Guid,l.CanBeFixed=d.Data==t.Unpaired,l}catch(e){return new c.ZR(r.FatalError,`Cannot run diagnostic - exeption occurs! ${e}`)}finally{o.j.Get(l.g.ServiceName).Error(h.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! RunDiagnosticAsync()"),yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}RepairDeviceAsync(e){return p(this,void 0,void 0,(function*(){var n;try{if(yield this._controllerConfigurationService.EnterConfigurationModeAsync(),e.DeviceDiagnosticsStatus===t.Unpaired){const i=new D;i.Data=e.DeviceGuid;const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(i,2e4,!1);return(null==t?void 0:t.Status)==u.nW.OK?u.nW.OK:new c.ZR(r.DeviceRepairFailed,"Cannot repair device - pairing error.")}return new c.ZR(r.RepairingIsUnsupported,"Cannot repair device - repair for given diagnostic result is unsupported.")}catch(e){return new c.ZR(r.FatalError,`Cannot repair device - exeption occurs! ${e}`)}finally{o.j.Get(l.g.ServiceName).Error(h.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! RepairDeviceAsync()"),yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}GetServiceName(){return h.ServiceName}}h.ServiceName="DiagnosticService";class f extends u.CP{constructor(e){super(),this.Resource="/extalife/device/diagnose",this.Method=u.IT.Get,this.Data=e}}class D extends u.CP{constructor(){super(),this.Resource="/extalife/device/pair",this.Method=u.IT.Get}}}}]);
//# sourceMappingURL=756-exalushome-extalife.bundle.js.map