UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 4.93 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[64],{5064:(e,r,t)=>{t.r(r),t.d(r,{WszfBidiConfigService:()=>S});var n,s,i=t(1061),o=t(4756),h=t(3386),l=t(9595),d=t(6823),a=t(4268),u=t(6030);class c{constructor(){this.WindThreshold=n.Disabled,this.BrightnessThreshold=s.Disabled}}!function(e){e[e.Disabled=0]="Disabled",e[e.Speed15km_h=1]="Speed15km_h",e[e.Speed21km_h=2]="Speed21km_h",e[e.Speed28km_h=3]="Speed28km_h",e[e.Speed36km_h=4]="Speed36km_h",e[e.Speed45km_h=5]="Speed45km_h",e[e.Speed55km_h=6]="Speed55km_h",e[e.Speed66km_h=7]="Speed66km_h",e[e.Speed78km_h=8]="Speed78km_h",e[e.Speed91km_h=9]="Speed91km_h"}(n||(n={})),function(e){e[e.Disabled=0]="Disabled",e[e.Brightness2000lux=1]="Brightness2000lux",e[e.Brightness5000lux=2]="Brightness5000lux",e[e.Brightness10000lux=3]="Brightness10000lux",e[e.Brightness20000lux=4]="Brightness20000lux",e[e.Brightness40000lux=5]="Brightness40000lux",e[e.Brightness60000lux=6]="Brightness60000lux",e[e.Brightness70000lux=7]="Brightness70000lux",e[e.Brightness80000lux=8]="Brightness80000lux",e[e.Brightness90000lux=9]="Brightness90000lux"}(s||(s={}));var g=function(e,r,t,n){return new(t||(t=Promise))((function(s,i){function o(e){try{l(n.next(e))}catch(e){i(e)}}function h(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,h)}l((n=n.apply(e,r||[])).next())}))};class S{constructor(){this._connection=i.j.Get(l.G.ServiceName),this._logger=i.j.Get(a.g.ServiceName),this._controllerConfigurationService=i.j.Get(h.u.ServiceName)}GetServiceName(){return S.ServiceName}GetBrightnessAndWindThresholdAsync(e,r){return g(this,void 0,void 0,(function*(){var r;try{const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new m(e.Guid),8e3,!1);if(null==t||null==t.Status||null==t.Data)return new d.ZR(u.m.OtherError,"Cannot get brightness threshold - unknown error.");if(t.Status!==o.nW.OK)return new d.ZR(u.m.OtherError,`Cannot get brightness threshold - controller responded with error code: ${t.Status}.`);const n=new c;return n.BrightnessThreshold=t.Data.BrightnessThreshold,n.WindThreshold=t.Data.WindThreshold,n}catch(e){return new d.ZR(u.m.OtherError,"Cannot get brightness threshold - unknown error.")}}))}SetBrightnessThresholdAsync(e,r,t){return g(this,void 0,void 0,(function*(){var n;try{const s=yield this.GetBrightnessAndWindThresholdAsync(e,r);if(null!=s.Type)return this._logger.Error(S.ServiceName,"Failed to set brightness threshold parameter - cannot get current configuration."),o.nW.Error;yield this._controllerConfigurationService.EnterConfigurationModeAsync();const i=new v;i.DeviceGuid=e.Guid,i.BrightnessThreshold=t,i.WindThreshold=s.WindThreshold;const h=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(i),8e3,!1);return null==h||null==h.Status?(this._logger.Error(S.ServiceName,"Failed to set brightness threshold parameter- unknow error."),o.nW.FatalError):(h.Status!==o.nW.OK&&this._logger.Error(S.ServiceName,`Failed to set brightness threshold parameter, response status: ${h.Status}`),h.Status)}catch(e){return o.nW.FatalError}finally{this._logger.Error(S.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! SetBrightnessThresholdAsync()"),yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}SetWindThresholdAsync(e,r,t){return g(this,void 0,void 0,(function*(){var n;try{const s=yield this.GetBrightnessAndWindThresholdAsync(e,r);if(null!=s.Type)return this._logger.Error(S.ServiceName,"Failed to set wind threshold parameter - cannot get current configuration."),o.nW.Error;yield this._controllerConfigurationService.EnterConfigurationModeAsync();const i=new v;i.DeviceGuid=e.Guid,i.BrightnessThreshold=s.BrightnessThreshold,i.WindThreshold=t;const h=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(i),8e3,!1);return null==h||null==h.Status?(this._logger.Error(S.ServiceName,"Failed to set wind threshold parameter- unknow error."),o.nW.FatalError):(h.Status!==o.nW.OK&&this._logger.Error(S.ServiceName,`Failed to set wind threshold parameter, response status: ${h.Status}`),h.Status)}catch(e){return o.nW.FatalError}finally{this._logger.Error(S.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! SetWindThresholdAsync()"),yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}}S.ServiceName="WszfBidiConfigService";class v extends c{constructor(){super(...arguments),this.DeviceGuid=""}}class m extends o.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/threshold/windbrightness/",this.Method=o.IT.Get,this.Data=e}}class p extends o.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/threshold/windbrightness/",this.Method=o.IT.Put,this.Data=e}}}}]); //# sourceMappingURL=64-exalushome-extalife.bundle.js.map