lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 7.41 kB
JavaScript
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[673],{2673:(e,n,t)=>{t.r(n),t.d(n,{Rcz21ConfigService:()=>S});var r,o,i=t(1061),a=t(9595),s=t(4756),c=t(6030),l=t(3956);class d extends l.B{constructor(){super(...arguments),this.AlertMode=r.AlarmAndLed,this.RepeatFloodEvent=!1,this.RepeatFloodEventTime=900,this.WorkingMode=o.FloodSensor,this.SyncTime=720}}!function(e){e[e.None=0]="None",e[e.Alarm=1]="Alarm",e[e.Led=2]="Led",e[e.AlarmAndLed=3]="AlarmAndLed"}(r||(r={})),function(e){e[e.FloodSensor=0]="FloodSensor",e[e.PulseSensor=1]="PulseSensor"}(o||(o={}));var u=t(161),v=t(6823),h=t(9592),m=function(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,s)}c((r=r.apply(e,n||[])).next())}))};class S{constructor(){this._connection=null,this._connection=i.j.Get(a.G.ServiceName)}GetServiceName(){return S.ServiceName}GetAllParamsAsync(e,n){return m(this,void 0,void 0,(function*(){var n;const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(e.Guid),35e3,!1);if(null==t)return new v.ZR(c.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(t.Status){case s.nW.OK:if(null!=t.Data)return t.Data;break;case s.nW.ResourceIsNotAvailable:return new v.ZR(c.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new v.ZR(c.m.OtherError,`Failed to retrieve parameters, response error: ${t.Status} data: ${t.Data}`)}))}SetAllParamsAsync(e,n){return m(this,void 0,void 0,(function*(){var n,t,r;const o=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new g(e),35e3,!1);return null==o||null==o.Status?(null===(t=u.h.Log)||void 0===t||t.Error(S.ServiceName,"Failed to change device parameters - unknow error."),s.nW.FatalError):(o.Status!==s.nW.OK&&(null===(r=u.h.Log)||void 0===r||r.Error(S.ServiceName,`Failed to change device parameters, response status: ${o.Status}`)),o.Status)}))}SetFloodAlertModeAsync(e,n,t){return m(this,void 0,void 0,(function*(){var n,r,o,i,a;try{const a=yield this.GetCurrentConfig(e.Guid);let c=new d;if(null===a)return null===(n=u.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),s.nW.ResourceIsNotAvailable;c.DeviceGuid=e.Guid,c.AlertMode=t,c.RepeatFloodEvent=a.RepeatFloodEvent,c.RepeatFloodEventTime=a.RepeatFloodEventTime,c.SyncTime=a.SyncTime,c.WorkingMode=a.WorkingMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(c),35e3,!1);return null==l||null==l.Status?(null===(o=u.h.Log)||void 0===o||o.Error(S.ServiceName,"Failed to change device parameters - unknow error."),s.nW.FatalError):(l.Status!==s.nW.OK&&(null===(i=u.h.Log)||void 0===i||i.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(a=u.h.Log)||void 0===a||a.Error(S.ServiceName,`Cannot change device parameters. ${e}`),s.nW.FatalError}}))}SetFloodEventRepetitionAsync(e,n,t){return m(this,void 0,void 0,(function*(){var n,r,o,i,a;try{const a=yield this.GetCurrentConfig(e.Guid);let c=new d;if(null===a)return null===(n=u.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device."),s.nW.ResourceIsNotAvailable;c.DeviceGuid=e.Guid,c.RepeatFloodEvent=t,c.AlertMode=a.AlertMode,c.RepeatFloodEventTime=a.RepeatFloodEventTime,c.SyncTime=a.SyncTime,c.WorkingMode=a.WorkingMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(c),35e3,!1);return null==l||null==l.Status?(null===(o=u.h.Log)||void 0===o||o.Error(S.ServiceName,"Failed to change device parameters - unknow error."),s.nW.FatalError):(l.Status!==s.nW.OK&&(null===(i=u.h.Log)||void 0===i||i.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(a=u.h.Log)||void 0===a||a.Error(S.ServiceName,`Cannot change device parameters. ${e}`),s.nW.FatalError}}))}SetFloodEventRepetitionTimeAsync(e,n,t){return m(this,void 0,void 0,(function*(){var n,r,o,i,a;try{const a=yield this.GetCurrentConfig(e.Guid);let c=new d;if(null===a)return null===(n=u.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),s.nW.ResourceIsNotAvailable;c.DeviceGuid=e.Guid,c.RepeatFloodEventTime=t,c.AlertMode=a.AlertMode,c.RepeatFloodEvent=a.RepeatFloodEvent,c.SyncTime=a.SyncTime,c.WorkingMode=a.WorkingMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(c),35e3,!1);return null==l||null==l.Status?(null===(o=u.h.Log)||void 0===o||o.Error(S.ServiceName,"Failed to change device parameters - unknow error."),s.nW.FatalError):(l.Status!==s.nW.OK&&(null===(i=u.h.Log)||void 0===i||i.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(a=u.h.Log)||void 0===a||a.Error(S.ServiceName,`Cannot change device parameters. ${e}`),s.nW.FatalError}}))}SetSynchronizationTimeAsync(e,n,t){return m(this,void 0,void 0,(function*(){var n,r,o,i,a;try{const a=yield this.GetCurrentConfig(e.Guid);let c=new d;if(null===a)return null===(n=u.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),s.nW.ResourceIsNotAvailable;c.DeviceGuid=e.Guid,c.SyncTime=t,c.AlertMode=a.AlertMode,c.RepeatFloodEvent=a.RepeatFloodEvent,c.RepeatFloodEventTime=a.RepeatFloodEventTime,c.WorkingMode=a.WorkingMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(c),35e3,!1);return null==l||null==l.Status?(null===(o=u.h.Log)||void 0===o||o.Error(S.ServiceName,"Failed to change device parameters - unknow error."),s.nW.FatalError):(l.Status!==s.nW.OK&&(null===(i=u.h.Log)||void 0===i||i.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(a=u.h.Log)||void 0===a||a.Error(S.ServiceName,`Cannot change device parameters. ${e}`),s.nW.FatalError}}))}GetCurrentConfig(e){return m(this,void 0,void 0,(function*(){var n;const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(e),35e3,!1);if(null==t)return null;switch(t.Status){case s.nW.OK:if(null!=t.Data)return t.Data;break;case s.nW.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device!")}))}}S.ServiceName="Rcz21ConfigService";class p extends s.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/floodsensor",this.Method=s.IT.Get,this.Data=new h.o(e)}}class g extends s.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/floodsensor",this.Method=s.IT.Put,this.Data=e}}},3956:(e,n,t)=>{t.d(n,{B:()=>r});class r{constructor(){this.DeviceGuid=""}}},9592:(e,n,t)=>{t.d(n,{o:()=>r,z:()=>o});class r{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class o{constructor(e,n){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=n}}}}]);
//# sourceMappingURL=673-exalushome-extalife.bundle.js.map