lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 10.4 kB
JavaScript
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[788],{788:(e,t,n)=>{n.r(t),n.d(t,{Rcm21ConfigService:()=>G});var r,a=n(4756),s=n(161),i=n(6823),o=n(6030),c=n(3956);class u extends c.B{constructor(){super(...arguments),this.Channel=r.Unknow,this.Threshold=0,this.Hysteresis=!1,this.IsHysteresisOptionAvailable=!1,this.IsOffsetOptionAvailable=!1}}class l extends c.B{constructor(){super(...arguments),this.Interval=0}}class d extends c.B{constructor(){super(...arguments),this.Channel=r.Unknow,this.Offset=0}}!function(e){e[e.Unknow=0]="Unknow",e[e.TemperatureChannel=1]="TemperatureChannel",e[e.HuminidityChannel=2]="HuminidityChannel",e[e.PressureChannel=3]="PressureChannel",e[e.BrightnessChannel=4]="BrightnessChannel"}(r||(r={}));var h=n(1061),v=n(9595),m=n(9592),f=function(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function o(e){try{c(r.throw(e))}catch(e){s(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(i,o)}c((r=r.apply(e,t||[])).next())}))};class p{constructor(){this._connection=null,this._connection=h.j.Get(v.G.ServiceName)}GetDetectionThresholdDataAsync(e,t){return f(this,void 0,void 0,(function*(){var n;const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e.Guid,t.valueOf()),35e3,!1);if(null==r)return new i.ZR(o.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(r.Status){case a.nW.OK:if(null!=r.Data)return r.Data.Threshold=r.Data.Threshold/1e3,r.Data;break;case a.nW.ResourceIsNotAvailable:return new i.ZR(o.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new i.ZR(o.m.OtherError,`Failed to retrieve parameters, response error: ${r.Status} data: ${r.Data}`)}))}SetDetectionThresholdAsync(e,t,n){return f(this,void 0,void 0,(function*(){var i,o,c,l,d;try{switch(t){case r.PressureChannel:if(n<.3||n>30||n*Math.pow(10,1)%1!=0)return a.nW.WrongData;break;case r.HuminidityChannel:if(n<1||n>99||!Number.isInteger(n))return a.nW.WrongData;break;case r.PressureChannel:case r.BrightnessChannel:if(n<1||n>100||!Number.isInteger(n))return a.nW.WrongData;break;default:return a.nW.WrongData}const d=yield this.GetCurrentDetectionThresholdConfigAsync(e.Guid,t.valueOf()),h=new u;if(null===d)return null===(i=s.h.Log)||void 0===i||i.Error(G.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.nW.ResourceIsNotAvailable;h.DeviceGuid=e.Guid,h.Channel=t,h.Hysteresis=d.Hysteresis,h.Threshold=1e3*n;const v=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new y(h),35e3,!1);return null==v||null==v.Status?(null===(c=s.h.Log)||void 0===c||c.Error(G.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(v.Status!==a.nW.OK&&(null===(l=s.h.Log)||void 0===l||l.Error(G.ServiceName,`Failed to change device parameters, response status: ${v.Status}`)),v.Status)}catch(e){return null===(d=s.h.Log)||void 0===d||d.Error(G.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}GetFramesIntervalAsync(e,t){return f(this,void 0,void 0,(function*(){var t;const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new w(e.Guid),35e3,!1);if(null==n)return new i.ZR(o.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(n.Status){case a.nW.OK:if(null!=n.Data)return n.Data;break;case a.nW.ResourceIsNotAvailable:return new i.ZR(o.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new i.ZR(o.m.OtherError,`Failed to retrieve parameters, response error: ${n.Status} data: ${n.Data}`)}))}SetFramesIntervalAsync(e,t,n){return f(this,void 0,void 0,(function*(){var t,r,i,o;try{if(n<1||n>6480)return a.nW.WrongData;const o=new l;o.DeviceGuid=e.Guid,o.Interval=n;const c=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new g(o),35e3,!1);return null==c||null==c.Status?(null===(r=s.h.Log)||void 0===r||r.Error(G.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(c.Status!==a.nW.OK&&(null===(i=s.h.Log)||void 0===i||i.Error(G.ServiceName,`Failed to change device parameters, response status: ${c.Status}`)),c.Status)}catch(e){return null===(o=s.h.Log)||void 0===o||o.Error(G.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}GetCurrentDetectionThresholdConfigAsync(e,t){return f(this,void 0,void 0,(function*(){var n;const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e,t),35e3,!1);if(null==r)return null;switch(r.Status){case a.nW.OK:if(null!=r.Data)return r.Data;break;case a.nW.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device!")}))}}class w extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/multisensor/interval",this.Method=a.IT.Get,this.Data=new m.o(e)}}class S extends a.CP{constructor(e,t){super(),this.Resource="/extalife/device/parameters/multisensor/detectionthreshold",this.Method=a.IT.Get,this.Data=new m.z(e,t)}}class y extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/multisensor/detectionthreshold",this.Method=a.IT.Put,this.Data=e}}class g extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/multisensor/interval",this.Method=a.IT.Put,this.Data=e}}var W=function(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function o(e){try{c(r.throw(e))}catch(e){s(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(i,o)}c((r=r.apply(e,t||[])).next())}))};class D extends p{GetHysteresisAsync(e,t){return W(this,void 0,void 0,(function*(){var n;const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e.Guid,t.valueOf()),35e3,!1);if(null==r)return new i.ZR(o.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(r.Status){case a.nW.OK:if(null!=r.Data)return r.Data.Hysteresis;break;case a.nW.ResourceIsNotAvailable:return new i.ZR(o.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new i.ZR(o.m.OtherError,`Failed to retrieve parameters, response error: ${r.Status} data: ${r.Data}`)}))}SetHysteresisAsync(e,t,n){return W(this,void 0,void 0,(function*(){var i,o,c,l,d;try{if(t==r.Unknow)return a.nW.WrongData;const d=yield this.GetCurrentDetectionThresholdConfigAsync(e.Guid,t);let h=new u;if(null===d)return null===(i=s.h.Log)||void 0===i||i.Error(G.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.nW.ResourceIsNotAvailable;h.DeviceGuid=e.Guid,h.Channel=t,h.Hysteresis=n,h.Threshold=d.Threshold;const v=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new y(h),35e3,!1);return null==v||null==v.Status?(null===(c=s.h.Log)||void 0===c||c.Error(G.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(v.Status!==a.nW.OK&&(null===(l=s.h.Log)||void 0===l||l.Error(G.ServiceName,`Failed to change device parameters, response status: ${v.Status}`)),v.Status)}catch(e){return null===(d=s.h.Log)||void 0===d||d.Error(G.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}}var C=function(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function o(e){try{c(r.throw(e))}catch(e){s(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(i,o)}c((r=r.apply(e,t||[])).next())}))};class R extends D{GetChannelOffsetAsync(e,t){return C(this,void 0,void 0,(function*(){var n;if(t!=r.TemperatureChannel)return new i.ZR(o.m.InvalidChannelNumber,"Failed to retrieve parameters - function not available on selected channel");const s=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new F(e.Guid,t.valueOf()),35e3,!1);if(null==s)return new i.ZR(o.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(s.Status){case a.nW.OK:if(null!=s.Data)return s.Data.Offset=s.Data.Offset/10,s.Data;break;case a.nW.ResourceIsNotAvailable:return new i.ZR(o.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new i.ZR(o.m.OtherError,`Failed to retrieve parameters, response error: ${s.Status} data: ${s.Data}`)}))}SetChannelOffsetAsync(e,t,n){return C(this,void 0,void 0,(function*(){var i,o,c,u;try{if(t!==r.TemperatureChannel)return a.nW.WrongData;if(n<-5||n>5||n*Math.pow(10,1)%1!=0)return a.nW.WrongData;const u=new d;u.DeviceGuid=e.Guid,u.Channel=t,u.Offset=10*n;const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new A(u),35e3,!1);return null==l||null==l.Status?(null===(o=s.h.Log)||void 0===o||o.Error(G.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(l.Status!==a.nW.OK&&(null===(c=s.h.Log)||void 0===c||c.Error(G.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(u=s.h.Log)||void 0===u||u.Error(G.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}}class F extends a.CP{constructor(e,t){super(),this.Resource="/extalife/device/parameters/multisensor/channeloffset",this.Method=a.IT.Get,this.Data=new m.z(e,t)}}class A extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/multisensor/channeloffset",this.Method=a.IT.Put,this.Data=e}}class G extends p{constructor(){super(...arguments),this._services={Rcm21v1_5_0_30:new D,Rcm21v1_6_0_34:new R}}GetServiceName(){return G.ServiceName}VersionedConfigurationOptions(){return{"^1.5.0.30":this._services.Rcm21v1_5_0_30,"^1.6.0.34":this._services.Rcm21v1_6_0_34}}}G.ServiceName="Rcm21ConfigService"},3956:(e,t,n)=>{n.d(t,{B:()=>r});class r{constructor(){this.DeviceGuid=""}}},9592:(e,t,n)=>{n.d(t,{o:()=>r,z:()=>a});class r{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class a{constructor(e,t){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=t}}}}]);
//# sourceMappingURL=788-exalushome-extalife.bundle.js.map