UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 6.88 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[484],{8484:(e,t,n)=>{n.r(t),n.d(t,{SbrConfigService:()=>m});var o=n(6823),r=n(6030);class i{constructor(){this.DeviceGuid="",this.TimeInMiliseconds=0,this.ResetOnCrossToOn=!1}}class s{constructor(){this.DeviceGuid="",this.LightDelayInMiliseconds=0}}class a{constructor(){this.DeviceGuid="",this.LightDurationInMiliseconds=0}}var c=n(1061),u=n(9595),l=n(4268),d=n(3386),h=n(4756),v=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};class m{constructor(){this._connection=c.j.Get(u.G.ServiceName),this._logger=c.j.Get(l.g.ServiceName),this._controllerConfigurationService=c.j.Get(d.u.ServiceName)}GetServiceName(){return m.ServiceName}SetAutoCloseTimeAsync(e,t,n){return v(this,void 0,void 0,(function*(){var r;try{if(t<6e4||t>36e5)return new o.ZR(o.Ao.WrongData,"Cannot set auto close time - invalid value. Time must be in range from 60_000 to 3_600_000 ms.");this._controllerConfigurationService.EnterConfigurationModeAsync();const i=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new w(e,t,n),8e3,!1);return this._logger.Error(m.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! SetAutoCloseTimeAsync()"),this._controllerConfigurationService.ExitConfigurationModeAsync(),null==i||null==i.Status?new o.ZR(o.Ao.UnknownError,"Cannot set auto close time - unknown error."):i.Status!==h.nW.OK?new o.ZR(o.Ao.UnknownError,`Cannot set auto close time - controller responded with error code: ${i.Status}.`):new o.ZR(o.Ao.Changed,"Auto close time set successfully.")}catch(e){return new o.ZR(o.Ao.UnknownError,"Cannot get auto close time - unknown error.")}}))}GetAutoCloseTimeAsync(e){return v(this,void 0,void 0,(function*(){var t;try{const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new g(e),8e3,!1);return(null==n?void 0:n.Status)===h.nW.OK?n.Data:new o.ZR(r.m.UnknownError,"Cannot get auto close time")}catch(e){return new o.ZR(r.m.UnknownError,`Cannot get auto close time error: ${e}`)}}))}SetAlarmLightDelayAsync(e,t){return v(this,void 0,void 0,(function*(){var n;try{if(t<0||t>12e4)return new o.ZR(o.Ao.WrongData,"Cannot set light delay time - invalid value. Time must be in range from 60_000 to 3_600_000 ms.");this._controllerConfigurationService.EnterConfigurationModeAsync();const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new A(e,t),8e3,!1);return this._logger.Error(m.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! SetAlarmLightDelayAsync()"),this._controllerConfigurationService.ExitConfigurationModeAsync(),null==r||null==r.Status?new o.ZR(o.Ao.UnknownError,"Cannot set light delay time - unknown error."):r.Status!==h.nW.OK?new o.ZR(o.Ao.UnknownError,`Cannot set light delay time - controller responded with error code: ${r.Status}.`):new o.ZR(o.Ao.Changed,"Light delay set successfully.")}catch(e){return new o.ZR(o.Ao.UnknownError,"Cannot get light delay time - unknown error.")}}))}GetAlarmLightDelayAsync(e){return v(this,void 0,void 0,(function*(){var t;try{const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new y(e),8e3,!1);return(null==n?void 0:n.Status)===h.nW.OK?n.Data:new o.ZR(r.m.UnknownError,"Cannot get light delay time")}catch(e){return new o.ZR(r.m.UnknownError,`Cannot get auto light delay error: ${e}`)}}))}SetAlarmLightDurationAsync(e,t){return v(this,void 0,void 0,(function*(){var n;try{if(t<0||t>36e5)return new o.ZR(o.Ao.WrongData,"Cannot set alarm light duration time - invalid value. Time must be in range from 60_000 to 3_600_000 ms.");this._controllerConfigurationService.EnterConfigurationModeAsync();const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new f(e,t),8e3,!1);return this._logger.Error(m.ServiceName,"EXIT CONFIGURATION MODE WILL BE FIRED! SetAlarmLightDurationAsync()"),this._controllerConfigurationService.ExitConfigurationModeAsync(),null==r||null==r.Status?new o.ZR(o.Ao.UnknownError,"Cannot set alarm light duration time - unknown error."):r.Status!==h.nW.OK?new o.ZR(o.Ao.UnknownError,`Cannot set alarm light duration time - controller responded with error code: ${r.Status}.`):new o.ZR(o.Ao.Changed,"Alarm light duration set successfully.")}catch(e){return new o.ZR(o.Ao.UnknownError,"Cannot get alarm light duration time - unknown error.")}}))}GetAlarmLightDurationAsync(e){return v(this,void 0,void 0,(function*(){var t;try{const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new C(e),8e3,!1);return(null==n?void 0:n.Status)===h.nW.OK?n.Data:new o.ZR(r.m.UnknownError,"Cannot get light delay time")}catch(e){return new o.ZR(r.m.UnknownError,`Cannot get auto light delay error: ${e}`)}}))}GetServiceInfoAsync(e){return v(this,void 0,void 0,(function*(){var t;try{const n=yield null===(t=this._connection)||void 0===t?void 0:t.SendAndWaitForResponseAsync(new D(e),8e3,!1);return(null==n?void 0:n.Status)===h.nW.OK?n.Data:new o.ZR(r.m.UnknownError,`Cannot get service info, response status: ${null==n?void 0:n.Status}`)}catch(e){return new o.ZR(r.m.UnknownError,`Cannot get service info error: ${e}`)}}))}}m.ServiceName="SbrConfigService";class g extends h.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/sbr/autoclosetime",this.Method=h.IT.Get,this.Data=e.GetDevice().Guid}}class w extends h.CP{constructor(e,t,n){super(),this.Resource="/extalife/device/parameters/sbr/autoclosetime",this.Method=h.IT.Put,this.Data=new i,this.Data.DeviceGuid=e.GetDevice().Guid,this.Data.TimeInMiliseconds=t,this.Data.ResetOnCrossToOn=n}}class y extends h.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/sbr/alarmlightdelay",this.Method=h.IT.Get,this.Data=e.GetDevice().Guid}}class A extends h.CP{constructor(e,t){super(),this.Resource="/extalife/device/parameters/sbr/alarmlightdelay",this.Method=h.IT.Put,this.Data=new s,this.Data.DeviceGuid=e.GetDevice().Guid,this.Data.LightDelayInMiliseconds=t}}class C extends h.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/sbr/lightduration",this.Method=h.IT.Get,this.Data=e.GetDevice().Guid}}class f extends h.CP{constructor(e,t){super(),this.Resource="/extalife/device/parameters/sbr/lightduration",this.Method=h.IT.Put,this.Data=new a,this.Data.DeviceGuid=e.GetDevice().Guid,this.Data.LightDurationInMiliseconds=t}}class D extends h.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/sbr/serviceinfo",this.Method=h.IT.Get,this.Data=e.GetDevice().Guid}}}}]); //# sourceMappingURL=484-exalushome-extalife.bundle.js.map