lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 6.5 kB
JavaScript
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[327],{7171:(e,n,t)=>{t.d(n,{v:()=>r});class r{constructor(){this.DeviceGuid=""}}},6532:(e,n,t)=>{t.d(n,{W:()=>i,_:()=>r});class r{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class i{constructor(e,n){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=n}}},1327:(e,n,t)=>{t.r(n),t.d(n,{Rck21ConfigService:()=>g});var r,i=t(5046),o=t(6895),a=t(6440),c=t(7171);class s extends c.v{constructor(){super(...arguments),this.ReedSwitchMode=r.ShortingOnOpeningOff,this.SyncTime=720,this.LogicNegation=!1}}!function(e){e[e.TimeConditionMode=1]="TimeConditionMode",e[e.ShortingSwitchOpeningNoResp=2]="ShortingSwitchOpeningNoResp",e[e.ShortingOnOpeningOff=3]="ShortingOnOpeningOff",e[e.ShortingOffOpeningOn=4]="ShortingOffOpeningOn",e[e.ShortingOnOpeningNoResp=5]="ShortingOnOpeningNoResp",e[e.ShortingOffOpeningNoResp=6]="ShortingOffOpeningNoResp",e[e.ShortingNoRespOpeningOn=7]="ShortingNoRespOpeningOn",e[e.ShortingNoRespOpeningOff=8]="ShortingNoRespOpeningOff",e[e.ShortingNoRespOpeningSwitch=9]="ShortingNoRespOpeningSwitch",e[e.RevertTimeConditionMode=10]="RevertTimeConditionMode"}(r||(r={}));var u=t(9897),d=t(8308),l=t(624),v=t(6532),h=function(e,n,t,r){return new(t||(t=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}s((r=r.apply(e,n||[])).next())}))};class g{constructor(){this._connection=null,this._connection=i.V.Get(o.c.ServiceName)}GetServiceName(){return g.ServiceName}GetAllParamsAsync(e,n){var t;return h(this,void 0,void 0,(function*(){const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new S(e.Guid),35e3,!1);if(null==n)return new l.tp(d.v.UnknownError,"Failed to retrieve parameters - unknow error.");switch(n.Status){case a.qb.OK:if(null!=n.Data)return n.Data;break;case a.qb.ResourceIsNotAvailable:return new l.tp(d.v.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new l.tp(d.v.OtherError,`Failed to retrieve parameters, response error: ${n.Status} data: ${n.Data}`)}))}SetAllParamsAsync(e,n){var t,r,i;return h(this,void 0,void 0,(function*(){const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new p(e),35e3,!1);return null==n||null==n.Status?(null===(r=u.Q.Log)||void 0===r||r.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.qb.FatalError):(n.Status!==a.qb.OK&&(null===(i=u.Q.Log)||void 0===i||i.Error(g.ServiceName,`Failed to change device parameters, response status: ${n.Status}`)),n.Status)}))}SetReedSwitchOperationModeAsync(e,n,t){var r,i,o,c,d;return h(this,void 0,void 0,(function*(){try{const n=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===n)return null===(r=u.Q.Log)||void 0===r||r.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.qb.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=n.LogicNegation,d.SyncTime=n.SyncTime,d.ReedSwitchMode=t;const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(o=u.Q.Log)||void 0===o||o.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.qb.FatalError):(l.Status!==a.qb.OK&&(null===(c=u.Q.Log)||void 0===c||c.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(d=u.Q.Log)||void 0===d||d.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.qb.FatalError}}))}SetSynchronizationTimeAsync(e,n,t){var r,i,o,c,d;return h(this,void 0,void 0,(function*(){try{const n=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===n)return null===(r=u.Q.Log)||void 0===r||r.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.qb.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=n.LogicNegation,d.SyncTime=t,d.ReedSwitchMode=n.ReedSwitchMode;const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(o=u.Q.Log)||void 0===o||o.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.qb.FatalError):(l.Status!==a.qb.OK&&(null===(c=u.Q.Log)||void 0===c||c.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(d=u.Q.Log)||void 0===d||d.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.qb.FatalError}}))}SetLogicNegationAsync(e,n,t){var r,i,o,c,d;return h(this,void 0,void 0,(function*(){try{const n=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===n)return null===(r=u.Q.Log)||void 0===r||r.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.qb.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=t,d.SyncTime=n.SyncTime,d.ReedSwitchMode=n.ReedSwitchMode;const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(o=u.Q.Log)||void 0===o||o.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.qb.FatalError):(l.Status!==a.qb.OK&&(null===(c=u.Q.Log)||void 0===c||c.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(d=u.Q.Log)||void 0===d||d.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.qb.FatalError}}))}GetCurrentConfig(e){var n;return h(this,void 0,void 0,(function*(){const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e),35e3,!1);if(null==t)return null;switch(t.Status){case a.qb.OK:if(null!=t.Data)return t.Data;break;case a.qb.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device! No data in response.")}))}}g.ServiceName="Rck21ConfigService";class S extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/reedswitch",this.Method=a.n$.Get,this.Data=new v._(e)}}class p extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/reedswitch",this.Method=a.n$.Put,this.Data=e}}}}]);
//# sourceMappingURL=327-exalushome-extalife.bundle.js.map