UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 6.5 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[656],{3656:(e,n,t)=>{t.r(n),t.d(n,{Rck21ConfigService:()=>g});var r,i=t(1061),o=t(9595),a=t(4756),c=t(3956);class s extends c.B{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(161),d=t(6030),l=t(6823),h=t(9592),v=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.j.Get(o.G.ServiceName)}GetServiceName(){return g.ServiceName}GetAllParamsAsync(e,n){return v(this,void 0,void 0,(function*(){var n;const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(e.Guid),35e3,!1);if(null==t)return new l.ZR(d.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(t.Status){case a.nW.OK:if(null!=t.Data)return t.Data;break;case a.nW.ResourceIsNotAvailable:return new l.ZR(d.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new l.ZR(d.m.OtherError,`Failed to retrieve parameters, response error: ${t.Status} data: ${t.Data}`)}))}SetAllParamsAsync(e,n){return v(this,void 0,void 0,(function*(){var n,t,r;const i=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(e),35e3,!1);return null==i||null==i.Status?(null===(t=u.h.Log)||void 0===t||t.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(i.Status!==a.nW.OK&&(null===(r=u.h.Log)||void 0===r||r.Error(g.ServiceName,`Failed to change device parameters, response status: ${i.Status}`)),i.Status)}))}SetReedSwitchOperationModeAsync(e,n,t){return v(this,void 0,void 0,(function*(){var n,r,i,o,c;try{const c=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===c)return null===(n=u.h.Log)||void 0===n||n.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.nW.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=c.LogicNegation,d.SyncTime=c.SyncTime,d.ReedSwitchMode=t;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(i=u.h.Log)||void 0===i||i.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(l.Status!==a.nW.OK&&(null===(o=u.h.Log)||void 0===o||o.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(c=u.h.Log)||void 0===c||c.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}SetSynchronizationTimeAsync(e,n,t){return v(this,void 0,void 0,(function*(){var n,r,i,o,c;try{const c=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===c)return null===(n=u.h.Log)||void 0===n||n.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.nW.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=c.LogicNegation,d.SyncTime=t,d.ReedSwitchMode=c.ReedSwitchMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(i=u.h.Log)||void 0===i||i.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(l.Status!==a.nW.OK&&(null===(o=u.h.Log)||void 0===o||o.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(c=u.h.Log)||void 0===c||c.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}SetLogicNegationAsync(e,n,t){return v(this,void 0,void 0,(function*(){var n,r,i,o,c;try{const c=yield this.GetCurrentConfig(e.Guid);let d=new s;if(null===c)return null===(n=u.h.Log)||void 0===n||n.Error(g.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),a.nW.ResourceIsNotAvailable;d.DeviceGuid=e.Guid,d.LogicNegation=t,d.SyncTime=c.SyncTime,d.ReedSwitchMode=c.ReedSwitchMode;const l=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new p(d),35e3,!1);return null==l||null==l.Status?(null===(i=u.h.Log)||void 0===i||i.Error(g.ServiceName,"Failed to change device parameters - unknow error."),a.nW.FatalError):(l.Status!==a.nW.OK&&(null===(o=u.h.Log)||void 0===o||o.Error(g.ServiceName,`Failed to change device parameters, response status: ${l.Status}`)),l.Status)}catch(e){return null===(c=u.h.Log)||void 0===c||c.Error(g.ServiceName,`Cannot change device parameters. ${e}`),a.nW.FatalError}}))}GetCurrentConfig(e){return v(this,void 0,void 0,(function*(){var n;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.nW.OK:if(null!=t.Data)return t.Data;break;case a.nW.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device! No data in response.")}))}}g.ServiceName="Rck21ConfigService";class S extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/reedswitch",this.Method=a.IT.Get,this.Data=new h.o(e)}}class p extends a.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/reedswitch",this.Method=a.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:()=>i});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}}}}]); //# sourceMappingURL=656-exalushome-extalife.bundle.js.map