lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 10.4 kB
JavaScript
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[39],{3196:(t,e,n)=>{n.d(e,{m:()=>c});var r=n(6440),i=n(624),o=n(6532),a=n(9899),s=n(9647),u=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))};class c extends s.c{constructor(){super()}GetServiceName(){return c.ServiceName}GetDimmingAndBrighteningTimeAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{if(!t.Channels.any((t=>t.Number===e)))return new i.tp(s.w.InvalidChannelNumber,`Cannot get dimming and brightening time - invalid channel number, channel: ${e}`);const a=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new d(new o.W(t.Guid,e)),8e3,!1);return null==a||null==a.Status?new i.tp(s.w.OtherError,"Cannot get dimming and brightening time - unknown error."):a.Status!==r.qb.OK?new i.tp(s.w.OtherError,`Cannot get dimming and brightening time - controller responded with error code: ${a.Status}.`):null==a.Data?new i.tp(s.w.NoData,"Cannot get dimming and brightening time - no data in response."):a.Data.State}catch(t){return new i.tp(s.w.OtherError,"Cannot get dimming and brightening time - unknown error.")}}))}SetDimmingAndBrighteningTimeAsync(t,e,n){var i;return u(this,void 0,void 0,(function*(){try{const o=new l;o.DeviceGuid=t.Guid,o.Channel=e,o.State=n;const a=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new h(o),8e3,!1);return null==a||null==a.Status?(this._logger.Error(s.c.ServiceName,"Failed to set dimming and brightening time - unknow error."),r.qb.FatalError):(a.Status!==r.qb.OK&&this._logger.Error(s.c.ServiceName,`Failed to set dimming and brightening time, response status: ${a.Status}`),a.Status)}catch(t){return r.qb.FatalError}}))}GetTurnOffTimeAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{if(!t.Channels.any((t=>t.Number===e)))return new i.tp(s.w.InvalidChannelNumber,`Cannot get turn off time - invalid channel number, channel: ${e}`);const u=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new v(new o.W(t.Guid,e)),8e3,!1);if(null==u||null==u.Status)return new i.tp(s.w.OtherError,"Cannot get turn off time - unknown error.");if(u.Status!==r.qb.OK)return new i.tp(s.w.OtherError,`Cannot get turn off time - controller responded with error code: ${u.Status}.`);if(null==u.Data)return new i.tp(s.w.NoData,"Cannot get turn off time - no data in response.");const c=new a.OL;return c.Channel=u.Data.Channel,c.Time=this.ParseNumberToTime(u.Data.Time),c}catch(t){return new i.tp(s.w.OtherError,"Cannot get turn off time - unknown error.")}}))}SetTurnOffTimeAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{const i=3600*e.Time.Hours+60*e.Time.Minutes+e.Time.Seconds;if(i>240)return this._logger.Error(s.c.ServiceName,"Failed to turn off time - time must be in range between 0 and 240 seconds."),r.qb.WrongData;const o=new m;o.Channel=e.Channel,o.DeviceGuid=t.Guid,o.Time=i;const a=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new p(o),8e3,!1);return null==a||null==a.Status?(this._logger.Error(s.c.ServiceName,"Failed to turn off time - unknow error."),r.qb.FatalError):(a.Status!==r.qb.OK&&this._logger.Error(s.c.ServiceName,`Failed to turn off time, response status: ${a.Status}`),a.Status)}catch(t){return r.qb.FatalError}}))}GetFloatingTimeAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{if(!t.Channels.any((t=>t.Number===e)))return new i.tp(s.w.InvalidChannelNumber,`Cannot floating time - invalid channel number, channel: ${e}`);const u=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new g(new o.W(t.Guid,e)),8e3,!1);if(null==u||null==u.Status)return new i.tp(s.w.OtherError,"Cannot floating time - unknown error.");if(u.Status!==r.qb.OK)return new i.tp(s.w.OtherError,`Cannot floating time - controller responded with error code: ${u.Status}.`);if(null==u.Data)return new i.tp(s.w.NoData,"Cannot floating time - no data in response.");const c=new a.OL;return c.Channel=u.Data.Channel,c.Time=this.ParseNumberToTime(u.Data.Time),c}catch(t){return new i.tp(s.w.OtherError,"Cannot floating time - unknown error.")}}))}SetFloatingTimeAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{const i=3600*e.Time.Hours+60*e.Time.Minutes+e.Time.Seconds;if(i>64800)return this._logger.Error(s.c.ServiceName,"Failed to set floating time - time must be in range between 1s to 18 hours."),r.qb.WrongData;const o=new m;o.Channel=e.Channel,o.DeviceGuid=t.Guid,o.Time=i;const a=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new S(o),8e3,!1);return null==a||null==a.Status?(this._logger.Error(s.c.ServiceName,"Failed to set floating time - unknow error."),r.qb.FatalError):(a.Status!==r.qb.OK&&this._logger.Error(s.c.ServiceName,`Failed to set floating time, response status: ${a.Status}`),a.Status)}catch(t){return r.qb.FatalError}}))}GetTurnOnOffTimeActivationAsync(t){var e;return u(this,void 0,void 0,(function*(){try{const n=yield null===(e=this._connection)||void 0===e?void 0:e.SendAndWaitForResponseAsync(new w(t.Guid),8e3,!1);return null==n||null==n.Status?new i.tp(s.w.OtherError,"Cannot get turn on/off time activation - unknown error."):n.Status!==r.qb.OK?new i.tp(s.w.OtherError,`Cannot get turn on/off time activation - controller responded with error code: ${n.Status}.`):null==n.Data?new i.tp(s.w.NoData,"Cannot get turn on/off time activation - no data in response."):n.Data}catch(t){return new i.tp(s.w.OtherError,"Cannot get turn on/off time activation - unknown error.")}}))}SetTurnOnOffTimeActivationAsync(t,e){var n;return u(this,void 0,void 0,(function*(){try{const i=new f;i.DeviceGuid=t.Guid,i.Active=e;const o=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new O(i),8e3,!1);return null==o||null==o.Status?(this._logger.Error(s.c.ServiceName,"Failed to set turn on/off time activation - unknow error."),r.qb.FatalError):o.Status}catch(t){return this._logger.Error(s.c.ServiceName,`Failed to set turn on/off time activation, error: ${t}`),r.qb.FatalError}}))}}c.ServiceName="LedControllerService";class l{constructor(){this.Channel=0,this.DeviceGuid="",this.State=0,this.StateOptional=0}}class d extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/brightening/time",this.Method=r.n$.Get,this.Data=t}}class h extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/brightening/time",this.Method=r.n$.Put,this.Data=t}}class m{constructor(){this.Channel=0,this.DeviceGuid="",this.Time=0}}class f{constructor(){this.DeviceGuid="",this.Active=!1}}class v extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/device/off/time",this.Method=r.n$.Get,this.Data=t}}class p extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/device/off/time",this.Method=r.n$.Put,this.Data=t}}class g extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/device/floating/time",this.Method=r.n$.Get,this.Data=t}}class S extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/device/floating/time",this.Method=r.n$.Put,this.Data=t}}class w extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/activation/onoff/times",this.Method=r.n$.Get,this.Data=t}}class O extends r.NE{constructor(t){super(),this.Resource="/extalife/device/parameters/activation/onoff/times",this.Method=r.n$.Put,this.Data=t}}},5039:(t,e,n)=>{n.r(e),n.d(e,{Sln21ConfigService:()=>u});var r=n(6440),i=n(3196),o=n(9899),a=n(9647),s=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))};class u extends i.m{constructor(){super()}GetServiceName(){return u.ServiceName}SetTurnOnTimeAsync(t,e){const n=Object.create(null,{SetTurnOnTimeAsync:{get:()=>super.SetTurnOnTimeAsync}});return s(this,void 0,void 0,(function*(){return e.Time.Hours>0||e.Time.Minutes>4||e.Time.Minutes>=4&&e.Time.Seconds>0?(this._logger.Error(a.c.ServiceName,"Failed to turn on time - time must be in range between 0 and 240 seconds."),r.qb.WrongData):n.SetTurnOnTimeAsync.call(this,t,e)}))}SetSwitchInputOutputParamAsync(t,e){const n=Object.create(null,{GetSwitchInputOutputParamAsync:{get:()=>super.GetSwitchInputOutputParamAsync},SetSwitchInputOutputParamAsync:{get:()=>super.SetSwitchInputOutputParamAsync}});return s(this,void 0,void 0,(function*(){if(e.ReactionToInput==o.M5.Off||e.ReactionToInput==o.M5.On||e.ReactionToInput==o.M5.OnOff||e.ReactionToInput==o.M5.None){if(e.InputMode==o.NL.Bistable){let i=yield n.GetSwitchInputOutputParamAsync.call(this,t,e.Channel);if(null!=i.Type)return this._logger.Error(a.c.ServiceName,"Failed to get current configuration of SLR-21"),r.qb.Error;let s=i.firstOrDefault((t=>t.InputChannel==e.InputChannel));if(null==s)return r.qb.Error;if(e.ReactionToInput!=o.M5.None&&s.ReactionToInput!=e.ReactionToInput)return this._logger.Error(a.c.ServiceName,"Failed to set input/output parameters - reaction to input cannot be change when mode is Bistable."),r.qb.WrongData;e.ReactionToInput=s.ReactionToInput}return n.SetSwitchInputOutputParamAsync.call(this,t,e)}return this._logger.Error(a.c.ServiceName,"Failed to set reaction to input, SLR-21 allows to set: On, Off or OnOff"),r.qb.WrongData}))}SetSwitchInputOutputReactionToInputParamAsync(t,e){const n=Object.create(null,{SetSwitchInputOutputReactionToInputParamAsync:{get:()=>super.SetSwitchInputOutputReactionToInputParamAsync}});return s(this,void 0,void 0,(function*(){return e.ReactionToInput==o.M5.Off||e.ReactionToInput==o.M5.On||e.ReactionToInput==o.M5.OnOff?(this._logger.Error(a.c.ServiceName,"Failed to set reaction to input, SLR-21 allows to set: On, Off or OnOff"),r.qb.WrongData):n.SetSwitchInputOutputReactionToInputParamAsync.call(this,t,e)}))}}u.ServiceName="Sln21ConfigService"}}]);
//# sourceMappingURL=39-exalushome-extalife.bundle.js.map