UNPKG

lavva.exalushome.extalife

Version:

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

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