UNPKG

lavva.exalushome.extalife

Version:

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

2 lines 13.2 kB
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[513],{2513:(e,r,t)=>{t.r(r),t.d(r,{Rcr21ConfigService:()=>S});var n,o,a,i=t(1061),c=t(9595),s=t(6823),u=t(3956);u.B,u.B,function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(n||(n={})),function(e){e[e.NoBrightnessSensor=0]="NoBrightnessSensor",e[e.NightMode=1]="NightMode",e[e.DayMode=2]="DayMode"}(o||(o={})),function(e){e[e.NO=0]="NO",e[e.NC=1]="NC",e[e.Disable=2]="Disable"}(a||(a={}));var l=t(6030),d=t(4756),v=t(9592),h=t(161),m=function(e,r,t,n){return new(t||(t=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,c)}s((n=n.apply(e,r||[])).next())}))};class S{constructor(){this._connection=null,this._connection=i.j.Get(c.G.ServiceName)}GetServiceName(){return S.ServiceName}GetPirSensorParamsAsync(e,r){return m(this,void 0,void 0,(function*(){var r;const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(e.Guid),35e3,!1);if(null==t)return new s.ZR(l.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(t.Status){case d.nW.OK:if(null!=t.Data)return t.Data;break;case d.nW.ResourceIsNotAvailable:return new s.ZR(l.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new s.ZR(l.m.OtherError,`Failed to retrieve parameters, response error: ${t.Status} data: ${t.Data}`)}))}SetDetectionThresholdAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentPirParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;if(0!=o.PredefinedSettings)return d.nW.OperationNotPermitted;const a=Object.assign({},o);return a.DetectionThreshold=t,this.SetPirSensorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetWindowTimeAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentPirParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;if(0!=o.PredefinedSettings)return d.nW.OperationNotPermitted;const a=Object.assign({},o);return a.WindowTime=t,this.SetPirSensorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetDetectionAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentPirParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;if(0!=o.PredefinedSettings)return d.nW.OperationNotPermitted;const a=Object.assign({},o);return a.Detection=t,this.SetPirSensorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetPredefinedSettingsAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentPirParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.PredefinedSettings=t,0===t&&(a.DetectionThreshold>=1?a.DetectionThreshold--:a.DetectionThreshold++),this.SetPirSensorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}GetMovementDetectorParamsAsync(e,r){return m(this,void 0,void 0,(function*(){var r;const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new y(e.Guid),35e3,!1);if(null==t)return new s.ZR(l.m.UnknownError,"Failed to retrieve parameters - unknow error.");switch(t.Status){case d.nW.OK:if(null!=t.Data)return t.Data.SensorMode==o.DayMode&&(t.Data.CurrentLuxValue-=65),t.Data;break;case d.nW.ResourceIsNotAvailable:return new s.ZR(l.m.ResourceIsNotAvailable,"Failed to retrieve parameters - cannot communicate with the device.")}return new s.ZR(l.m.OtherError,`Failed to retrieve parameters, response error: ${t.Status} data: ${t.Data}`)}))}SetOffTimeAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;if(t<10||t>3600)return d.nW.WrongData;const a=Object.assign({},o);return a.OffTime=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetLuxSettingAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.LuxSetting=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetSynchronizationTimeAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.SyncTime=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetAccTamperEventAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.AccEvent=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetAccLevelAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.AccLevel=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetSensorModeAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.SensorMode=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetExternalOutModeAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.ExternalOutMode=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetOpticalLEDSignalizationAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.OpticalLEDSignalization=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}SetMoveLEDSignalizationAsync(e,r,t){return m(this,void 0,void 0,(function*(){var n,o;try{const o=yield this.GetCurrentMovementDetectorParamsAsync(e.Guid);if(null===o)return null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,"Failed to change device parameters - cannot read current configuration of device"),d.nW.ResourceIsNotAvailable;const a=Object.assign({},o);return a.MoveLEDSignalization=t,this.SetMovementDetectorParamsAsync(a,r)}catch(e){return null===(o=h.h.Log)||void 0===o||o.Error(S.ServiceName,`Cannot change device parameters. ${e}`),d.nW.FatalError}}))}GetCurrentPirParamsAsync(e){return m(this,void 0,void 0,(function*(){var r;const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new g(e),35e3,!1);if(null==t)return null;switch(t.Status){case d.nW.OK:if(null!=t.Data)return t.Data;break;case d.nW.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device! No data in response.")}))}GetCurrentMovementDetectorParamsAsync(e){return m(this,void 0,void 0,(function*(){var r;const t=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new y(e),35e3,!1);if(null==t)return null;switch(t.Status){case d.nW.OK:if(null!=t.Data)return t.Data;break;case d.nW.ResourceIsNotAvailable:return null}throw new Error("Failed to read current configuration of device! No data in response.")}))}SetPirSensorParamsAsync(e,r){return m(this,void 0,void 0,(function*(){var r,t,n;const o=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new f(e),35e3,!1);return null==o||null==o.Status?(null===(t=h.h.Log)||void 0===t||t.Error(S.ServiceName,"Failed to change device parameters - unknow error."),d.nW.FatalError):(o.Status!==d.nW.OK&&(null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,`Failed to change device parameters, response status: ${o.Status}`)),o.Status)}))}SetMovementDetectorParamsAsync(e,r){return m(this,void 0,void 0,(function*(){var r,t,n;const o=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new A(e),35e3,!1);return null==o||null==o.Status?(null===(t=h.h.Log)||void 0===t||t.Error(S.ServiceName,"Failed to change device parameters - unknow error."),d.nW.FatalError):(o.Status!==d.nW.OK&&(null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,`Failed to change device parameters, response status: ${o.Status}`)),o.Status)}))}ClearTamperAlarmAsync(e,r){return m(this,void 0,void 0,(function*(){var r,t,n;const o=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new p(e.Guid),35e3,!1);return null==o||null==o.Status?(null===(t=h.h.Log)||void 0===t||t.Error(S.ServiceName,"Failed to clear tamper alarm - unknow error."),d.nW.FatalError):(o.Status!==d.nW.OK&&(null===(n=h.h.Log)||void 0===n||n.Error(S.ServiceName,`Failed to clear tamper alarm, response status: ${o.Status}`)),o.Status)}))}}S.ServiceName="Rcr21ConfigService";class g extends d.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/movementsensor/pir",this.Method=d.IT.Get,this.Data=new v.o(e)}}class f extends d.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/movementsensor/pir",this.Method=d.IT.Put,this.Data=e}}class y extends d.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/movementsensor/movementdetector",this.Method=d.IT.Get,this.Data=new v.o(e)}}class A extends d.CP{constructor(e){super(),this.Resource="/extalife/device/parameters/movementsensor/movementdetector",this.Method=d.IT.Put,this.Data=e}}class p extends d.CP{constructor(e){super(),this.Resource="/extalife/device/movementsensor/tamper/clear",this.Method=d.IT.Post,this.Data=new v.o(e)}}},3956:(e,r,t)=>{t.d(r,{B:()=>n});class n{constructor(){this.DeviceGuid=""}}},9592:(e,r,t)=>{t.d(r,{o:()=>n,z:()=>o});class n{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class o{constructor(e,r){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=r}}}}]); //# sourceMappingURL=513-exalushome-extalife.bundle.js.map