UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 7.49 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[341],{8341:(e,t,n)=>{n.r(t),n.d(t,{SsrConfigService:()=>A});var r,a=n(1701);class o extends a.l{}!function(e){e[e.Automatic=0]="Automatic",e[e.Manual=1]="Manual"}(r||(r={}));var s=n(7460),i=n(624),c=n(6440),u=n(7418),l=n(2160),d=n(2),h=n(866),v=n(2765),f=n(2166),p=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}c((r=r.apply(e,t||[])).next())}))};class y extends a.l{constructor(){super()}RunAutomaticCalibrationAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new i.tp(a.J.InvalidChannelNumber,`Cannot calibrate blind - invalid channel number: ${t}`);const o=new u.LO;if(o.Action=u.IC.Stop,(yield e.Channels.first((e=>e.Number==t)).ExecuteTaskAsync(o))!==l.G.Executed)return new i.tp(a.J.DeviceNotResponding,"Cannot calibrate blind - device is not responding.");const d=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new C(e.Guid),8e3,!1);if(null==d||null==d.Status)return new i.tp(a.J.OtherError,"Cannot calibrate blind - calibration request failed for an unknown reason.");switch(d.Status){case c.qb.OK:var r=new s.nv;return r.CalibrationStatus=s.oQ.AutoLernInProgress,r.Channel=t,r.StateReliability=s.op.Confident,r;case c.qb.Error:return new i.tp(a.J.CalibrationsIsCurrentlyRunning,"Cannot calibrate blind - calibration is currently running.");default:return new i.tp(a.J.OtherError,`Cannot calibrate blind - calibration request failed - request status code: ${d.Status}`)}}catch(e){return new i.tp(a.J.OtherError,`Cannot calibrate blind - fatal error: ${e}`)}}))}GetCorrectionStepAsync(e,t,n){const r=Object.create(null,{GetCorrectionStepAsync:{get:()=>super.GetCorrectionStepAsync}});return p(this,void 0,void 0,(function*(){try{const o=yield h.V.Get(f.pJ.ServiceName).GetSoftwareRuntimeInfoAsync(),[s,c]=o.SoftwareVersion.split(".").map((e=>parseInt(e)));if(s>=7&&c>=45){const o=yield this.GetWorkLogAsyncRaw(e,t);return o instanceof i.tp?o:o.ManualAutoConfigFlag&&"UPPER"===n?new i.tp(a.J.NotAvailableInManualMode,"Cannot get correction step - not available in manual mode."):r.GetCorrectionStepAsync.call(this,e,t,n)}return r.GetCorrectionStepAsync.call(this,e,t,n)}catch(e){return new i.tp(a.J.OtherError,`Cannot get correction step - fatal error: ${e}`)}}))}SetCorrectionStepAsync(e,t,n,r){const a=Object.create(null,{SetCorrectionStepAsync:{get:()=>super.SetCorrectionStepAsync}});return p(this,void 0,void 0,(function*(){try{const o=yield h.V.Get(f.pJ.ServiceName).GetSoftwareRuntimeInfoAsync(),[s,u]=o.SoftwareVersion.split(".").map((e=>parseInt(e)));if(s>=7&&u>=45){const o=yield this.GetWorkLogAsyncRaw(e,t);return o instanceof i.tp?(this._logger.Error(`Cannot set correction step - cannot get work log - ${o.Type} - ${o.Data}`),c.qb.Error):o.ManualAutoConfigFlag&&"UPPER"===r?(this._logger.Warning("Cannot set correction step - not available in manual mode."),c.qb.WrongData):yield a.SetCorrectionStepAsync.call(this,e,t,n,r)}return yield a.SetCorrectionStepAsync.call(this,e,t,n,r)}catch(e){return this._logger.Error(`Cannot set correction step - fatal error: ${e}`),c.qb.FatalError}}))}GetHeadSensorStatusAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new i.tp(a.J.InvalidChannelNumber,`Cannot get head sensor status - invalid channel number: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e.Guid,t),8e3,!1);return null==r||null==r.Status?new i.tp(a.J.OtherError,"Cannot get head sensor status - request failed for an unknown reason."):r.Status!=c.qb.OK?new i.tp(a.J.OtherError,`Cannot get head sensor status - request failed - request status code: ${r.Status}`):null==r.Data?new i.tp(a.J.NoData,"Cannot get head sensor status - request failed - no data received."):r.Data}catch(e){return new i.tp(a.J.OtherError,`Cannot get head sensor status - fatal error: ${e}`)}}))}SwitchHeadSensorStatusAsync(e,t,n){var r;return p(this,void 0,void 0,(function*(){try{if(!t.Channels.any((e=>e.Number===n)))return c.qb.WrongData;const a=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new b(t.Guid,n,e),8e3,!1);return null==a||null==a.Status?c.qb.FatalError:a.Status}catch(e){return c.qb.FatalError}}))}ChangeMovementDirectionAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return c.qb.WrongData;const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new w(e.Guid,t),8e3,!1);return null==r||null==r.Status?c.qb.FatalError:r.Status}catch(e){return c.qb.FatalError}}))}GetWorkingModeAsync(e,t){return p(this,void 0,void 0,(function*(){const n=yield h.V.Get(f.pJ.ServiceName).GetSoftwareRuntimeInfoAsync(),[a,o]=n.SoftwareVersion.split(".").map((e=>parseInt(e)));if(a>=7&&o>=45){const n=yield this.GetWorkLogAsyncRaw(e,t);return n instanceof i.tp?n:n.ManualAutoConfigFlag?r.Manual:r.Automatic}return r.Automatic}))}GetWorkLogAsync(e,t){return p(this,void 0,void 0,(function*(){try{const n=yield h.V.Get(d.f.ServiceName).GetUserAsync();return null==n||n.AccessLevel<v.uv.Support?new i.tp(a.J.InsufficientPermissions,"Cannot get head sensor status - current user has insufficient permissions."):yield this.GetWorkLogAsyncRaw(e,t)}catch(e){return new i.tp(a.J.OtherError,`Cannot get work log - fatal error: ${e}`)}}))}GetWorkLogAsyncRaw(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new i.tp(a.J.InvalidChannelNumber,`Cannot get head sensor status - invalid channel number: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new g(e.Guid,t),8e3,!1);return null==r||null==r.Status?new i.tp(a.J.OtherError,"Cannot get work log - request failed for an unknown reason."):r.Status!=c.qb.OK?new i.tp(a.J.OtherError,`Cannot get work log - request failed - request status code: ${r.Status}`):null==r.Data?new i.tp(a.J.NoData,"Cannot get work log - request failed - no data received."):r.Data}catch(e){return new i.tp(a.J.OtherError,`Cannot get work log - fatal error: ${e}`)}}))}}class C extends c.NE{constructor(e){super(),this.Resource="/extafree2/blind/calibration/auto",this.Method=c.n$.Get,this.Data=e}}class S extends c.NE{constructor(e,t){super(),this.Resource="/extalife/device/blind/head/sensor/status",this.Method=c.n$.Get,this.Data={DeviceGuid:e,Channel:t}}}class b extends c.NE{constructor(e,t,n){super(),this.Resource="/extalife/device/blind/head/sensor/switch",this.Method=c.n$.Put,this.Data={DeviceGuid:e,Channel:t,Enable:n}}}class w extends c.NE{constructor(e,t){super(),this.Resource="/extalife/device/blind/direction/reverse",this.Method=c.n$.Post,this.Data={DeviceGuid:e,Channel:t}}}class g extends c.NE{constructor(e,t){super(),this.Resource="/extalife/device/blind/work/log",this.Method=c.n$.Get,this.Data={DeviceGuid:e,Channel:t}}}class A extends o{constructor(){super(),this._services={Ssr_4_0_0_0:new y}}GetServiceName(){return A.ServiceName}VersionedConfigurationOptions(){return{"^4.0.0.0":this._services.Ssr_4_0_0_0}}}A.ServiceName="SsrConfigService"}}]); //# sourceMappingURL=341-exalushome-extalife.bundle.js.map