UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 7.41 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[596],{7171:(e,t,r)=>{r.d(t,{v:()=>n});class n{constructor(){this.DeviceGuid=""}}},6532:(e,t,r)=>{r.d(t,{W:()=>o,_:()=>n});class n{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class o{constructor(e,t){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=t}}},3596:(e,t,r)=>{r.r(t),r.d(t,{Rcz21ConfigService:()=>S});var n,o,i=r(5046),a=r(6895),c=r(6440),s=r(8308),l=r(7171);class d extends l.v{constructor(){super(...arguments),this.AlertMode=n.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"}(n||(n={})),function(e){e[e.FloodSensor=0]="FloodSensor",e[e.PulseSensor=1]="PulseSensor"}(o||(o={}));var u=r(9897),v=r(624),h=r(6532),m=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}s((n=n.apply(e,t||[])).next())}))};class S{constructor(){this._connection=null,this._connection=i.V.Get(a.c.ServiceName)}GetServiceName(){return S.ServiceName}GetAllParamsAsync(e,t){var r;return m(this,void 0,void 0,(function*(){const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new p(e.Guid),35e3,!1);if(null==t)return new v.tp(s.v.UnknownError,"Failed to retrieve parameters - unknow error.");switch(t.Status){case c.qb.OK:if(null!=t.Data)return t.Data;break;case c.qb.ResourceIsNotAvailable:return new v.tp(s.v.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new v.tp(s.v.OtherError,`Failed to retrieve parameters, response error: ${t.Status} data: ${t.Data}`)}))}SetAllParamsAsync(e,t){var r,n,o;return m(this,void 0,void 0,(function*(){const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(e),35e3,!1);return null==t||null==t.Status?(null===(n=u.Q.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - unknow error."),c.qb.FatalError):(t.Status!==c.qb.OK&&(null===(o=u.Q.Log)||void 0===o||o.Error(S.ServiceName,`Failed to change device parameters, response status: ${t.Status}`)),t.Status)}))}SetFloodAlertModeAsync(e,t,r){var n,o,i,a,s;return m(this,void 0,void 0,(function*(){try{const t=yield this.GetCurrentConfig(e.Guid);let s=new d;if(null===t)return null===(n=u.Q.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),c.qb.ResourceIsNotAvailable;s.DeviceGuid=e.Guid,s.AlertMode=r,s.RepeatFloodEvent=t.RepeatFloodEvent,s.RepeatFloodEventTime=t.RepeatFloodEventTime,s.SyncTime=t.SyncTime,s.WorkingMode=t.WorkingMode;const l=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new g(s),35e3,!1);return null==l||null==l.Status?(null===(i=u.Q.Log)||void 0===i||i.Error(S.ServiceName,"Failed to change device parameters - unknow error."),c.qb.FatalError):(l.Status!==c.qb.OK&&(null===(a=u.Q.Log)||void 0===a||a.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(s=u.Q.Log)||void 0===s||s.Error(S.ServiceName,`Cannot change device parameters. ${e}`),c.qb.FatalError}}))}SetFloodEventRepetitionAsync(e,t,r){var n,o,i,a,s;return m(this,void 0,void 0,(function*(){try{const t=yield this.GetCurrentConfig(e.Guid);let s=new d;if(null===t)return null===(n=u.Q.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device."),c.qb.ResourceIsNotAvailable;s.DeviceGuid=e.Guid,s.RepeatFloodEvent=r,s.AlertMode=t.AlertMode,s.RepeatFloodEventTime=t.RepeatFloodEventTime,s.SyncTime=t.SyncTime,s.WorkingMode=t.WorkingMode;const l=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new g(s),35e3,!1);return null==l||null==l.Status?(null===(i=u.Q.Log)||void 0===i||i.Error(S.ServiceName,"Failed to change device parameters - unknow error."),c.qb.FatalError):(l.Status!==c.qb.OK&&(null===(a=u.Q.Log)||void 0===a||a.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(s=u.Q.Log)||void 0===s||s.Error(S.ServiceName,`Cannot change device parameters. ${e}`),c.qb.FatalError}}))}SetFloodEventRepetitionTimeAsync(e,t,r){var n,o,i,a,s;return m(this,void 0,void 0,(function*(){try{const t=yield this.GetCurrentConfig(e.Guid);let s=new d;if(null===t)return null===(n=u.Q.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),c.qb.ResourceIsNotAvailable;s.DeviceGuid=e.Guid,s.RepeatFloodEventTime=r,s.AlertMode=t.AlertMode,s.RepeatFloodEvent=t.RepeatFloodEvent,s.SyncTime=t.SyncTime,s.WorkingMode=t.WorkingMode;const l=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new g(s),35e3,!1);return null==l||null==l.Status?(null===(i=u.Q.Log)||void 0===i||i.Error(S.ServiceName,"Failed to change device parameters - unknow error."),c.qb.FatalError):(l.Status!==c.qb.OK&&(null===(a=u.Q.Log)||void 0===a||a.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(s=u.Q.Log)||void 0===s||s.Error(S.ServiceName,`Cannot change device parameters. ${e}`),c.qb.FatalError}}))}SetSynchronizationTimeAsync(e,t,r){var n,o,i,a,s;return m(this,void 0,void 0,(function*(){try{const t=yield this.GetCurrentConfig(e.Guid);let s=new d;if(null===t)return null===(n=u.Q.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),c.qb.ResourceIsNotAvailable;s.DeviceGuid=e.Guid,s.SyncTime=r,s.AlertMode=t.AlertMode,s.RepeatFloodEvent=t.RepeatFloodEvent,s.RepeatFloodEventTime=t.RepeatFloodEventTime,s.WorkingMode=t.WorkingMode;const l=yield null===(o=this._connection)||void 0===o?void 0:o.SendAndWaitForResponseAsync(new g(s),35e3,!1);return null==l||null==l.Status?(null===(i=u.Q.Log)||void 0===i||i.Error(S.ServiceName,"Failed to change device parameters - unknow error."),c.qb.FatalError):(l.Status!==c.qb.OK&&(null===(a=u.Q.Log)||void 0===a||a.Error(S.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(s=u.Q.Log)||void 0===s||s.Error(S.ServiceName,`Cannot change device parameters. ${e}`),c.qb.FatalError}}))}GetCurrentConfig(e){var t;return m(this,void 0,void 0,(function*(){const r=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new p(e),35e3,!1);if(null==r)return null;switch(r.Status){case c.qb.OK:if(null!=r.Data)return r.Data;break;case c.qb.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device!")}))}}S.ServiceName="Rcz21ConfigService";class p extends c.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/floodsensor",this.Method=c.n$.Get,this.Data=new h._(e)}}class g extends c.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/floodsensor",this.Method=c.n$.Put,this.Data=e}}}}]); //# sourceMappingURL=596-exalushome-extalife.bundle.js.map