UNPKG

lavva.exalushome.extalife

Version:

Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system

2 lines 3.26 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[542],{2542:(e,n,i)=>{i.r(n),i.d(n,{DiagnosticService:()=>p});var t,r,o=i(5046),a=i(2889),c=i(624);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(6440),d=i(6895),l=i(4533),v=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 p{constructor(){this._connection=o.V.Get(d.c.ServiceName),this._controllerConfigurationService=o.V.Get(l.Q.ServiceName)}RunDiagnosticAsync(e){var n;return v(this,void 0,void 0,(function*(){try{let i;if("string"==typeof e){const n=yield o.V.Get(a.Ih.ServiceName).GetDevice(e);if(null==n)return new c.tp(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 h(i.Guid),6e4,!1);if(null==d)return new c.tp(r.OtherError,"Cannot run diagnostic - unknown error.");if(d.Status!==u.qb.OK||null==d.Data)return new c.tp(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.tp(r.FatalError,`Cannot run diagnostic - exeption occurs! ${e}`)}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}RepairDeviceAsync(e){var n;return v(this,void 0,void 0,(function*(){try{if(yield this._controllerConfigurationService.EnterConfigurationModeAsync(),e.DeviceDiagnosticsStatus===t.Unpaired){const i=new f;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.qb.OK?u.qb.OK:new c.tp(r.DeviceRepairFailed,"Cannot repair device - pairing error.")}return new c.tp(r.RepairingIsUnsupported,"Cannot repair device - repair for given diagnostic result is unsupported.")}catch(e){return new c.tp(r.FatalError,`Cannot repair device - exeption occurs! ${e}`)}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}GetServiceName(){return p.ServiceName}}p.ServiceName="DiagnosticService";class h extends u.NE{constructor(e){super(),this.Resource="/extalife/device/diagnose",this.Method=u.n$.Get,this.Data=e}}class f extends u.NE{constructor(){super(),this.Resource="/extalife/device/pair",this.Method=u.n$.Get}}}}]); //# sourceMappingURL=542-exalushome-extalife.bundle.js.map