freeathome-local-api-client 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
A client library for the BUSCH-JAEGER free@home local API implemented in TypeScript.
|
|
4
4
|
|
|
5
|
-

|
|
6
|
+
[](https://codecov.io/gh/lion-and-bear/freeathome-local-api-client)
|
|
7
|
+
[](https://sonarcloud.io/summary/new_code?id=lion-and-bear_freeathome-local-api-client)
|
|
8
8
|

|
|
9
9
|

|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
If you are using Golang, feel free to check out the Go implementation of this library [here](https://github.com/pgerke/freeathome)!
|
|
13
13
|
|
|
@@ -57,7 +57,7 @@ This package uses npm Trusted Publisher authentication for secure, token-free pu
|
|
|
57
57
|
|
|
58
58
|
## I found a bug, what do I do?
|
|
59
59
|
|
|
60
|
-
I'm happy to hear any feedback regarding the library or it's implementation, be it critizism, praise or rants. Please create a [GitHub issue](https://github.com/
|
|
60
|
+
I'm happy to hear any feedback regarding the library or it's implementation, be it critizism, praise or rants. Please create a [GitHub issue](https://github.com/lion-and-bear/freeathome-local-api-client/issues) or drop me an [email](mailto:info@philipgerke.com) if you would like to contact me.
|
|
61
61
|
|
|
62
62
|
I would especially appreciate, if you could report any issues you encounter while using the library. Issues I know about, I can probably fix.
|
|
63
63
|
|
|
@@ -72,7 +72,7 @@ While creating a bug report, please make it easy for me to fix it by giving us a
|
|
|
72
72
|
|
|
73
73
|
## I have a feature request, what do I do?
|
|
74
74
|
|
|
75
|
-
Please create a [GitHub issue](https://github.com/
|
|
75
|
+
Please create a [GitHub issue](https://github.com/lion-and-bear/freeathome-local-api-client/issues) or drop me an [email](mailto:info@philipgerke.com)!
|
|
76
76
|
|
|
77
77
|
## Non-Affiliation Disclaimer
|
|
78
78
|
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var me=(n,s)=>{for(var e in s)U(n,e,{get:s[e],enumerable:!0})},le=(n,s,e,p)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of ge(s))!ye.call(n,o)&&o!==e&&U(n,o,{get:()=>s[o],enumerable:!(p=ue(s,o))||p.enumerable});return n};var fe=n=>le(U({},"__esModule",{value:!0}),n);var He={};me(He,{SystemAccessPoint:()=>N,VirtualDeviceType:()=>se,isChannel:()=>ae,isConfiguration:()=>$,isDevice:()=>pe,isDeviceList:()=>K,isDeviceResponse:()=>A,isGetDataPointResponse:()=>B,isSetDataPointResponse:()=>F,isVirtualDevice:()=>ne,isVirtualDeviceResponse:()=>G,isWebSocketMessage:()=>L});module.exports=fe(He);var c=require("ts-interface-checker"),Se=(0,c.iface)([],{displayName:(0,c.opt)("string"),functionID:(0,c.opt)("string"),room:(0,c.opt)("string"),floor:(0,c.opt)("string"),inputs:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"InOutPut"})),outputs:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"InOutPut"})),parameters:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"string"})),type:(0,c.opt)("string")}),b={Channel:Se};var O=require("ts-interface-checker"),he=(0,O.iface)([],{[O.indexKey]:"SysAP"}),j={Configuration:he};var u=require("ts-interface-checker"),de=(0,u.iface)([],{displayName:(0,u.opt)("string"),room:(0,u.opt)("string"),floor:(0,u.opt)("string"),interface:(0,u.opt)("string"),nativeId:(0,u.opt)("string"),channels:(0,u.opt)((0,u.iface)([],{[u.indexKey]:"Channel"})),parameters:(0,u.opt)((0,u.iface)([],{[u.indexKey]:"string"}))}),x={Device:de};var D=require("ts-interface-checker"),ve=(0,D.iface)([],{[D.indexKey]:(0,D.array)("string")}),H={DeviceList:ve};var T=require("ts-interface-checker"),be=(0,T.iface)([],{[T.indexKey]:(0,T.iface)([],{devices:"Devices"})}),V={DeviceResponse:be};var Q=require("ts-interface-checker"),ke=(0,Q.iface)([],{[Q.indexKey]:"Device"}),P={Devices:ke};var oe=require("ts-interface-checker"),Re=(0,oe.iface)([],{code:"string",detail:"string",title:"string"}),q={Error:Re};var I=require("ts-interface-checker"),xe=(0,I.iface)([],{[I.indexKey]:(0,I.iface)([],{name:"string",rooms:"Rooms"})}),z={Floors:xe};var k=require("ts-interface-checker"),De=(0,k.iface)([],{[k.indexKey]:(0,k.iface)([],{values:(0,k.array)("string")})}),X={GetDataPointResponse:De};var E=require("ts-interface-checker"),we=(0,E.iface)([],{value:(0,E.opt)("string"),pairingID:(0,E.opt)("number")}),R={InOutPut:we};var C=require("ts-interface-checker"),Ae=(0,C.iface)([],{[C.indexKey]:(0,C.iface)([],{name:"string"})}),J={Rooms:Ae};var m=require("ts-interface-checker"),Te=(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{channels:(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{outputs:(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{value:"string",pairingID:"number"})})})})})}),_={ScenesTriggered:Te};var w=require("ts-interface-checker"),Pe=(0,w.iface)([],{[w.indexKey]:(0,w.iface)([],{[w.indexKey]:"string"})}),Y={SetDataPointResponse:Pe};var M=require("ts-interface-checker"),Ie=(0,M.iface)([],{devices:"Devices",floorplan:(0,M.iface)([],{floors:"Floors"}),sysapName:"string",users:"Users",error:(0,M.opt)("Error")}),Z={SysAP:Ie};var h=require("ts-interface-checker"),Ee=(0,h.iface)([],{[h.indexKey]:(0,h.iface)([],{enabled:"boolean",flags:(0,h.array)("string"),grantedPermissions:(0,h.array)("string"),jid:"string",name:"string",requestedPermissions:(0,h.array)("string"),role:"string"})}),ee={Users:Ee};var y=require("ts-interface-checker"),Ce=(0,y.iface)([],{type:"VirtualDeviceType",properties:(0,y.opt)((0,y.iface)([],{ttl:(0,y.opt)("string"),displayname:(0,y.opt)("string"),flavor:(0,y.opt)("string"),capabilities:(0,y.opt)((0,y.array)("number"))}))}),Me=(0,y.enumtype)({BinarySensor:"BinarySensor",BlindActuator:"BlindActuator",SwitchingActuator:"SwitchingActuator",CeilingFanActuator:"CeilingFanActuator",RTC:"RTC",DimActuator:"DimActuator",EVCharging:"evcharging",WindowSensor:"WindowSensor",SimpleDoorlock:"simple_doorlock",ShutterActuator:"ShutterActuator",WeatherStation:"WeatherStation",WeatherTemperatureSensor:"Weather-TemperatureSensor",WeatherWindSensor:"Weather-WindSensor",WeatherBrightnessSensor:"Weather-BrightnessSensor",WeatherRainSensor:"Weather-RainSensor",WindowActuator:"WindowActuator",CODetector:"CODetector",FireDetector:"FireDetector",KNXSwitchSensor:"KNX-SwitchSensor",MediaPlayer:"MediaPlayer",EnergyBattery:"EnergyBattery",EnergyInverter:"EnergyInverter",EnergyMeter:"EnergyMeter",EnergyInverterBattery:"EnergyInverterBattery",EnergyInverterMeter:"EnergyInverterMeter",EnergyInverterMeterBattery:"EnergyInverterMeterBattery",EnergyMeterBattery:"EnergyMeterBattery",AirQualityCO2:"AirQualityCO2",AirQualityCO:"AirQualityCO",AirQualityFull:"AirQualityFull",AirQualityHumidity:"AirQualityHumidity",AirQualityNO2:"AirQualityNO2",AirQualityO3:"AirQualityO3",AirQualityPM10:"AirQualityPM10",AirQualityPM25:"AirQualityPM25",AirQualityPressure:"AirQualityPressure",AirQualityTemperature:"AirQualityTemperature",AirQualityVOC:"AirQualityVOC",EnergyMeterV2:"EnergyMeterv2",HomeApplianceLaundry:"HomeAppliance-Laundry",HVAC:"HVAC",SplitUnit:"SplitUnit"}),te={VirtualDevice:Ce,VirtualDeviceType:Me};var v=require("ts-interface-checker"),We=(0,v.iface)([],{[v.indexKey]:(0,v.iface)([],{devices:(0,v.iface)([],{[v.indexKey]:(0,v.iface)([],{serial:"string"})})})}),re={VirtualDeviceResponse:We};var g=require("ts-interface-checker"),Oe=(0,g.iface)([],{[g.indexKey]:(0,g.iface)([],{datapoints:(0,g.iface)([],{[g.indexKey]:"string"}),devices:"Devices",devicesAdded:(0,g.array)("string"),devicesRemoved:(0,g.array)("string"),scenesTriggered:"ScenesTriggered",parameters:(0,g.opt)((0,g.iface)([],{[g.indexKey]:"string"}))})}),ie={WebSocketMessage:Oe};var l=require("ts-interface-checker");var se=(t=>(t.BinarySensor="BinarySensor",t.BlindActuator="BlindActuator",t.SwitchingActuator="SwitchingActuator",t.CeilingFanActuator="CeilingFanActuator",t.RTC="RTC",t.DimActuator="DimActuator",t.EVCharging="evcharging",t.WindowSensor="WindowSensor",t.SimpleDoorlock="simple_doorlock",t.ShutterActuator="ShutterActuator",t.WeatherStation="WeatherStation",t.WeatherTemperatureSensor="Weather-TemperatureSensor",t.WeatherWindSensor="Weather-WindSensor",t.WeatherBrightnessSensor="Weather-BrightnessSensor",t.WeatherRainSensor="Weather-RainSensor",t.WindowActuator="WindowActuator",t.CODetector="CODetector",t.FireDetector="FireDetector",t.KNXSwitchSensor="KNX-SwitchSensor",t.MediaPlayer="MediaPlayer",t.EnergyBattery="EnergyBattery",t.EnergyInverter="EnergyInverter",t.EnergyMeter="EnergyMeter",t.EnergyInverterBattery="EnergyInverterBattery",t.EnergyInverterMeter="EnergyInverterMeter",t.EnergyInverterMeterBattery="EnergyInverterMeterBattery",t.EnergyMeterBattery="EnergyMeterBattery",t.AirQualityCO2="AirQualityCO2",t.AirQualityCO="AirQualityCO",t.AirQualityFull="AirQualityFull",t.AirQualityHumidity="AirQualityHumidity",t.AirQualityNO2="AirQualityNO2",t.AirQualityO3="AirQualityO3",t.AirQualityPM10="AirQualityPM10",t.AirQualityPM25="AirQualityPM25",t.AirQualityPressure="AirQualityPressure",t.AirQualityTemperature="AirQualityTemperature",t.AirQualityVOC="AirQualityVOC",t.EnergyMeterV2="EnergyMeterv2",t.HomeApplianceLaundry="HomeAppliance-Laundry",t.HVAC="HVAC",t.SplitUnit="SplitUnit",t))(se||{});var{Channel:Qe}=(0,l.createCheckers)(b,R),{Configuration:Le}=(0,l.createCheckers)(j,P,x,b,R,z,J,Z,ee,q),{Device:$e}=(0,l.createCheckers)(x,b,R),{DeviceList:Ke}=(0,l.createCheckers)(H),{DeviceResponse:Be}=(0,l.createCheckers)(V,P,x,b,R),{GetDataPointResponse:Fe}=(0,l.createCheckers)(X),{SetDataPointResponse:Ge}=(0,l.createCheckers)(Y),{VirtualDevice:Ne}=(0,l.createCheckers)(te),{VirtualDeviceResponse:Ue}=(0,l.createCheckers)(re),{WebSocketMessage:je}=(0,l.createCheckers)(ie,P,x,b,R,_);function f(n,s,e,p){if(p)try{return s.check(n),!0}catch(o){return e.error("Object validation failed!",o),!1}return s.test(n)}function L(n,s,e=!1){return f(n,je,s,e)}function $(n,s,e=!1){return f(n,Le,s,e)}function K(n,s,e=!1){return f(n,Ke,s,e)}function A(n,s,e=!1){return f(n,Be,s,e)}function B(n,s,e=!1){return f(n,Fe,s,e)}function F(n,s,e=!1){return f(n,Ge,s,e)}function ne(n,s,e=!1){return f(n,Ne,s,e)}function G(n,s,e=!1){return f(n,Ue,s,e)}function ae(n,s,e=!1){return f(n,Qe,s,e)}function pe(n,s,e=!1){return f(n,$e,s,e)}var ce=require("events"),d=require("rxjs"),W=require("ws");var N=class extends ce.EventEmitter{constructor(e,p,o,i=!0,a=!1,S=console,Ve){super();this.hostName=e;this.userName=p;this.password=o;this.tlsEnabled=i;this.verboseErrors=a;this.logger=S;this.scheduler=Ve;this.basicAuthKey=Buffer.from(`${p}:${o}`,"utf8").toString("base64")}basicAuthKey;webSocket;webSocketMessageSubject=new d.Subject;webSocketKeepaliveTimerReset$=new d.Subject;webSocketKeepaliveTimer$=this.webSocketKeepaliveTimerReset$.pipe((0,d.switchMap)(()=>(0,d.interval)(3e4,this.scheduler).pipe((0,d.takeUntil)(this.webSocketKeepaliveTimerReset$))));webSocketKeepaliveSubscription;connectWebSocket(e=!0){if(this.webSocket&&this.webSocket.readyState===W.WebSocket.OPEN)throw new Error("Web socket is already connected");this.webSocket=this.createWebSocket(e),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0,this.webSocketKeepaliveSubscription=this.webSocketKeepaliveTimer$.subscribe(()=>{this.webSocket&&this.webSocket.readyState===W.WebSocket.OPEN&&(this.logger.log("keepalive timer expired, sending ping message..."),this.webSocket.ping())}),this.webSocketKeepaliveTimerReset$.next()}async createVirtualDevice(e,p,o){let i=await this.fetchDataViaRest("PUT",`virtualdevice/${e}/${p}`,JSON.stringify(o));return this.processRestResponse(i,G)}createWebSocket(e){this.tlsEnabled&&!e&&this.logger.warn("TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.");let p=`${this.tlsEnabled?"wss":"ws"}://${this.hostName}/fhapi/v1/api/ws`,o={rejectUnauthorized:this.tlsEnabled&&e,headers:{Authorization:`Basic ${this.basicAuthKey}`}},i=new W.WebSocket(p,o);return i.on("error",a=>{this.emit("websocket-error",a),this.logger.error("Error received",a)}),i.on("ping",a=>{this.emit("websocket-ping",a),this.logger.debug("Ping received",a.toString("ascii")),this.webSocketKeepaliveTimerReset$.next(),i.pong(a),this.logger.debug("Pong sent",a.toString("ascii"))}),i.on("pong",a=>{this.emit("websocket-pong",a),this.logger.debug("Pong received",a.toString("ascii"))}),i.on("unexpected-response",(a,S)=>{this.emit("websocket-unexpected-response",a,S),this.logger.error("Unexpected response received")}),i.on("upgrade",a=>{this.emit("websocket-upgrade",a),this.logger.debug("Upgrade request received")}),i.on("open",()=>{this.emit("websocket-open"),this.logger.log("Connection opened")}),i.on("close",(a,S)=>{this.emit("websocket-close",a,S),this.logger.log("Connection closed"),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0}),i.on("message",(a,S)=>{this.emit("websocket-message",a,S),this.webSocketKeepaliveTimerReset$.next(),this.processWebSocketMessage(a,S)}),i}disconnectWebSocket(e=!1){if(!this.webSocket||this.webSocket.readyState===W.WebSocket.CLOSED)throw new Error("Web socket is not open");e?this.webSocket.terminate():this.webSocket.close()}async getConfiguration(){let e=await this.fetchDataViaRest("GET","configuration");return this.processRestResponse(e,$)}async getDeviceList(){let e=await this.fetchDataViaRest("GET","devicelist");return this.processRestResponse(e,K)}async getDevice(e,p){let o=await this.fetchDataViaRest("GET",`device/${e}/${p}`);return this.processRestResponse(o,A)}async getDatapoint(e,p,o,i){let a=await this.fetchDataViaRest("GET",`datapoint/${e}/${p}.${o}.${i}`);return this.processRestResponse(a,B)}getWebSocketMessages(){return this.webSocketMessageSubject.asObservable()}async setDatapoint(e,p,o,i,a){let S=await this.fetchDataViaRest("PUT",`datapoint/${e}/${p}.${o}.${i}`,a);return this.processRestResponse(S,F)}async triggerProxyDevice(e,p,o,i){let a=await this.fetchDataViaRest("GET",`proxydevice/${e}/${p}/${o}/action/${i}`);return this.processRestResponse(a,A)}async setProxyDeviceValue(e,p,o,i){let a=await this.fetchDataViaRest("PUT",`proxydevice/${e}/${p}/${o}/value/${i}`);return this.processRestResponse(a,A)}async fetchDataViaRest(e,p,o){let i=`${this.tlsEnabled?"https":"http"}://${this.hostName}/fhapi/v1/api/rest/${p}`,a={method:e,headers:{Authorization:`Basic ${this.basicAuthKey}`},body:o};return fetch(i,a)}async processRestResponse(e,p){let o,i;switch(e.status){case 200:if(o=await e.json(),!p(o,this.logger,this.verboseErrors))throw i="Received message has an unexpected type!",this.logger.error(i,o),new Error(i);return o;case 401:throw i="Authentication information is missing or invalid.",this.logger.error(i),new Error(i);case 502:throw i=await e.text(),this.logger.error(i),new Error(i);default:throw i=`Received HTTP ${e.status} status code unexpectedly: ${await e.text()}`,this.logger.error(i),new Error(i)}}processWebSocketMessage(e,p){if(p){this.logger.warn("Binary message received. Binary messages are not processed.");return}this.logger.debug("Message received");let o=e.toString(),i=JSON.parse(o);if(L(i,this.logger,this.verboseErrors)){this.webSocketMessageSubject.next(i);return}this.logger.error("Received message has an unexpected type!",o)}};0&&(module.exports={SystemAccessPoint,VirtualDeviceType,isChannel,isConfiguration,isDevice,isDeviceList,isDeviceResponse,isGetDataPointResponse,isSetDataPointResponse,isVirtualDevice,isVirtualDeviceResponse,isWebSocketMessage});
|
|
1
|
+
"use strict";var U=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var me=(n,s)=>{for(var e in s)U(n,e,{get:s[e],enumerable:!0})},le=(n,s,e,p)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of ge(s))!ye.call(n,o)&&o!==e&&U(n,o,{get:()=>s[o],enumerable:!(p=ue(s,o))||p.enumerable});return n};var fe=n=>le(U({},"__esModule",{value:!0}),n);var He={};me(He,{SystemAccessPoint:()=>N,VirtualDeviceType:()=>se,isChannel:()=>ae,isConfiguration:()=>$,isDevice:()=>pe,isDeviceList:()=>K,isDeviceResponse:()=>T,isGetDataPointResponse:()=>B,isSetDataPointResponse:()=>F,isVirtualDevice:()=>ne,isVirtualDeviceResponse:()=>G,isWebSocketMessage:()=>L});module.exports=fe(He);var c=require("ts-interface-checker"),Se=(0,c.iface)([],{displayName:(0,c.opt)("string"),functionID:(0,c.opt)("string"),room:(0,c.opt)("string"),floor:(0,c.opt)("string"),inputs:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"InOutPut"})),outputs:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"InOutPut"})),parameters:(0,c.opt)((0,c.iface)([],{[c.indexKey]:"string"})),type:(0,c.opt)("string")}),b={Channel:Se};var O=require("ts-interface-checker"),he=(0,O.iface)([],{[O.indexKey]:"SysAP"}),j={Configuration:he};var u=require("ts-interface-checker"),de=(0,u.iface)([],{displayName:(0,u.opt)("string"),room:(0,u.opt)("string"),floor:(0,u.opt)("string"),interface:(0,u.opt)("string"),nativeId:(0,u.opt)("string"),channels:(0,u.opt)((0,u.iface)([],{[u.indexKey]:"Channel"})),parameters:(0,u.opt)((0,u.iface)([],{[u.indexKey]:"string"}))}),x={Device:de};var D=require("ts-interface-checker"),ve=(0,D.iface)([],{[D.indexKey]:(0,D.array)("string")}),H={DeviceList:ve};var A=require("ts-interface-checker"),be=(0,A.iface)([],{[A.indexKey]:(0,A.iface)([],{devices:"Devices"})}),V={DeviceResponse:be};var Q=require("ts-interface-checker"),ke=(0,Q.iface)([],{[Q.indexKey]:"Device"}),P={Devices:ke};var oe=require("ts-interface-checker"),Re=(0,oe.iface)([],{code:"string",detail:"string",title:"string"}),q={Error:Re};var I=require("ts-interface-checker"),xe=(0,I.iface)([],{[I.indexKey]:(0,I.iface)([],{name:"string",rooms:"Rooms"})}),z={Floors:xe};var k=require("ts-interface-checker"),De=(0,k.iface)([],{[k.indexKey]:(0,k.iface)([],{values:(0,k.array)("string")})}),X={GetDataPointResponse:De};var E=require("ts-interface-checker"),we=(0,E.iface)([],{value:(0,E.opt)("string"),pairingID:(0,E.opt)("number")}),R={InOutPut:we};var C=require("ts-interface-checker"),Te=(0,C.iface)([],{[C.indexKey]:(0,C.iface)([],{name:"string"})}),J={Rooms:Te};var m=require("ts-interface-checker"),Ae=(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{channels:(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{outputs:(0,m.iface)([],{[m.indexKey]:(0,m.iface)([],{value:"string",pairingID:"number"})})})})})}),_={ScenesTriggered:Ae};var w=require("ts-interface-checker"),Pe=(0,w.iface)([],{[w.indexKey]:(0,w.iface)([],{[w.indexKey]:"string"})}),Y={SetDataPointResponse:Pe};var M=require("ts-interface-checker"),Ie=(0,M.iface)([],{devices:"Devices",floorplan:(0,M.iface)([],{floors:"Floors"}),sysapName:"string",users:"Users",error:(0,M.opt)("Error")}),Z={SysAP:Ie};var h=require("ts-interface-checker"),Ee=(0,h.iface)([],{[h.indexKey]:(0,h.iface)([],{enabled:"boolean",flags:(0,h.array)("string"),grantedPermissions:(0,h.array)("string"),jid:"string",name:"string",requestedPermissions:(0,h.array)("string"),role:"string"})}),ee={Users:Ee};var y=require("ts-interface-checker"),Ce=(0,y.iface)([],{type:"VirtualDeviceType",properties:(0,y.opt)((0,y.iface)([],{ttl:(0,y.opt)("string"),displayname:(0,y.opt)("string"),flavor:(0,y.opt)("string"),capabilities:(0,y.opt)((0,y.array)("number"))}))}),Me=(0,y.enumtype)({BinarySensor:"BinarySensor",BlindActuator:"BlindActuator",SwitchingActuator:"SwitchingActuator",CeilingFanActuator:"CeilingFanActuator",RTC:"RTC",DimActuator:"DimActuator",EVCharging:"evcharging",WindowSensor:"WindowSensor",SimpleDoorlock:"simple_doorlock",ShutterActuator:"ShutterActuator",WeatherStation:"WeatherStation",WeatherTemperatureSensor:"Weather-TemperatureSensor",WeatherWindSensor:"Weather-WindSensor",WeatherBrightnessSensor:"Weather-BrightnessSensor",WeatherRainSensor:"Weather-RainSensor",WindowActuator:"WindowActuator",CODetector:"CODetector",FireDetector:"FireDetector",KNXSwitchSensor:"KNX-SwitchSensor",MediaPlayer:"MediaPlayer",EnergyBattery:"EnergyBattery",EnergyInverter:"EnergyInverter",EnergyMeter:"EnergyMeter",EnergyInverterBattery:"EnergyInverterBattery",EnergyInverterMeter:"EnergyInverterMeter",EnergyInverterMeterBattery:"EnergyInverterMeterBattery",EnergyMeterBattery:"EnergyMeterBattery",AirQualityCO2:"AirQualityCO2",AirQualityCO:"AirQualityCO",AirQualityFull:"AirQualityFull",AirQualityHumidity:"AirQualityHumidity",AirQualityNO2:"AirQualityNO2",AirQualityO3:"AirQualityO3",AirQualityPM10:"AirQualityPM10",AirQualityPM25:"AirQualityPM25",AirQualityPressure:"AirQualityPressure",AirQualityTemperature:"AirQualityTemperature",AirQualityVOC:"AirQualityVOC",EnergyMeterV2:"EnergyMeterv2",HomeApplianceLaundry:"HomeAppliance-Laundry",HVAC:"HVAC",SplitUnit:"SplitUnit"}),te={VirtualDevice:Ce,VirtualDeviceType:Me};var v=require("ts-interface-checker"),We=(0,v.iface)([],{[v.indexKey]:(0,v.iface)([],{devices:(0,v.iface)([],{[v.indexKey]:(0,v.iface)([],{serial:"string"})})})}),re={VirtualDeviceResponse:We};var g=require("ts-interface-checker"),Oe=(0,g.iface)([],{[g.indexKey]:(0,g.iface)([],{datapoints:(0,g.iface)([],{[g.indexKey]:"string"}),devices:"Devices",devicesAdded:(0,g.array)("string"),devicesRemoved:(0,g.array)("string"),scenesTriggered:"ScenesTriggered",parameters:(0,g.opt)((0,g.iface)([],{[g.indexKey]:"string"}))})}),ie={WebSocketMessage:Oe};var l=require("ts-interface-checker");var se=(t=>(t.BinarySensor="BinarySensor",t.BlindActuator="BlindActuator",t.SwitchingActuator="SwitchingActuator",t.CeilingFanActuator="CeilingFanActuator",t.RTC="RTC",t.DimActuator="DimActuator",t.EVCharging="evcharging",t.WindowSensor="WindowSensor",t.SimpleDoorlock="simple_doorlock",t.ShutterActuator="ShutterActuator",t.WeatherStation="WeatherStation",t.WeatherTemperatureSensor="Weather-TemperatureSensor",t.WeatherWindSensor="Weather-WindSensor",t.WeatherBrightnessSensor="Weather-BrightnessSensor",t.WeatherRainSensor="Weather-RainSensor",t.WindowActuator="WindowActuator",t.CODetector="CODetector",t.FireDetector="FireDetector",t.KNXSwitchSensor="KNX-SwitchSensor",t.MediaPlayer="MediaPlayer",t.EnergyBattery="EnergyBattery",t.EnergyInverter="EnergyInverter",t.EnergyMeter="EnergyMeter",t.EnergyInverterBattery="EnergyInverterBattery",t.EnergyInverterMeter="EnergyInverterMeter",t.EnergyInverterMeterBattery="EnergyInverterMeterBattery",t.EnergyMeterBattery="EnergyMeterBattery",t.AirQualityCO2="AirQualityCO2",t.AirQualityCO="AirQualityCO",t.AirQualityFull="AirQualityFull",t.AirQualityHumidity="AirQualityHumidity",t.AirQualityNO2="AirQualityNO2",t.AirQualityO3="AirQualityO3",t.AirQualityPM10="AirQualityPM10",t.AirQualityPM25="AirQualityPM25",t.AirQualityPressure="AirQualityPressure",t.AirQualityTemperature="AirQualityTemperature",t.AirQualityVOC="AirQualityVOC",t.EnergyMeterV2="EnergyMeterv2",t.HomeApplianceLaundry="HomeAppliance-Laundry",t.HVAC="HVAC",t.SplitUnit="SplitUnit",t))(se||{});var{Channel:Qe}=(0,l.createCheckers)(b,R),{Configuration:Le}=(0,l.createCheckers)(j,P,x,b,R,z,J,Z,ee,q),{Device:$e}=(0,l.createCheckers)(x,b,R),{DeviceList:Ke}=(0,l.createCheckers)(H),{DeviceResponse:Be}=(0,l.createCheckers)(V,P,x,b,R),{GetDataPointResponse:Fe}=(0,l.createCheckers)(X),{SetDataPointResponse:Ge}=(0,l.createCheckers)(Y),{VirtualDevice:Ne}=(0,l.createCheckers)(te),{VirtualDeviceResponse:Ue}=(0,l.createCheckers)(re),{WebSocketMessage:je}=(0,l.createCheckers)(ie,P,x,b,R,_);function f(n,s,e,p){if(p)try{return s.check(n),!0}catch(o){return e.error("Object validation failed!",o),!1}return s.test(n)}function L(n,s,e=!1){return f(n,je,s,e)}function $(n,s,e=!1){return f(n,Le,s,e)}function K(n,s,e=!1){return f(n,Ke,s,e)}function T(n,s,e=!1){return f(n,Be,s,e)}function B(n,s,e=!1){return f(n,Fe,s,e)}function F(n,s,e=!1){return f(n,Ge,s,e)}function ne(n,s,e=!1){return f(n,Ne,s,e)}function G(n,s,e=!1){return f(n,Ue,s,e)}function ae(n,s,e=!1){return f(n,Qe,s,e)}function pe(n,s,e=!1){return f(n,$e,s,e)}var ce=require("events"),d=require("rxjs"),W=require("ws");var N=class extends ce.EventEmitter{constructor(e,p,o,i=!0,a=!1,S=console,Ve){super();this.hostName=e;this.userName=p;this.password=o;this.tlsEnabled=i;this.verboseErrors=a;this.logger=S;this.scheduler=Ve;this.basicAuthKey=Buffer.from(`${p}:${o}`,"utf8").toString("base64")}basicAuthKey;webSocket;webSocketMessageSubject=new d.Subject;webSocketKeepaliveTimerReset$=new d.Subject;webSocketKeepaliveTimer$=this.webSocketKeepaliveTimerReset$.pipe((0,d.switchMap)(()=>(0,d.interval)(3e4,this.scheduler).pipe((0,d.takeUntil)(this.webSocketKeepaliveTimerReset$))));webSocketKeepaliveSubscription;connectWebSocket(e=!0){if(this.webSocket?.readyState===W.WebSocket.OPEN)throw new Error("Web socket is already connected");this.webSocket=this.createWebSocket(e),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0,this.webSocketKeepaliveSubscription=this.webSocketKeepaliveTimer$.subscribe(()=>{this.webSocket?.readyState===W.WebSocket.OPEN&&(this.logger.log("keepalive timer expired, sending ping message..."),this.webSocket.ping())}),this.webSocketKeepaliveTimerReset$.next()}async createVirtualDevice(e,p,o){let i=await this.fetchDataViaRest("PUT",`virtualdevice/${e}/${p}`,JSON.stringify(o));return this.processRestResponse(i,G)}createWebSocket(e){this.tlsEnabled&&!e&&this.logger.warn("TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.");let p=`${this.tlsEnabled?"wss":"ws"}://${this.hostName}/fhapi/v1/api/ws`,o={rejectUnauthorized:this.tlsEnabled&&e,headers:{Authorization:`Basic ${this.basicAuthKey}`}},i=new W.WebSocket(p,o);return i.on("error",a=>{this.emit("websocket-error",a),this.logger.error("Error received",a)}),i.on("ping",a=>{this.emit("websocket-ping",a),this.logger.debug("Ping received",a.toString("ascii")),this.webSocketKeepaliveTimerReset$.next(),i.pong(a),this.logger.debug("Pong sent",a.toString("ascii"))}),i.on("pong",a=>{this.emit("websocket-pong",a),this.logger.debug("Pong received",a.toString("ascii"))}),i.on("unexpected-response",(a,S)=>{this.emit("websocket-unexpected-response",a,S),this.logger.error("Unexpected response received")}),i.on("upgrade",a=>{this.emit("websocket-upgrade",a),this.logger.debug("Upgrade request received")}),i.on("open",()=>{this.emit("websocket-open"),this.logger.log("Connection opened")}),i.on("close",(a,S)=>{this.emit("websocket-close",a,S),this.logger.log("Connection closed"),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0}),i.on("message",(a,S)=>{this.emit("websocket-message",a,S),this.webSocketKeepaliveTimerReset$.next(),this.processWebSocketMessage(a,S)}),i}disconnectWebSocket(e=!1){if(!this.webSocket||this.webSocket.readyState===W.WebSocket.CLOSED)throw new Error("Web socket is not open");e?this.webSocket.terminate():this.webSocket.close()}async getConfiguration(){let e=await this.fetchDataViaRest("GET","configuration");return this.processRestResponse(e,$)}async getDeviceList(){let e=await this.fetchDataViaRest("GET","devicelist");return this.processRestResponse(e,K)}async getDevice(e,p){let o=await this.fetchDataViaRest("GET",`device/${e}/${p}`);return this.processRestResponse(o,T)}async getDatapoint(e,p,o,i){let a=await this.fetchDataViaRest("GET",`datapoint/${e}/${p}.${o}.${i}`);return this.processRestResponse(a,B)}getWebSocketMessages(){return this.webSocketMessageSubject.asObservable()}async setDatapoint(e,p,o,i,a){let S=await this.fetchDataViaRest("PUT",`datapoint/${e}/${p}.${o}.${i}`,a);return this.processRestResponse(S,F)}async triggerProxyDevice(e,p,o,i){let a=await this.fetchDataViaRest("GET",`proxydevice/${e}/${p}/${o}/action/${i}`);return this.processRestResponse(a,T)}async setProxyDeviceValue(e,p,o,i){let a=await this.fetchDataViaRest("PUT",`proxydevice/${e}/${p}/${o}/value/${i}`);return this.processRestResponse(a,T)}async fetchDataViaRest(e,p,o){let i=`${this.tlsEnabled?"https":"http"}://${this.hostName}/fhapi/v1/api/rest/${p}`,a={method:e,headers:{Authorization:`Basic ${this.basicAuthKey}`},body:o};return fetch(i,a)}async processRestResponse(e,p){let o,i;switch(e.status){case 200:if(o=await e.json(),!p(o,this.logger,this.verboseErrors))throw i="Received message has an unexpected type!",this.logger.error(i,o),new Error(i);return o;case 401:throw i="Authentication information is missing or invalid.",this.logger.error(i),new Error(i);case 502:throw i=await e.text(),this.logger.error(i),new Error(i);default:throw i=`Received HTTP ${e.status} status code unexpectedly: ${await e.text()}`,this.logger.error(i),new Error(i)}}processWebSocketMessage(e,p){if(p){this.logger.warn("Binary message received. Binary messages are not processed.");return}this.logger.debug("Message received");let o=e.toString(),i=JSON.parse(o);if(L(i,this.logger,this.verboseErrors)){this.webSocketMessageSubject.next(i);return}this.logger.error("Received message has an unexpected type!",o)}};0&&(module.exports={SystemAccessPoint,VirtualDeviceType,isChannel,isConfiguration,isDevice,isDeviceList,isDeviceResponse,isGetDataPointResponse,isSetDataPointResponse,isVirtualDevice,isVirtualDeviceResponse,isWebSocketMessage});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/model/validation/channel-ti.ts","../src/model/validation/configuration-ti.ts","../src/model/validation/device-ti.ts","../src/model/validation/device-list-ti.ts","../src/model/validation/device-response-ti.ts","../src/model/validation/devices-ti.ts","../src/model/validation/error-ti.ts","../src/model/validation/floors-ti.ts","../src/model/validation/get-data-point-response-ti.ts","../src/model/validation/in-out-put-ti.ts","../src/model/validation/rooms-ti.ts","../src/model/validation/scenes-triggered-ti.ts","../src/model/validation/set-data-point-response-ti.ts","../src/model/validation/sys-ap-ti.ts","../src/model/validation/users-ti.ts","../src/model/validation/virtual-device-ti.ts","../src/model/validation/virtual-device-response-ti.ts","../src/model/validation/websocket-message-ti.ts","../src/model/validator.ts","../src/model/virtual-device.ts","../src/system-access-point.ts"],"sourcesContent":["export * from \"./model\";\nexport { SystemAccessPoint } from \"./system-access-point\";\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Channel = iface([], {\n displayName: opt(\"string\"),\n functionID: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n inputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n outputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n type: opt(\"string\"),\n});\n\nexport const ChannelTypeSuite: ITypeSuite = {\n Channel,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Configuration = iface([], {\n [indexKey]: \"SysAP\",\n});\n\nexport const ConfigurationTypeSuite: ITypeSuite = {\n Configuration,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Device = iface([], {\n displayName: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n interface: opt(\"string\"),\n nativeId: opt(\"string\"),\n channels: opt(\n iface([], {\n [indexKey]: \"Channel\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n});\n\nexport const DeviceTypeSuite: ITypeSuite = {\n Device,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceList = iface([], {\n [indexKey]: array(\"string\"),\n});\n\nexport const DeviceListTypeSuite: ITypeSuite = {\n DeviceList,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: \"Devices\",\n }),\n});\n\nexport const DeviceResponseTypeSuite: ITypeSuite = {\n DeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Devices = iface([], {\n [indexKey]: \"Device\",\n});\n\nexport const DevicesTypeSuite: ITypeSuite = {\n Devices,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface } from \"ts-interface-checker\";\n\nconst Error = iface([], {\n code: \"string\",\n detail: \"string\",\n title: \"string\",\n});\n\nexport const ErrorTypeSuite: ITypeSuite = {\n Error,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Floors = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n rooms: \"Rooms\",\n }),\n});\n\nexport const FloorsTypeSuite: ITypeSuite = {\n Floors,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst GetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n values: array(\"string\"),\n }),\n});\n\nexport const GetDataPointResponseTypeSuite: ITypeSuite = {\n GetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst InOutPut = iface([], {\n value: opt(\"string\"),\n pairingID: opt(\"number\"),\n});\n\nexport const InOutPutTypeSuite: ITypeSuite = {\n InOutPut,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Rooms = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n }),\n});\n\nexport const RoomsTypeSuite: ITypeSuite = {\n Rooms,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst ScenesTriggered = iface([], {\n [indexKey]: iface([], {\n channels: iface([], {\n [indexKey]: iface([], {\n outputs: iface([], {\n [indexKey]: iface([], {\n value: \"string\",\n pairingID: \"number\",\n }),\n }),\n }),\n }),\n }),\n});\n\nexport const ScenesTriggeredTypeSuite: ITypeSuite = {\n ScenesTriggered,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst SetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n [indexKey]: \"string\",\n }),\n});\n\nexport const SetDataPointResponseTypeSuite: ITypeSuite = {\n SetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst SysAP = iface([], {\n devices: \"Devices\",\n floorplan: iface([], {\n floors: \"Floors\",\n }),\n sysapName: \"string\",\n users: \"Users\",\n error: opt(\"Error\"),\n});\n\nexport const SysApTypeSuite: ITypeSuite = {\n SysAP,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst Users = iface([], {\n [indexKey]: iface([], {\n enabled: \"boolean\",\n flags: array(\"string\"),\n grantedPermissions: array(\"string\"),\n jid: \"string\",\n name: \"string\",\n requestedPermissions: array(\"string\"),\n role: \"string\",\n }),\n});\n\nexport const UsersTypeSuite: ITypeSuite = {\n Users,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, enumtype, iface, opt } from \"ts-interface-checker\";\n\nconst VirtualDevice = iface([], {\n type: \"VirtualDeviceType\",\n properties: opt(\n iface([], {\n ttl: opt(\"string\"),\n displayname: opt(\"string\"),\n flavor: opt(\"string\"),\n capabilities: opt(array(\"number\")),\n })\n ),\n});\n\nexport const VirtualDeviceType = enumtype({\n BinarySensor: \"BinarySensor\",\n BlindActuator: \"BlindActuator\",\n SwitchingActuator: \"SwitchingActuator\",\n CeilingFanActuator: \"CeilingFanActuator\",\n RTC: \"RTC\",\n DimActuator: \"DimActuator\",\n EVCharging: \"evcharging\",\n WindowSensor: \"WindowSensor\",\n SimpleDoorlock: \"simple_doorlock\",\n ShutterActuator: \"ShutterActuator\",\n WeatherStation: \"WeatherStation\",\n WeatherTemperatureSensor: \"Weather-TemperatureSensor\",\n WeatherWindSensor: \"Weather-WindSensor\",\n WeatherBrightnessSensor: \"Weather-BrightnessSensor\",\n WeatherRainSensor: \"Weather-RainSensor\",\n WindowActuator: \"WindowActuator\",\n CODetector: \"CODetector\",\n FireDetector: \"FireDetector\",\n KNXSwitchSensor: \"KNX-SwitchSensor\",\n MediaPlayer: \"MediaPlayer\",\n EnergyBattery: \"EnergyBattery\",\n EnergyInverter: \"EnergyInverter\",\n EnergyMeter: \"EnergyMeter\",\n EnergyInverterBattery: \"EnergyInverterBattery\",\n EnergyInverterMeter: \"EnergyInverterMeter\",\n EnergyInverterMeterBattery: \"EnergyInverterMeterBattery\",\n EnergyMeterBattery: \"EnergyMeterBattery\",\n AirQualityCO2: \"AirQualityCO2\",\n AirQualityCO: \"AirQualityCO\",\n AirQualityFull: \"AirQualityFull\",\n AirQualityHumidity: \"AirQualityHumidity\",\n AirQualityNO2: \"AirQualityNO2\",\n AirQualityO3: \"AirQualityO3\",\n AirQualityPM10: \"AirQualityPM10\",\n AirQualityPM25: \"AirQualityPM25\",\n AirQualityPressure: \"AirQualityPressure\",\n AirQualityTemperature: \"AirQualityTemperature\",\n AirQualityVOC: \"AirQualityVOC\",\n EnergyMeterV2: \"EnergyMeterv2\",\n HomeApplianceLaundry: \"HomeAppliance-Laundry\",\n HVAC: \"HVAC\",\n SplitUnit: \"SplitUnit\",\n});\n\nexport const VirtualDeviceTypeSuite: ITypeSuite = {\n VirtualDevice,\n VirtualDeviceType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst VirtualDeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: iface([], {\n [indexKey]: iface([], {\n serial: \"string\",\n }),\n }),\n }),\n});\n\nexport const VirtualDeviceResponseTypeSuite: ITypeSuite = {\n VirtualDeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst WebSocketMessage = iface([], {\n [indexKey]: iface([], {\n datapoints: iface([], {\n [indexKey]: \"string\",\n }),\n devices: \"Devices\",\n devicesAdded: array(\"string\"),\n devicesRemoved: array(\"string\"),\n scenesTriggered: \"ScenesTriggered\",\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n }),\n});\n\nexport const WebSocketMessageTypeSuite: ITypeSuite = {\n WebSocketMessage,\n};\n","import {\n ChannelTypeSuite,\n DeviceTypeSuite,\n DevicesTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite,\n WebSocketMessageTypeSuite,\n DeviceListTypeSuite,\n SetDataPointResponseTypeSuite,\n GetDataPointResponseTypeSuite,\n ConfigurationTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite,\n DeviceResponseTypeSuite,\n VirtualDeviceTypeSuite,\n VirtualDeviceResponseTypeSuite,\n} from \"./validation\";\nimport type { Checker } from \"ts-interface-checker\";\nimport { createCheckers } from \"ts-interface-checker\";\nimport { type WebSocketMessage as Message } from \"./websocket-message\";\nimport { type Configuration as Config } from \"./configuration\";\nimport { type Channel as Chan } from \"./channel\";\nimport { type Device as Dev } from \"./device\";\nimport { type DeviceList as DevList } from \"./device-list\";\nimport { type DeviceResponse as DevResponse } from \"./device-response\";\nimport { type GetDataPointResponse as GetResponse } from \"./get-data-point-response\";\nimport { type SetDataPointResponse as SetResponse } from \"./set-data-point-response\";\nimport { type VirtualDeviceResponse as VDeviceResponse } from \"./virtual-device-response\";\nimport { type VirtualDevice as VDevice } from \"./virtual-device\";\nimport { type Logger } from \"./logger\";\n\nconst { Channel } = createCheckers(ChannelTypeSuite, InOutPutTypeSuite);\n\nconst { Configuration } = createCheckers(\n ConfigurationTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite\n);\n\nconst { Device } = createCheckers(\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { DeviceList } = createCheckers(DeviceListTypeSuite);\n\nconst { DeviceResponse } = createCheckers(\n DeviceResponseTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { GetDataPointResponse } = createCheckers(GetDataPointResponseTypeSuite);\n\nconst { SetDataPointResponse } = createCheckers(SetDataPointResponseTypeSuite);\n\nconst { VirtualDevice } = createCheckers(VirtualDeviceTypeSuite);\n\nconst { VirtualDeviceResponse } = createCheckers(\n VirtualDeviceResponseTypeSuite\n);\n\nconst { WebSocketMessage } = createCheckers(\n WebSocketMessageTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite\n);\n\nfunction check(\n obj: unknown,\n checker: Checker,\n logger: Logger,\n verbose: boolean\n): boolean {\n if (verbose) {\n try {\n checker.check(obj);\n return true;\n } catch (error) {\n logger.error(\"Object validation failed!\", error);\n return false;\n }\n }\n\n return checker.test(obj);\n}\n\n/**\n * Determines whether the specified object is a web socket message.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a web socket message.\n */\nexport function isWebSocketMessage(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Message {\n return check(obj, WebSocketMessage, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a configuration.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a configuration.\n */\nexport function isConfiguration(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Config {\n return check(obj, Configuration, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device list.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device list.\n */\nexport function isDeviceList(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevList {\n return check(obj, DeviceList, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device response.\n */\nexport function isDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevResponse {\n return check(obj, DeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a get data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a get data point request.\n */\nexport function isGetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is GetResponse {\n return check(obj, GetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a set data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a set data point request.\n */\nexport function isSetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is SetResponse {\n return check(obj, SetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a virtual device.\n */\nexport function isVirtualDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDevice {\n return check(obj, VirtualDevice, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a virtual device request.\n */\nexport function isVirtualDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDeviceResponse {\n return check(obj, VirtualDeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a channel.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a channel.\n */\nexport function isChannel(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Chan {\n return check(obj, Channel, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device.\n */\nexport function isDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Dev {\n return check(obj, Device, logger, verbose);\n}\n","/** Defines a virtual device. */\nexport interface VirtualDevice {\n /** The virtual device type. */\n type: VirtualDeviceType;\n /** The virtual device properties */\n properties?: {\n /** The time to live value indicates the number of seconds the system access point will wait for a message before it assumes the device to be unresponsive. */\n ttl?: string;\n /** The display name for the virtual device. */\n displayname?: string;\n /** The virtual device flavor. */\n flavor?: string;\n /** The virtual device capabilities. */\n capabilities?: Array<number>;\n };\n}\n\n/** Defines the possible types of virtual devices. */\nexport enum VirtualDeviceType {\n /** A binary sensor */\n BinarySensor = \"BinarySensor\",\n /** A blind actuator */\n BlindActuator = \"BlindActuator\",\n /** A switching actuator */\n SwitchingActuator = \"SwitchingActuator\",\n /** A ceiling fan actuator */\n CeilingFanActuator = \"CeilingFanActuator\",\n /** A real time clock */\n RTC = \"RTC\",\n /** A dimmer actuator */\n DimActuator = \"DimActuator\",\n /** A charger for an electronic vehicle */\n EVCharging = \"evcharging\",\n /** A window sensor */\n WindowSensor = \"WindowSensor\",\n /** A simple door lock */\n SimpleDoorlock = \"simple_doorlock\",\n /** A shutter actuator */\n ShutterActuator = \"ShutterActuator\",\n /** A weather station */\n WeatherStation = \"WeatherStation\",\n /** A temperature sensor */\n WeatherTemperatureSensor = \"Weather-TemperatureSensor\",\n /** A wind sensor */\n WeatherWindSensor = \"Weather-WindSensor\",\n /** A brightness sensor */\n WeatherBrightnessSensor = \"Weather-BrightnessSensor\",\n /** A rain sensor */\n WeatherRainSensor = \"Weather-RainSensor\",\n /** A window actuator */\n WindowActuator = \"WindowActuator\",\n /** A detector for carbon monoxide (CO) */\n CODetector = \"CODetector\",\n /** A fire detector */\n FireDetector = \"FireDetector\",\n /** A KNX switch sensor */\n KNXSwitchSensor = \"KNX-SwitchSensor\",\n /** A media player */\n MediaPlayer = \"MediaPlayer\",\n /** A battery */\n EnergyBattery = \"EnergyBattery\",\n /** An inverter */\n EnergyInverter = \"EnergyInverter\",\n /** An energy meter */\n EnergyMeter = \"EnergyMeter\",\n /** A device combining inverter and battery characteristics */\n EnergyInverterBattery = \"EnergyInverterBattery\",\n /** A device combining inverter and energy meter characteristics */\n EnergyInverterMeter = \"EnergyInverterMeter\",\n /** A device combining inverter, battery and energy meter characteristics */\n EnergyInverterMeterBattery = \"EnergyInverterMeterBattery\",\n /** A device combining battery and energy meter characteristics */\n EnergyMeterBattery = \"EnergyMeterBattery\",\n /** An air quality sensor measuring carbon dioxide (CO2) */\n AirQualityCO2 = \"AirQualityCO2\",\n /** An air quality sensor measuring carbon monoxide (CO) */\n AirQualityCO = \"AirQualityCO\",\n /** An full air quality sensor */\n AirQualityFull = \"AirQualityFull\",\n /** An air quality sensor measuring humidity */\n AirQualityHumidity = \"AirQualityHumidity\",\n /** An air quality sensor measuring nitrogen dioxide (NO2) */\n AirQualityNO2 = \"AirQualityNO2\",\n /** An air quality sensor measuring ozone (O3) */\n AirQualityO3 = \"AirQualityO3\",\n /** An air quality sensor measuring coarse particulate matter with in the 10 micron scale */\n AirQualityPM10 = \"AirQualityPM10\",\n /** An air quality sensor measuring coarse particulate matter with in the 25 micron scale */\n AirQualityPM25 = \"AirQualityPM25\",\n /** An air quality sensor measuring barometric pressure */\n AirQualityPressure = \"AirQualityPressure\",\n /** An air quality sensor measuring temperature */\n AirQualityTemperature = \"AirQualityTemperature\",\n /** An air quality sensor measuring volatile organic compounds */\n AirQualityVOC = \"AirQualityVOC\",\n /** A version 2 energy meter */\n EnergyMeterV2 = \"EnergyMeterv2\",\n HomeApplianceLaundry = \"HomeAppliance-Laundry\",\n HVAC = \"HVAC\",\n SplitUnit = \"SplitUnit\",\n}\n","import { EventEmitter } from \"events\";\nimport {\n interval,\n type Observable,\n type SchedulerLike,\n Subject,\n type Subscription,\n switchMap,\n takeUntil,\n} from \"rxjs\";\nimport { type ClientOptions, type RawData, WebSocket } from \"ws\";\nimport {\n type Configuration,\n type DeviceList,\n type DeviceResponse,\n type GetDataPointResponse,\n isConfiguration,\n isDeviceList,\n isDeviceResponse,\n isGetDataPointResponse,\n isSetDataPointResponse,\n isWebSocketMessage,\n type Logger,\n type SetDataPointResponse,\n type VirtualDevice,\n type VirtualDeviceResponse,\n type WebSocketMessage,\n} from \"./model\";\nimport { isVirtualDeviceResponse } from \"./model/validator\";\n\n/** The HTTP request method */\ntype HttpRequestMethod = \"GET\" | \"POST\" | \"DELETE\" | \"PATCH\" | \"PUT\";\n\n/** The class representing a System Access Point. */\nexport class SystemAccessPoint extends EventEmitter {\n /** The basic authentication key used for requests. */\n public readonly basicAuthKey: string;\n private webSocket?: WebSocket;\n private readonly webSocketMessageSubject = new Subject<WebSocketMessage>();\n private readonly webSocketKeepaliveTimerReset$ = new Subject<void>();\n private readonly webSocketKeepaliveTimer$ =\n this.webSocketKeepaliveTimerReset$.pipe(\n switchMap(() =>\n interval(30000, this.scheduler).pipe(\n takeUntil(this.webSocketKeepaliveTimerReset$)\n )\n )\n );\n private webSocketKeepaliveSubscription?: Subscription;\n\n /**\n * Constructs a new SystemAccessPoint instance\n *\n * @constructor\n * @param hostName {string} The system access point host name.\n * @param userName {string} The user name that shall be used to authenticate with the system access point.\n * @param password {string} The password that shall be used to authenticate with the system access point.\n * @param tlsEnabled {boolean} Determines whether the communication with the system access point shall be protected by TLS.\n * @param verboseErrors {boolean} Determines whether verbose error messages shall be used, for example for message validation.\n * @param logger {Logger} The logger instance to be used. If no explicit implementation is provided, the this.logger will be used for logging.\n */\n constructor(\n private readonly hostName: string,\n readonly userName: string,\n readonly password: string,\n private readonly tlsEnabled = true,\n private readonly verboseErrors = false,\n private readonly logger: Logger = console,\n readonly scheduler?: SchedulerLike\n ) {\n super();\n\n // Create Basic Authentication key\n this.basicAuthKey = Buffer.from(`${userName}:${password}`, \"utf8\").toString(\n \"base64\"\n );\n }\n\n /**\n * Connects to the System Access Point web socket.\n * @param certificateVerification {boolean} Determines whether the TLS certificate presented by the server will be verified.\n */\n public connectWebSocket(certificateVerification: boolean = true): void {\n if (this.webSocket && this.webSocket.readyState === WebSocket.OPEN) {\n throw new Error(\"Web socket is already connected\");\n }\n\n this.webSocket = this.createWebSocket(certificateVerification);\n // (Re-)create the web socket keepalive timer\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n this.webSocketKeepaliveSubscription =\n this.webSocketKeepaliveTimer$.subscribe(() => {\n if (!(this.webSocket && this.webSocket.readyState === WebSocket.OPEN))\n return;\n\n this.logger.log(\"keepalive timer expired, sending ping message...\");\n this.webSocket.ping();\n });\n this.webSocketKeepaliveTimerReset$.next();\n }\n\n /**\n * Creates a new virtual device.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The serial number to be assigned to the device.\n * @param virtualDevice {VirtualDevice} The virtual device to be created.\n * @returns {Promise.<VirtualDeviceResponse>} The response to the virtual device request.\n */\n public async createVirtualDevice(\n sysApUuid: string,\n deviceSerial: string,\n virtualDevice: VirtualDevice\n ): Promise<VirtualDeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `virtualdevice/${sysApUuid}/${deviceSerial}`,\n JSON.stringify(virtualDevice)\n );\n\n // Process response\n return this.processRestResponse(response, isVirtualDeviceResponse);\n }\n\n private createWebSocket(certificateVerification: boolean): WebSocket {\n // Disabling certificate verification is discouraged, issue a warning\n if (this.tlsEnabled && !certificateVerification) {\n this.logger.warn(\n \"TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.\"\n );\n }\n\n const url = `${this.tlsEnabled ? \"wss\" : \"ws\"}://${\n this.hostName\n }/fhapi/v1/api/ws`;\n const options: ClientOptions = {\n rejectUnauthorized: this.tlsEnabled && certificateVerification,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n };\n const webSocket = new WebSocket(url, options);\n webSocket.on(\"error\", (error: Error) => {\n this.emit(\"websocket-error\", error);\n this.logger.error(\"Error received\", error);\n });\n webSocket.on(\"ping\", (data: Buffer) => {\n this.emit(\"websocket-ping\", data);\n this.logger.debug(\"Ping received\", data.toString(\"ascii\"));\n this.webSocketKeepaliveTimerReset$.next();\n webSocket.pong(data);\n this.logger.debug(\"Pong sent\", data.toString(\"ascii\"));\n });\n webSocket.on(\"pong\", (data: Buffer) => {\n this.emit(\"websocket-pong\", data);\n this.logger.debug(\"Pong received\", data.toString(\"ascii\"));\n });\n webSocket.on(\"unexpected-response\", (request, response) => {\n this.emit(\"websocket-unexpected-response\", request, response);\n this.logger.error(\"Unexpected response received\");\n });\n webSocket.on(\"upgrade\", (request) => {\n this.emit(\"websocket-upgrade\", request);\n this.logger.debug(\"Upgrade request received\");\n });\n webSocket.on(\"open\", () => {\n this.emit(\"websocket-open\");\n this.logger.log(\"Connection opened\");\n });\n webSocket.on(\"close\", (code, reason) => {\n this.emit(\"websocket-close\", code, reason);\n this.logger.log(\"Connection closed\");\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n });\n webSocket.on(\"message\", (data: RawData, isBinary: boolean) => {\n this.emit(\"websocket-message\", data, isBinary);\n this.webSocketKeepaliveTimerReset$.next();\n this.processWebSocketMessage(data, isBinary);\n });\n return webSocket;\n }\n\n /**\n * Disconnects from the System Access Point web socket.\n * @param force {boolean} Determines whether or not the connection will be closed forcibly.\n */\n public disconnectWebSocket(force: boolean = false): void {\n if (!this.webSocket || this.webSocket.readyState === WebSocket.CLOSED) {\n throw new Error(\"Web socket is not open\");\n }\n\n if (force) {\n this.webSocket.terminate();\n } else {\n this.webSocket.close();\n }\n }\n\n /**\n * Gets the configuration from the system access point.\n * @returns {Promise.<Configuration>} The system access point configuration.\n */\n public async getConfiguration(): Promise<Configuration> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n \"configuration\"\n );\n\n // Process response\n return this.processRestResponse(response, isConfiguration);\n }\n\n /**\n * Gets the device list from the system access point.\n * @returns {Promise.<DeviceList>} The requested device list.\n */\n public async getDeviceList(): Promise<DeviceList> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\"GET\", \"devicelist\");\n\n // Process response\n return this.processRestResponse(response, isDeviceList);\n }\n\n /**\n * Gets the specified device from the system access point.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @returns {Promise.<DeviceResponse>} The response to the device request.\n */\n public async getDevice(\n sysApUuid: string,\n deviceSerial: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `device/${sysApUuid}/${deviceSerial}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Gets the specified data point from the system access point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @returns {Promise.<GetDataPointResponse>} The response to the get data point request.\n */\n public async getDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string\n ): Promise<GetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`\n );\n\n // Process response\n return this.processRestResponse(response, isGetDataPointResponse);\n }\n\n /**\n * Gets the web socket messages.\n * @returns {Observable.<WebSocketMessage>} An observable that is updated with the messages received from the web socket.\n */\n public getWebSocketMessages(): Observable<WebSocketMessage> {\n return this.webSocketMessageSubject.asObservable();\n }\n\n /**\n * Sets a new value for the specificed data point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @param value {string} The new value to be set.\n * @returns {Promise.<SetDataPointResponse>} The response to the set data point request.\n */\n public async setDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string,\n value: string\n ): Promise<SetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`,\n value\n );\n\n // Process response\n return this.processRestResponse(response, isSetDataPointResponse);\n }\n\n /**\n * Triggeres the given action for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param action {string} The action to be triggered.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async triggerProxyDevice(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n action: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/action/${action}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Sets the given value for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param value {string} The value to be set.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async setProxyDeviceValue(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n value: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/value/${value}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n private async fetchDataViaRest(\n method: HttpRequestMethod,\n route: string,\n body?: RequestInit[\"body\"]\n ): Promise<Response> {\n // Set up request info\n const info = `${this.tlsEnabled ? \"https\" : \"http\"}://${\n this.hostName\n }/fhapi/v1/api/rest/${route}`;\n\n // Set up request init\n const init: RequestInit = {\n method: method,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n body: body,\n };\n\n // Get response from system access point\n return fetch(info, init);\n }\n\n private async processRestResponse<TResponse>(\n response: Response,\n typeGuard: (\n obj: unknown,\n logger: Logger,\n verbose: boolean\n ) => obj is TResponse\n ): Promise<TResponse> {\n let body: unknown;\n let message: string;\n\n // Process response\n switch (response.status) {\n case 200:\n body = await response.json();\n if (!typeGuard(body, this.logger, this.verboseErrors)) {\n message = \"Received message has an unexpected type!\";\n this.logger.error(message, body);\n throw new Error(message);\n }\n\n return body;\n case 401:\n message = \"Authentication information is missing or invalid.\";\n this.logger.error(message);\n throw new Error(message);\n case 502:\n message = await response.text();\n this.logger.error(message);\n throw new Error(message);\n default:\n message = `Received HTTP ${\n response.status\n } status code unexpectedly: ${await response.text()}`;\n this.logger.error(message);\n throw new Error(message);\n }\n }\n\n private processWebSocketMessage(data: RawData, isBinary: boolean): void {\n // Do not process binary messages\n if (isBinary) {\n this.logger.warn(\n \"Binary message received. Binary messages are not processed.\"\n );\n return;\n }\n\n this.logger.debug(\"Message received\");\n /*\n * Deserialize the message.\n * The message is expected to be deserializable as a web socket message.\n * If that is not the case, that's an error case.\n */\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const serialized = data.toString();\n const message: unknown = JSON.parse(serialized);\n\n if (isWebSocketMessage(message, this.logger, this.verboseErrors)) {\n this.webSocketMessageSubject.next(message);\n return;\n }\n\n this.logger.error(\"Received message has an unexpected type!\", serialized);\n }\n}\n"],"mappings":"mbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uBAAAE,EAAA,sBAAAC,GAAA,cAAAC,GAAA,oBAAAC,EAAA,aAAAC,GAAA,iBAAAC,EAAA,qBAAAC,EA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ACH,MAAAA,EAAU,MAAM5B,EAAS,KAAK,EAC9B,KAAK,OAAO,MAAM4B,CAAO,EACnB,IAAI,MAAMA,CAAO,EACzB,QACE,MAAAA,EAAU,iBACR5B,EAAS,MACX,8BAA8B,MAAMA,EAAS,KAAK,CAAC,GACnD,KAAK,OAAO,MAAM4B,CAAO,EACnB,IAAI,MAAMA,CAAO,CAC3B,CACF,CAEQ,wBAAwBtB,EAAeI,EAAyB,CAEtE,GAAIA,EAAU,CACZ,KAAK,OAAO,KACV,6DACF,EACA,MACF,CAEA,KAAK,OAAO,MAAM,kBAAkB,EAOpC,IAAMmB,EAAavB,EAAK,SAAS,EAC3BsB,EAAmB,KAAK,MAAMC,CAAU,EAE9C,GAAIC,EAAmBF,EAAS,KAAK,OAAQ,KAAK,aAAa,EAAG,CAChE,KAAK,wBAAwB,KAAKA,CAAO,EACzC,MACF,CAEA,KAAK,OAAO,MAAM,2CAA4CC,CAAU,CAC1E,CACF","names":["index_exports","__export","SystemAccessPoint","VirtualDeviceType","isChannel","isConfiguration","isDevice","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isWebSocketMessage","__toCommonJS","import_ts_interface_checker","Channel","ChannelTypeSuite","import_ts_interface_checker","Configuration","ConfigurationTypeSuite","import_ts_interface_checker","Device","DeviceTypeSuite","import_ts_interface_checker","DeviceList","DeviceListTypeSuite","import_ts_interface_checker","DeviceResponse","DeviceResponseTypeSuite","import_ts_interface_checker","Devices","DevicesTypeSuite","import_ts_interface_checker","Error","ErrorTypeSuite","import_ts_interface_checker","Floors","FloorsTypeSuite","import_ts_interface_checker","GetDataPointResponse","GetDataPointResponseTypeSuite","import_ts_interface_checker","InOutPut","InOutPutTypeSuite","import_ts_interface_checker","Rooms","RoomsTypeSuite","import_ts_interface_checker","ScenesTriggered","ScenesTriggeredTypeSuite","import_ts_interface_checker","SetDataPointResponse","SetDataPointResponseTypeSuite","import_ts_interface_checker","SysAP","SysApTypeSuite","import_ts_interface_checker","Users","UsersTypeSuite","import_ts_interface_checker","VirtualDevice","VirtualDeviceType","VirtualDeviceTypeSuite","import_ts_interface_checker","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","import_ts_interface_checker","WebSocketMessage","WebSocketMessageTypeSuite","import_ts_interface_checker","VirtualDeviceType","Channel","ChannelTypeSuite","InOutPutTypeSuite","Configuration","ConfigurationTypeSuite","DevicesTypeSuite","DeviceTypeSuite","FloorsTypeSuite","RoomsTypeSuite","SysApTypeSuite","UsersTypeSuite","ErrorTypeSuite","Device","DeviceList","DeviceListTypeSuite","DeviceResponse","DeviceResponseTypeSuite","GetDataPointResponse","GetDataPointResponseTypeSuite","SetDataPointResponse","SetDataPointResponseTypeSuite","VirtualDevice","VirtualDeviceTypeSuite","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","WebSocketMessage","WebSocketMessageTypeSuite","ScenesTriggeredTypeSuite","check","obj","checker","logger","verbose","error","isWebSocketMessage","isConfiguration","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isChannel","isDevice","import_events","import_rxjs","import_ws","SystemAccessPoint","hostName","userName","password","tlsEnabled","verboseErrors","logger","scheduler","certificateVerification","sysApUuid","deviceSerial","virtualDevice","response","isVirtualDeviceResponse","url","options","webSocket","error","data","request","code","reason","isBinary","force","isConfiguration","isDeviceList","isDeviceResponse","channel","dataPoint","isGetDataPointResponse","value","isSetDataPointResponse","deviceClass","action","method","route","body","info","init","typeGuard","message","serialized","isWebSocketMessage"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/model/validation/channel-ti.ts","../src/model/validation/configuration-ti.ts","../src/model/validation/device-ti.ts","../src/model/validation/device-list-ti.ts","../src/model/validation/device-response-ti.ts","../src/model/validation/devices-ti.ts","../src/model/validation/error-ti.ts","../src/model/validation/floors-ti.ts","../src/model/validation/get-data-point-response-ti.ts","../src/model/validation/in-out-put-ti.ts","../src/model/validation/rooms-ti.ts","../src/model/validation/scenes-triggered-ti.ts","../src/model/validation/set-data-point-response-ti.ts","../src/model/validation/sys-ap-ti.ts","../src/model/validation/users-ti.ts","../src/model/validation/virtual-device-ti.ts","../src/model/validation/virtual-device-response-ti.ts","../src/model/validation/websocket-message-ti.ts","../src/model/validator.ts","../src/model/virtual-device.ts","../src/system-access-point.ts"],"sourcesContent":["export * from \"./model\";\nexport { SystemAccessPoint } from \"./system-access-point\";\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Channel = iface([], {\n displayName: opt(\"string\"),\n functionID: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n inputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n outputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n type: opt(\"string\"),\n});\n\nexport const ChannelTypeSuite: ITypeSuite = {\n Channel,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Configuration = iface([], {\n [indexKey]: \"SysAP\",\n});\n\nexport const ConfigurationTypeSuite: ITypeSuite = {\n Configuration,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Device = iface([], {\n displayName: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n interface: opt(\"string\"),\n nativeId: opt(\"string\"),\n channels: opt(\n iface([], {\n [indexKey]: \"Channel\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n});\n\nexport const DeviceTypeSuite: ITypeSuite = {\n Device,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceList = iface([], {\n [indexKey]: array(\"string\"),\n});\n\nexport const DeviceListTypeSuite: ITypeSuite = {\n DeviceList,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: \"Devices\",\n }),\n});\n\nexport const DeviceResponseTypeSuite: ITypeSuite = {\n DeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Devices = iface([], {\n [indexKey]: \"Device\",\n});\n\nexport const DevicesTypeSuite: ITypeSuite = {\n Devices,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface } from \"ts-interface-checker\";\n\nconst ErrorType = iface([], {\n code: \"string\",\n detail: \"string\",\n title: \"string\",\n});\n\nexport const ErrorTypeSuite: ITypeSuite = {\n Error: ErrorType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Floors = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n rooms: \"Rooms\",\n }),\n});\n\nexport const FloorsTypeSuite: ITypeSuite = {\n Floors,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst GetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n values: array(\"string\"),\n }),\n});\n\nexport const GetDataPointResponseTypeSuite: ITypeSuite = {\n GetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst InOutPut = iface([], {\n value: opt(\"string\"),\n pairingID: opt(\"number\"),\n});\n\nexport const InOutPutTypeSuite: ITypeSuite = {\n InOutPut,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Rooms = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n }),\n});\n\nexport const RoomsTypeSuite: ITypeSuite = {\n Rooms,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst ScenesTriggered = iface([], {\n [indexKey]: iface([], {\n channels: iface([], {\n [indexKey]: iface([], {\n outputs: iface([], {\n [indexKey]: iface([], {\n value: \"string\",\n pairingID: \"number\",\n }),\n }),\n }),\n }),\n }),\n});\n\nexport const ScenesTriggeredTypeSuite: ITypeSuite = {\n ScenesTriggered,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst SetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n [indexKey]: \"string\",\n }),\n});\n\nexport const SetDataPointResponseTypeSuite: ITypeSuite = {\n SetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst SysAP = iface([], {\n devices: \"Devices\",\n floorplan: iface([], {\n floors: \"Floors\",\n }),\n sysapName: \"string\",\n users: \"Users\",\n error: opt(\"Error\"),\n});\n\nexport const SysApTypeSuite: ITypeSuite = {\n SysAP,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst Users = iface([], {\n [indexKey]: iface([], {\n enabled: \"boolean\",\n flags: array(\"string\"),\n grantedPermissions: array(\"string\"),\n jid: \"string\",\n name: \"string\",\n requestedPermissions: array(\"string\"),\n role: \"string\",\n }),\n});\n\nexport const UsersTypeSuite: ITypeSuite = {\n Users,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, enumtype, iface, opt } from \"ts-interface-checker\";\n\nconst VirtualDevice = iface([], {\n type: \"VirtualDeviceType\",\n properties: opt(\n iface([], {\n ttl: opt(\"string\"),\n displayname: opt(\"string\"),\n flavor: opt(\"string\"),\n capabilities: opt(array(\"number\")),\n })\n ),\n});\n\nexport const VirtualDeviceType = enumtype({\n BinarySensor: \"BinarySensor\",\n BlindActuator: \"BlindActuator\",\n SwitchingActuator: \"SwitchingActuator\",\n CeilingFanActuator: \"CeilingFanActuator\",\n RTC: \"RTC\",\n DimActuator: \"DimActuator\",\n EVCharging: \"evcharging\",\n WindowSensor: \"WindowSensor\",\n SimpleDoorlock: \"simple_doorlock\",\n ShutterActuator: \"ShutterActuator\",\n WeatherStation: \"WeatherStation\",\n WeatherTemperatureSensor: \"Weather-TemperatureSensor\",\n WeatherWindSensor: \"Weather-WindSensor\",\n WeatherBrightnessSensor: \"Weather-BrightnessSensor\",\n WeatherRainSensor: \"Weather-RainSensor\",\n WindowActuator: \"WindowActuator\",\n CODetector: \"CODetector\",\n FireDetector: \"FireDetector\",\n KNXSwitchSensor: \"KNX-SwitchSensor\",\n MediaPlayer: \"MediaPlayer\",\n EnergyBattery: \"EnergyBattery\",\n EnergyInverter: \"EnergyInverter\",\n EnergyMeter: \"EnergyMeter\",\n EnergyInverterBattery: \"EnergyInverterBattery\",\n EnergyInverterMeter: \"EnergyInverterMeter\",\n EnergyInverterMeterBattery: \"EnergyInverterMeterBattery\",\n EnergyMeterBattery: \"EnergyMeterBattery\",\n AirQualityCO2: \"AirQualityCO2\",\n AirQualityCO: \"AirQualityCO\",\n AirQualityFull: \"AirQualityFull\",\n AirQualityHumidity: \"AirQualityHumidity\",\n AirQualityNO2: \"AirQualityNO2\",\n AirQualityO3: \"AirQualityO3\",\n AirQualityPM10: \"AirQualityPM10\",\n AirQualityPM25: \"AirQualityPM25\",\n AirQualityPressure: \"AirQualityPressure\",\n AirQualityTemperature: \"AirQualityTemperature\",\n AirQualityVOC: \"AirQualityVOC\",\n EnergyMeterV2: \"EnergyMeterv2\",\n HomeApplianceLaundry: \"HomeAppliance-Laundry\",\n HVAC: \"HVAC\",\n SplitUnit: \"SplitUnit\",\n});\n\nexport const VirtualDeviceTypeSuite: ITypeSuite = {\n VirtualDevice,\n VirtualDeviceType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst VirtualDeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: iface([], {\n [indexKey]: iface([], {\n serial: \"string\",\n }),\n }),\n }),\n});\n\nexport const VirtualDeviceResponseTypeSuite: ITypeSuite = {\n VirtualDeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst WebSocketMessage = iface([], {\n [indexKey]: iface([], {\n datapoints: iface([], {\n [indexKey]: \"string\",\n }),\n devices: \"Devices\",\n devicesAdded: array(\"string\"),\n devicesRemoved: array(\"string\"),\n scenesTriggered: \"ScenesTriggered\",\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n }),\n});\n\nexport const WebSocketMessageTypeSuite: ITypeSuite = {\n WebSocketMessage,\n};\n","import {\n ChannelTypeSuite,\n DeviceTypeSuite,\n DevicesTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite,\n WebSocketMessageTypeSuite,\n DeviceListTypeSuite,\n SetDataPointResponseTypeSuite,\n GetDataPointResponseTypeSuite,\n ConfigurationTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite,\n DeviceResponseTypeSuite,\n VirtualDeviceTypeSuite,\n VirtualDeviceResponseTypeSuite,\n} from \"./validation\";\nimport type { Checker } from \"ts-interface-checker\";\nimport { createCheckers } from \"ts-interface-checker\";\nimport { type WebSocketMessage as Message } from \"./websocket-message\";\nimport { type Configuration as Config } from \"./configuration\";\nimport { type Channel as Chan } from \"./channel\";\nimport { type Device as Dev } from \"./device\";\nimport { type DeviceList as DevList } from \"./device-list\";\nimport { type DeviceResponse as DevResponse } from \"./device-response\";\nimport { type GetDataPointResponse as GetResponse } from \"./get-data-point-response\";\nimport { type SetDataPointResponse as SetResponse } from \"./set-data-point-response\";\nimport { type VirtualDeviceResponse as VDeviceResponse } from \"./virtual-device-response\";\nimport { type VirtualDevice as VDevice } from \"./virtual-device\";\nimport { type Logger } from \"./logger\";\n\nconst { Channel } = createCheckers(ChannelTypeSuite, InOutPutTypeSuite);\n\nconst { Configuration } = createCheckers(\n ConfigurationTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite\n);\n\nconst { Device } = createCheckers(\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { DeviceList } = createCheckers(DeviceListTypeSuite);\n\nconst { DeviceResponse } = createCheckers(\n DeviceResponseTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { GetDataPointResponse } = createCheckers(GetDataPointResponseTypeSuite);\n\nconst { SetDataPointResponse } = createCheckers(SetDataPointResponseTypeSuite);\n\nconst { VirtualDevice } = createCheckers(VirtualDeviceTypeSuite);\n\nconst { VirtualDeviceResponse } = createCheckers(\n VirtualDeviceResponseTypeSuite\n);\n\nconst { WebSocketMessage } = createCheckers(\n WebSocketMessageTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite\n);\n\nfunction check(\n obj: unknown,\n checker: Checker,\n logger: Logger,\n verbose: boolean\n): boolean {\n if (verbose) {\n try {\n checker.check(obj);\n return true;\n } catch (error) {\n logger.error(\"Object validation failed!\", error);\n return false;\n }\n }\n\n return checker.test(obj);\n}\n\n/**\n * Determines whether the specified object is a web socket message.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a web socket message.\n */\nexport function isWebSocketMessage(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Message {\n return check(obj, WebSocketMessage, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a configuration.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a configuration.\n */\nexport function isConfiguration(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Config {\n return check(obj, Configuration, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device list.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device list.\n */\nexport function isDeviceList(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevList {\n return check(obj, DeviceList, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device response.\n */\nexport function isDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevResponse {\n return check(obj, DeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a get data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a get data point request.\n */\nexport function isGetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is GetResponse {\n return check(obj, GetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a set data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a set data point request.\n */\nexport function isSetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is SetResponse {\n return check(obj, SetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a virtual device.\n */\nexport function isVirtualDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDevice {\n return check(obj, VirtualDevice, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a virtual device request.\n */\nexport function isVirtualDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDeviceResponse {\n return check(obj, VirtualDeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a channel.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a channel.\n */\nexport function isChannel(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Chan {\n return check(obj, Channel, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device.\n */\nexport function isDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Dev {\n return check(obj, Device, logger, verbose);\n}\n","/** Defines a virtual device. */\nexport interface VirtualDevice {\n /** The virtual device type. */\n type: VirtualDeviceType;\n /** The virtual device properties */\n properties?: {\n /** The time to live value indicates the number of seconds the system access point will wait for a message before it assumes the device to be unresponsive. */\n ttl?: string;\n /** The display name for the virtual device. */\n displayname?: string;\n /** The virtual device flavor. */\n flavor?: string;\n /** The virtual device capabilities. */\n capabilities?: Array<number>;\n };\n}\n\n/** Defines the possible types of virtual devices. */\nexport enum VirtualDeviceType {\n /** A binary sensor */\n BinarySensor = \"BinarySensor\",\n /** A blind actuator */\n BlindActuator = \"BlindActuator\",\n /** A switching actuator */\n SwitchingActuator = \"SwitchingActuator\",\n /** A ceiling fan actuator */\n CeilingFanActuator = \"CeilingFanActuator\",\n /** A real time clock */\n RTC = \"RTC\",\n /** A dimmer actuator */\n DimActuator = \"DimActuator\",\n /** A charger for an electronic vehicle */\n EVCharging = \"evcharging\",\n /** A window sensor */\n WindowSensor = \"WindowSensor\",\n /** A simple door lock */\n SimpleDoorlock = \"simple_doorlock\",\n /** A shutter actuator */\n ShutterActuator = \"ShutterActuator\",\n /** A weather station */\n WeatherStation = \"WeatherStation\",\n /** A temperature sensor */\n WeatherTemperatureSensor = \"Weather-TemperatureSensor\",\n /** A wind sensor */\n WeatherWindSensor = \"Weather-WindSensor\",\n /** A brightness sensor */\n WeatherBrightnessSensor = \"Weather-BrightnessSensor\",\n /** A rain sensor */\n WeatherRainSensor = \"Weather-RainSensor\",\n /** A window actuator */\n WindowActuator = \"WindowActuator\",\n /** A detector for carbon monoxide (CO) */\n CODetector = \"CODetector\",\n /** A fire detector */\n FireDetector = \"FireDetector\",\n /** A KNX switch sensor */\n KNXSwitchSensor = \"KNX-SwitchSensor\",\n /** A media player */\n MediaPlayer = \"MediaPlayer\",\n /** A battery */\n EnergyBattery = \"EnergyBattery\",\n /** An inverter */\n EnergyInverter = \"EnergyInverter\",\n /** An energy meter */\n EnergyMeter = \"EnergyMeter\",\n /** A device combining inverter and battery characteristics */\n EnergyInverterBattery = \"EnergyInverterBattery\",\n /** A device combining inverter and energy meter characteristics */\n EnergyInverterMeter = \"EnergyInverterMeter\",\n /** A device combining inverter, battery and energy meter characteristics */\n EnergyInverterMeterBattery = \"EnergyInverterMeterBattery\",\n /** A device combining battery and energy meter characteristics */\n EnergyMeterBattery = \"EnergyMeterBattery\",\n /** An air quality sensor measuring carbon dioxide (CO2) */\n AirQualityCO2 = \"AirQualityCO2\",\n /** An air quality sensor measuring carbon monoxide (CO) */\n AirQualityCO = \"AirQualityCO\",\n /** An full air quality sensor */\n AirQualityFull = \"AirQualityFull\",\n /** An air quality sensor measuring humidity */\n AirQualityHumidity = \"AirQualityHumidity\",\n /** An air quality sensor measuring nitrogen dioxide (NO2) */\n AirQualityNO2 = \"AirQualityNO2\",\n /** An air quality sensor measuring ozone (O3) */\n AirQualityO3 = \"AirQualityO3\",\n /** An air quality sensor measuring coarse particulate matter with in the 10 micron scale */\n AirQualityPM10 = \"AirQualityPM10\",\n /** An air quality sensor measuring coarse particulate matter with in the 25 micron scale */\n AirQualityPM25 = \"AirQualityPM25\",\n /** An air quality sensor measuring barometric pressure */\n AirQualityPressure = \"AirQualityPressure\",\n /** An air quality sensor measuring temperature */\n AirQualityTemperature = \"AirQualityTemperature\",\n /** An air quality sensor measuring volatile organic compounds */\n AirQualityVOC = \"AirQualityVOC\",\n /** A version 2 energy meter */\n EnergyMeterV2 = \"EnergyMeterv2\",\n HomeApplianceLaundry = \"HomeAppliance-Laundry\",\n HVAC = \"HVAC\",\n SplitUnit = \"SplitUnit\",\n}\n","import { EventEmitter } from \"node:events\";\nimport {\n interval,\n type Observable,\n type SchedulerLike,\n Subject,\n type Subscription,\n switchMap,\n takeUntil,\n} from \"rxjs\";\nimport { type ClientOptions, type RawData, WebSocket } from \"ws\";\nimport {\n type Configuration,\n type DeviceList,\n type DeviceResponse,\n type GetDataPointResponse,\n isConfiguration,\n isDeviceList,\n isDeviceResponse,\n isGetDataPointResponse,\n isSetDataPointResponse,\n isWebSocketMessage,\n type Logger,\n type SetDataPointResponse,\n type VirtualDevice,\n type VirtualDeviceResponse,\n type WebSocketMessage,\n} from \"./model\";\nimport { isVirtualDeviceResponse } from \"./model/validator\";\n\n/** The HTTP request method */\ntype HttpRequestMethod = \"GET\" | \"POST\" | \"DELETE\" | \"PATCH\" | \"PUT\";\n\n/** The class representing a System Access Point. */\nexport class SystemAccessPoint extends EventEmitter {\n /** The basic authentication key used for requests. */\n public readonly basicAuthKey: string;\n private webSocket?: WebSocket;\n private readonly webSocketMessageSubject = new Subject<WebSocketMessage>();\n private readonly webSocketKeepaliveTimerReset$ = new Subject<void>();\n private readonly webSocketKeepaliveTimer$ =\n this.webSocketKeepaliveTimerReset$.pipe(\n switchMap(() =>\n interval(30000, this.scheduler).pipe(\n takeUntil(this.webSocketKeepaliveTimerReset$)\n )\n )\n );\n private webSocketKeepaliveSubscription?: Subscription;\n\n /**\n * Constructs a new SystemAccessPoint instance\n *\n * @constructor\n * @param hostName {string} The system access point host name.\n * @param userName {string} The user name that shall be used to authenticate with the system access point.\n * @param password {string} The password that shall be used to authenticate with the system access point.\n * @param tlsEnabled {boolean} Determines whether the communication with the system access point shall be protected by TLS.\n * @param verboseErrors {boolean} Determines whether verbose error messages shall be used, for example for message validation.\n * @param logger {Logger} The logger instance to be used. If no explicit implementation is provided, the this.logger will be used for logging.\n */\n constructor(\n private readonly hostName: string,\n readonly userName: string,\n readonly password: string,\n private readonly tlsEnabled = true,\n private readonly verboseErrors = false,\n private readonly logger: Logger = console,\n readonly scheduler?: SchedulerLike\n ) {\n super();\n\n // Create Basic Authentication key\n this.basicAuthKey = Buffer.from(`${userName}:${password}`, \"utf8\").toString(\n \"base64\"\n );\n }\n\n /**\n * Connects to the System Access Point web socket.\n * @param certificateVerification {boolean} Determines whether the TLS certificate presented by the server will be verified.\n */\n public connectWebSocket(certificateVerification: boolean = true): void {\n if (this.webSocket?.readyState === WebSocket.OPEN) {\n throw new Error(\"Web socket is already connected\");\n }\n\n this.webSocket = this.createWebSocket(certificateVerification);\n // (Re-)create the web socket keepalive timer\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n this.webSocketKeepaliveSubscription =\n this.webSocketKeepaliveTimer$.subscribe(() => {\n if (this.webSocket?.readyState !== WebSocket.OPEN) return;\n\n this.logger.log(\"keepalive timer expired, sending ping message...\");\n this.webSocket.ping();\n });\n this.webSocketKeepaliveTimerReset$.next();\n }\n\n /**\n * Creates a new virtual device.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The serial number to be assigned to the device.\n * @param virtualDevice {VirtualDevice} The virtual device to be created.\n * @returns {Promise.<VirtualDeviceResponse>} The response to the virtual device request.\n */\n public async createVirtualDevice(\n sysApUuid: string,\n deviceSerial: string,\n virtualDevice: VirtualDevice\n ): Promise<VirtualDeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `virtualdevice/${sysApUuid}/${deviceSerial}`,\n JSON.stringify(virtualDevice)\n );\n\n // Process response\n return this.processRestResponse(response, isVirtualDeviceResponse);\n }\n\n private createWebSocket(certificateVerification: boolean): WebSocket {\n // Disabling certificate verification is discouraged, issue a warning\n if (this.tlsEnabled && !certificateVerification) {\n this.logger.warn(\n \"TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.\"\n );\n }\n\n const url = `${this.tlsEnabled ? \"wss\" : \"ws\"}://${\n this.hostName\n }/fhapi/v1/api/ws`;\n const options: ClientOptions = {\n rejectUnauthorized: this.tlsEnabled && certificateVerification,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n };\n const webSocket = new WebSocket(url, options);\n webSocket.on(\"error\", (error: Error) => {\n this.emit(\"websocket-error\", error);\n this.logger.error(\"Error received\", error);\n });\n webSocket.on(\"ping\", (data: Buffer) => {\n this.emit(\"websocket-ping\", data);\n this.logger.debug(\"Ping received\", data.toString(\"ascii\"));\n this.webSocketKeepaliveTimerReset$.next();\n webSocket.pong(data);\n this.logger.debug(\"Pong sent\", data.toString(\"ascii\"));\n });\n webSocket.on(\"pong\", (data: Buffer) => {\n this.emit(\"websocket-pong\", data);\n this.logger.debug(\"Pong received\", data.toString(\"ascii\"));\n });\n webSocket.on(\"unexpected-response\", (request, response) => {\n this.emit(\"websocket-unexpected-response\", request, response);\n this.logger.error(\"Unexpected response received\");\n });\n webSocket.on(\"upgrade\", (request) => {\n this.emit(\"websocket-upgrade\", request);\n this.logger.debug(\"Upgrade request received\");\n });\n webSocket.on(\"open\", () => {\n this.emit(\"websocket-open\");\n this.logger.log(\"Connection opened\");\n });\n webSocket.on(\"close\", (code, reason) => {\n this.emit(\"websocket-close\", code, reason);\n this.logger.log(\"Connection closed\");\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n });\n webSocket.on(\"message\", (data: RawData, isBinary: boolean) => {\n this.emit(\"websocket-message\", data, isBinary);\n this.webSocketKeepaliveTimerReset$.next();\n this.processWebSocketMessage(data, isBinary);\n });\n return webSocket;\n }\n\n /**\n * Disconnects from the System Access Point web socket.\n * @param force {boolean} Determines whether or not the connection will be closed forcibly.\n */\n public disconnectWebSocket(force: boolean = false): void {\n if (!this.webSocket || this.webSocket.readyState === WebSocket.CLOSED) {\n throw new Error(\"Web socket is not open\");\n }\n\n if (force) {\n this.webSocket.terminate();\n } else {\n this.webSocket.close();\n }\n }\n\n /**\n * Gets the configuration from the system access point.\n * @returns {Promise.<Configuration>} The system access point configuration.\n */\n public async getConfiguration(): Promise<Configuration> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n \"configuration\"\n );\n\n // Process response\n return this.processRestResponse(response, isConfiguration);\n }\n\n /**\n * Gets the device list from the system access point.\n * @returns {Promise.<DeviceList>} The requested device list.\n */\n public async getDeviceList(): Promise<DeviceList> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\"GET\", \"devicelist\");\n\n // Process response\n return this.processRestResponse(response, isDeviceList);\n }\n\n /**\n * Gets the specified device from the system access point.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @returns {Promise.<DeviceResponse>} The response to the device request.\n */\n public async getDevice(\n sysApUuid: string,\n deviceSerial: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `device/${sysApUuid}/${deviceSerial}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Gets the specified data point from the system access point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @returns {Promise.<GetDataPointResponse>} The response to the get data point request.\n */\n public async getDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string\n ): Promise<GetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`\n );\n\n // Process response\n return this.processRestResponse(response, isGetDataPointResponse);\n }\n\n /**\n * Gets the web socket messages.\n * @returns {Observable.<WebSocketMessage>} An observable that is updated with the messages received from the web socket.\n */\n public getWebSocketMessages(): Observable<WebSocketMessage> {\n return this.webSocketMessageSubject.asObservable();\n }\n\n /**\n * Sets a new value for the specificed data point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @param value {string} The new value to be set.\n * @returns {Promise.<SetDataPointResponse>} The response to the set data point request.\n */\n public async setDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string,\n value: string\n ): Promise<SetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`,\n value\n );\n\n // Process response\n return this.processRestResponse(response, isSetDataPointResponse);\n }\n\n /**\n * Triggeres the given action for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param action {string} The action to be triggered.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async triggerProxyDevice(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n action: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/action/${action}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Sets the given value for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param value {string} The value to be set.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async setProxyDeviceValue(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n value: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/value/${value}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n private async fetchDataViaRest(\n method: HttpRequestMethod,\n route: string,\n body?: RequestInit[\"body\"]\n ): Promise<Response> {\n // Set up request info\n const info = `${this.tlsEnabled ? \"https\" : \"http\"}://${\n this.hostName\n }/fhapi/v1/api/rest/${route}`;\n\n // Set up request init\n const init: RequestInit = {\n method: method,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n body: body,\n };\n\n // Get response from system access point\n return fetch(info, init);\n }\n\n private async processRestResponse<TResponse>(\n response: Response,\n typeGuard: (\n obj: unknown,\n logger: Logger,\n verbose: boolean\n ) => obj is TResponse\n ): Promise<TResponse> {\n let body: unknown;\n let message: string;\n\n // Process response\n switch (response.status) {\n case 200:\n body = await response.json();\n if (!typeGuard(body, this.logger, this.verboseErrors)) {\n message = \"Received message has an unexpected type!\";\n this.logger.error(message, body);\n throw new Error(message);\n }\n\n return body;\n case 401:\n message = \"Authentication information is missing or invalid.\";\n this.logger.error(message);\n throw new Error(message);\n case 502:\n message = await response.text();\n this.logger.error(message);\n throw new Error(message);\n default:\n message = `Received HTTP ${\n response.status\n } status code unexpectedly: ${await response.text()}`;\n this.logger.error(message);\n throw new Error(message);\n }\n }\n\n private processWebSocketMessage(data: RawData, isBinary: boolean): void {\n // Do not process binary messages\n if (isBinary) {\n this.logger.warn(\n \"Binary message received. Binary messages are not processed.\"\n );\n return;\n }\n\n this.logger.debug(\"Message received\");\n /*\n * Deserialize the message.\n * The message is expected to be deserializable as a web socket message.\n * If that is not the case, that's an error case.\n */\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const serialized = data.toString();\n const message: unknown = JSON.parse(serialized);\n\n if (isWebSocketMessage(message, this.logger, this.verboseErrors)) {\n this.webSocketMessageSubject.next(message);\n return;\n }\n\n this.logger.error(\"Received message has an unexpected type!\", serialized);\n }\n}\n"],"mappings":"mbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uBAAAE,EAAA,sBAAAC,GAAA,cAAAC,GAAA,oBAAAC,EAAA,aAAAC,GAAA,iBAAAC,EAAA,qBAAAC,EAAA,2BAAAC,EAAA,2BAAAC,EAAA,oBAAAC,GAAA,4BAAAC,EAAA,uBAAAC,IAAA,eAAAC,GAAAd,ICCA,IAAAe,EAAqC,gCAE/BC,MAAU,SAAM,CAAC,EAAG,CACxB,eAAa,OAAI,QAAQ,EACzB,cAAY,OAAI,QAAQ,EACxB,QAAM,OAAI,QAAQ,EAClB,SAAO,OAAI,QAAQ,EACnB,UAAQ,UACN,SAAM,CAAC,EAAG,CACR,CAAC,UAAQ,EAAG,UACd,CAAC,CACH,EACA,WAAS,UACP,SAAM,CAAC,EAAG,CACR,CAAC,UAAQ,EAAG,UACd,CAAC,CACH,EACA,cAAY,UACV,SAAM,CAAC,EAAG,CACR,CAAC,UAAQ,EAAG,QACd,CAAC,CACH,EACA,QAAM,OAAI,QAAQ,CACpB,CAAC,EAEYC,EAA+B,CAC1C,QAAAD,EACF,EC3BA,IAAAE,EAAgC,gCAE1BC,MAAgB,SAAM,CAAC,EAAG,CAC9B,CAAC,UAAQ,EAAG,OACd,CAAC,E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KAAK,WAAa,QAAU,MAAM,MAChD,KAAK,QACP,sBAAsBF,CAAK,GAGrBG,EAAoB,CACxB,OAAQJ,EACR,QAAS,CACP,cAAe,SAAS,KAAK,YAAY,EAC3C,EACA,KAAME,CACR,EAGA,OAAO,MAAMC,EAAMC,CAAI,CACzB,CAEA,MAAc,oBACZ1B,EACA2B,EAKoB,CACpB,IAAIH,EACAI,EAGJ,OAAQ5B,EAAS,OAAQ,CACvB,IAAK,KAEH,GADAwB,EAAO,MAAMxB,EAAS,KAAK,EACvB,CAAC2B,EAAUH,EAAM,KAAK,OAAQ,KAAK,aAAa,EAClD,MAAAI,EAAU,2CACV,KAAK,OAAO,MAAMA,EAASJ,CAAI,EACzB,IAAI,MAAMI,CAAO,EAGzB,OAAOJ,EACT,IAAK,KACH,MAAAI,EAAU,oDACV,KAAK,OAAO,MAAMA,CAAO,EACnB,IAAI,MAAMA,CAAO,EACzB,IAAK,KACH,MAAAA,EAAU,MAAM5B,EAAS,KAAK,EAC9B,KAAK,OAAO,MAAM4B,CAAO,EACnB,IAAI,MAAMA,CAAO,EACzB,QACE,MAAAA,EAAU,iBACR5B,EAAS,MACX,8BAA8B,MAAMA,EAAS,KAAK,CAAC,GACnD,KAAK,OAAO,MAAM4B,CAAO,EACnB,IAAI,MAAMA,CAAO,CAC3B,CACF,CAEQ,wBAAwBtB,EAAeI,EAAyB,CAEtE,GAAIA,EAAU,CACZ,KAAK,OAAO,KACV,6DACF,EACA,MACF,CAEA,KAAK,OAAO,MAAM,kBAAkB,EAOpC,IAAMmB,EAAavB,EAAK,SAAS,EAC3BsB,EAAmB,KAAK,MAAMC,CAAU,EAE9C,GAAIC,EAAmBF,EAAS,KAAK,OAAQ,KAAK,aAAa,EAAG,CAChE,KAAK,wBAAwB,KAAKA,CAAO,EACzC,MACF,CAEA,KAAK,OAAO,MAAM,2CAA4CC,CAAU,CAC1E,CACF","names":["index_exports","__export","SystemAccessPoint","VirtualDeviceType","isChannel","isConfiguration","isDevice","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isWebSocketMessage","__toCommonJS","import_ts_interface_checker","Channel","ChannelTypeSuite","import_ts_interface_checker","Configuration","ConfigurationTypeSuite","import_ts_interface_checker","Device","DeviceTypeSuite","import_ts_interface_checker","DeviceList","DeviceListTypeSuite","import_ts_interface_checker","DeviceResponse","DeviceResponseTypeSuite","import_ts_interface_checker","Devices","DevicesTypeSuite","import_ts_interface_checker","ErrorType","ErrorTypeSuite","import_ts_interface_checker","Floors","FloorsTypeSuite","import_ts_interface_checker","GetDataPointResponse","GetDataPointResponseTypeSuite","import_ts_interface_checker","InOutPut","InOutPutTypeSuite","import_ts_interface_checker","Rooms","RoomsTypeSuite","import_ts_interface_checker","ScenesTriggered","ScenesTriggeredTypeSuite","import_ts_interface_checker","SetDataPointResponse","SetDataPointResponseTypeSuite","import_ts_interface_checker","SysAP","SysApTypeSuite","import_ts_interface_checker","Users","UsersTypeSuite","import_ts_interface_checker","VirtualDevice","VirtualDeviceType","VirtualDeviceTypeSuite","import_ts_interface_checker","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","import_ts_interface_checker","WebSocketMessage","WebSocketMessageTypeSuite","import_ts_interface_checker","VirtualDeviceType","Channel","ChannelTypeSuite","InOutPutTypeSuite","Configuration","ConfigurationTypeSuite","DevicesTypeSuite","DeviceTypeSuite","FloorsTypeSuite","RoomsTypeSuite","SysApTypeSuite","UsersTypeSuite","ErrorTypeSuite","Device","DeviceList","DeviceListTypeSuite","DeviceResponse","DeviceResponseTypeSuite","GetDataPointResponse","GetDataPointResponseTypeSuite","SetDataPointResponse","SetDataPointResponseTypeSuite","VirtualDevice","VirtualDeviceTypeSuite","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","WebSocketMessage","WebSocketMessageTypeSuite","ScenesTriggeredTypeSuite","check","obj","checker","logger","verbose","error","isWebSocketMessage","isConfiguration","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isChannel","isDevice","import_node_events","import_rxjs","import_ws","SystemAccessPoint","hostName","userName","password","tlsEnabled","verboseErrors","logger","scheduler","certificateVerification","sysApUuid","deviceSerial","virtualDevice","response","isVirtualDeviceResponse","url","options","webSocket","error","data","request","code","reason","isBinary","force","isConfiguration","isDeviceList","isDeviceResponse","channel","dataPoint","isGetDataPointResponse","value","isSetDataPointResponse","deviceClass","action","method","route","body","info","init","typeGuard","message","serialized","isWebSocketMessage"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{iface as R,indexKey as A,opt as m}from"ts-interface-checker";var me=R([],{displayName:m("string"),functionID:m("string"),room:m("string"),floor:m("string"),inputs:m(R([],{[A]:"InOutPut"})),outputs:m(R([],{[A]:"InOutPut"})),parameters:m(R([],{[A]:"string"})),type:m("string")}),l={Channel:me};import{iface as le,indexKey as fe}from"ts-interface-checker";var Se=le([],{[fe]:"SysAP"}),T={Configuration:Se};import{iface as P,indexKey as Y,opt as f}from"ts-interface-checker";var he=P([],{displayName:f("string"),room:f("string"),floor:f("string"),interface:f("string"),nativeId:f("string"),channels:f(P([],{[Y]:"Channel"})),parameters:f(P([],{[Y]:"string"}))}),h={Device:he};import{array as de,iface as ve,indexKey as be}from"ts-interface-checker";var ke=ve([],{[be]:de("string")}),I={DeviceList:ke};import{iface as Z,indexKey as Re}from"ts-interface-checker";var xe=Z([],{[Re]:Z([],{devices:"Devices"})}),E={DeviceResponse:xe};import{iface as De,indexKey as we}from"ts-interface-checker";var Ae=De([],{[we]:"Device"}),v={Devices:Ae};import{iface as Te}from"ts-interface-checker";var Pe=Te([],{code:"string",detail:"string",title:"string"}),C={Error:Pe};import{iface as ee,indexKey as Ie}from"ts-interface-checker";var Ee=ee([],{[Ie]:ee([],{name:"string",rooms:"Rooms"})}),M={Floors:Ee};import{array as Ce,iface as te,indexKey as Me}from"ts-interface-checker";var We=te([],{[Me]:te([],{values:Ce("string")})}),W={GetDataPointResponse:We};import{iface as Oe,opt as re}from"ts-interface-checker";var Qe=Oe([],{value:re("string"),pairingID:re("number")}),S={InOutPut:Qe};import{iface as ie,indexKey as Le}from"ts-interface-checker";var $e=ie([],{[Le]:ie([],{name:"string"})}),O={Rooms:$e};import{iface as d,indexKey as Q}from"ts-interface-checker";var Ke=d([],{[Q]:d([],{channels:d([],{[Q]:d([],{outputs:d([],{[Q]:d([],{value:"string",pairingID:"number"})})})})})}),L={ScenesTriggered:Ke};import{iface as se,indexKey as oe}from"ts-interface-checker";var Be=se([],{[oe]:se([],{[oe]:"string"})}),$={SetDataPointResponse:Be};import{iface as ne,opt as Fe}from"ts-interface-checker";var Ge=ne([],{devices:"Devices",floorplan:ne([],{floors:"Floors"}),sysapName:"string",users:"Users",error:Fe("Error")}),K={SysAP:Ge};import{array as B,iface as ae,indexKey as Ne}from"ts-interface-checker";var Ue=ae([],{[Ne]:ae([],{enabled:"boolean",flags:B("string"),grantedPermissions:B("string"),jid:"string",name:"string",requestedPermissions:B("string"),role:"string"})}),F={Users:Ue};import{array as je,enumtype as He,iface as pe,opt as b}from"ts-interface-checker";var Ve=pe([],{type:"VirtualDeviceType",properties:b(pe([],{ttl:b("string"),displayname:b("string"),flavor:b("string"),capabilities:b(je("number"))}))}),qe=He({BinarySensor:"BinarySensor",BlindActuator:"BlindActuator",SwitchingActuator:"SwitchingActuator",CeilingFanActuator:"CeilingFanActuator",RTC:"RTC",DimActuator:"DimActuator",EVCharging:"evcharging",WindowSensor:"WindowSensor",SimpleDoorlock:"simple_doorlock",ShutterActuator:"ShutterActuator",WeatherStation:"WeatherStation",WeatherTemperatureSensor:"Weather-TemperatureSensor",WeatherWindSensor:"Weather-WindSensor",WeatherBrightnessSensor:"Weather-BrightnessSensor",WeatherRainSensor:"Weather-RainSensor",WindowActuator:"WindowActuator",CODetector:"CODetector",FireDetector:"FireDetector",KNXSwitchSensor:"KNX-SwitchSensor",MediaPlayer:"MediaPlayer",EnergyBattery:"EnergyBattery",EnergyInverter:"EnergyInverter",EnergyMeter:"EnergyMeter",EnergyInverterBattery:"EnergyInverterBattery",EnergyInverterMeter:"EnergyInverterMeter",EnergyInverterMeterBattery:"EnergyInverterMeterBattery",EnergyMeterBattery:"EnergyMeterBattery",AirQualityCO2:"AirQualityCO2",AirQualityCO:"AirQualityCO",AirQualityFull:"AirQualityFull",AirQualityHumidity:"AirQualityHumidity",AirQualityNO2:"AirQualityNO2",AirQualityO3:"AirQualityO3",AirQualityPM10:"AirQualityPM10",AirQualityPM25:"AirQualityPM25",AirQualityPressure:"AirQualityPressure",AirQualityTemperature:"AirQualityTemperature",AirQualityVOC:"AirQualityVOC",EnergyMeterV2:"EnergyMeterv2",HomeApplianceLaundry:"HomeAppliance-Laundry",HVAC:"HVAC",SplitUnit:"SplitUnit"}),G={VirtualDevice:Ve,VirtualDeviceType:qe};import{iface as x,indexKey as ce}from"ts-interface-checker";var ze=x([],{[ce]:x([],{devices:x([],{[ce]:x([],{serial:"string"})})})}),N={VirtualDeviceResponse:ze};import{array as ue,iface as D,indexKey as U,opt as Xe}from"ts-interface-checker";var Je=D([],{[U]:D([],{datapoints:D([],{[U]:"string"}),devices:"Devices",devicesAdded:ue("string"),devicesRemoved:ue("string"),scenesTriggered:"ScenesTriggered",parameters:Xe(D([],{[U]:"string"}))})}),j={WebSocketMessage:Je};import{createCheckers as u}from"ts-interface-checker";var ge=(t=>(t.BinarySensor="BinarySensor",t.BlindActuator="BlindActuator",t.SwitchingActuator="SwitchingActuator",t.CeilingFanActuator="CeilingFanActuator",t.RTC="RTC",t.DimActuator="DimActuator",t.EVCharging="evcharging",t.WindowSensor="WindowSensor",t.SimpleDoorlock="simple_doorlock",t.ShutterActuator="ShutterActuator",t.WeatherStation="WeatherStation",t.WeatherTemperatureSensor="Weather-TemperatureSensor",t.WeatherWindSensor="Weather-WindSensor",t.WeatherBrightnessSensor="Weather-BrightnessSensor",t.WeatherRainSensor="Weather-RainSensor",t.WindowActuator="WindowActuator",t.CODetector="CODetector",t.FireDetector="FireDetector",t.KNXSwitchSensor="KNX-SwitchSensor",t.MediaPlayer="MediaPlayer",t.EnergyBattery="EnergyBattery",t.EnergyInverter="EnergyInverter",t.EnergyMeter="EnergyMeter",t.EnergyInverterBattery="EnergyInverterBattery",t.EnergyInverterMeter="EnergyInverterMeter",t.EnergyInverterMeterBattery="EnergyInverterMeterBattery",t.EnergyMeterBattery="EnergyMeterBattery",t.AirQualityCO2="AirQualityCO2",t.AirQualityCO="AirQualityCO",t.AirQualityFull="AirQualityFull",t.AirQualityHumidity="AirQualityHumidity",t.AirQualityNO2="AirQualityNO2",t.AirQualityO3="AirQualityO3",t.AirQualityPM10="AirQualityPM10",t.AirQualityPM25="AirQualityPM25",t.AirQualityPressure="AirQualityPressure",t.AirQualityTemperature="AirQualityTemperature",t.AirQualityVOC="AirQualityVOC",t.EnergyMeterV2="EnergyMeterv2",t.HomeApplianceLaundry="HomeAppliance-Laundry",t.HVAC="HVAC",t.SplitUnit="SplitUnit",t))(ge||{});var{Channel:_e}=u(l,S),{Configuration:Ye}=u(T,v,h,l,S,M,O,K,F,C),{Device:Ze}=u(h,l,S),{DeviceList:et}=u(I),{DeviceResponse:tt}=u(E,v,h,l,S),{GetDataPointResponse:rt}=u(W),{SetDataPointResponse:it}=u($),{VirtualDevice:st}=u(G),{VirtualDeviceResponse:ot}=u(N),{WebSocketMessage:nt}=u(j,v,h,l,S,L);function g(a,p,e,c){if(c)try{return p.check(a),!0}catch(n){return e.error("Object validation failed!",n),!1}return p.test(a)}function H(a,p,e=!1){return g(a,nt,p,e)}function V(a,p,e=!1){return g(a,Ye,p,e)}function q(a,p,e=!1){return g(a,et,p,e)}function k(a,p,e=!1){return g(a,tt,p,e)}function z(a,p,e=!1){return g(a,rt,p,e)}function X(a,p,e=!1){return g(a,it,p,e)}function at(a,p,e=!1){return g(a,st,p,e)}function J(a,p,e=!1){return g(a,ot,p,e)}function pt(a,p,e=!1){return g(a,_e,p,e)}function ct(a,p,e=!1){return g(a,Ze,p,e)}import{EventEmitter as ut}from"events";import{interval as gt,Subject as ye,switchMap as yt,takeUntil as mt}from"rxjs";import{WebSocket as w}from"ws";var _=class extends ut{constructor(e,c,n,s=!0,o=!1,y=console,lt){super();this.hostName=e;this.userName=c;this.password=n;this.tlsEnabled=s;this.verboseErrors=o;this.logger=y;this.scheduler=lt;this.basicAuthKey=Buffer.from(`${c}:${n}`,"utf8").toString("base64")}basicAuthKey;webSocket;webSocketMessageSubject=new ye;webSocketKeepaliveTimerReset$=new ye;webSocketKeepaliveTimer$=this.webSocketKeepaliveTimerReset$.pipe(yt(()=>gt(3e4,this.scheduler).pipe(mt(this.webSocketKeepaliveTimerReset$))));webSocketKeepaliveSubscription;connectWebSocket(e=!0){if(this.webSocket&&this.webSocket.readyState===w.OPEN)throw new Error("Web socket is already connected");this.webSocket=this.createWebSocket(e),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0,this.webSocketKeepaliveSubscription=this.webSocketKeepaliveTimer$.subscribe(()=>{this.webSocket&&this.webSocket.readyState===w.OPEN&&(this.logger.log("keepalive timer expired, sending ping message..."),this.webSocket.ping())}),this.webSocketKeepaliveTimerReset$.next()}async createVirtualDevice(e,c,n){let s=await this.fetchDataViaRest("PUT",`virtualdevice/${e}/${c}`,JSON.stringify(n));return this.processRestResponse(s,J)}createWebSocket(e){this.tlsEnabled&&!e&&this.logger.warn("TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.");let c=`${this.tlsEnabled?"wss":"ws"}://${this.hostName}/fhapi/v1/api/ws`,n={rejectUnauthorized:this.tlsEnabled&&e,headers:{Authorization:`Basic ${this.basicAuthKey}`}},s=new w(c,n);return s.on("error",o=>{this.emit("websocket-error",o),this.logger.error("Error received",o)}),s.on("ping",o=>{this.emit("websocket-ping",o),this.logger.debug("Ping received",o.toString("ascii")),this.webSocketKeepaliveTimerReset$.next(),s.pong(o),this.logger.debug("Pong sent",o.toString("ascii"))}),s.on("pong",o=>{this.emit("websocket-pong",o),this.logger.debug("Pong received",o.toString("ascii"))}),s.on("unexpected-response",(o,y)=>{this.emit("websocket-unexpected-response",o,y),this.logger.error("Unexpected response received")}),s.on("upgrade",o=>{this.emit("websocket-upgrade",o),this.logger.debug("Upgrade request received")}),s.on("open",()=>{this.emit("websocket-open"),this.logger.log("Connection opened")}),s.on("close",(o,y)=>{this.emit("websocket-close",o,y),this.logger.log("Connection closed"),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0}),s.on("message",(o,y)=>{this.emit("websocket-message",o,y),this.webSocketKeepaliveTimerReset$.next(),this.processWebSocketMessage(o,y)}),s}disconnectWebSocket(e=!1){if(!this.webSocket||this.webSocket.readyState===w.CLOSED)throw new Error("Web socket is not open");e?this.webSocket.terminate():this.webSocket.close()}async getConfiguration(){let e=await this.fetchDataViaRest("GET","configuration");return this.processRestResponse(e,V)}async getDeviceList(){let e=await this.fetchDataViaRest("GET","devicelist");return this.processRestResponse(e,q)}async getDevice(e,c){let n=await this.fetchDataViaRest("GET",`device/${e}/${c}`);return this.processRestResponse(n,k)}async getDatapoint(e,c,n,s){let o=await this.fetchDataViaRest("GET",`datapoint/${e}/${c}.${n}.${s}`);return this.processRestResponse(o,z)}getWebSocketMessages(){return this.webSocketMessageSubject.asObservable()}async setDatapoint(e,c,n,s,o){let y=await this.fetchDataViaRest("PUT",`datapoint/${e}/${c}.${n}.${s}`,o);return this.processRestResponse(y,X)}async triggerProxyDevice(e,c,n,s){let o=await this.fetchDataViaRest("GET",`proxydevice/${e}/${c}/${n}/action/${s}`);return this.processRestResponse(o,k)}async setProxyDeviceValue(e,c,n,s){let o=await this.fetchDataViaRest("PUT",`proxydevice/${e}/${c}/${n}/value/${s}`);return this.processRestResponse(o,k)}async fetchDataViaRest(e,c,n){let s=`${this.tlsEnabled?"https":"http"}://${this.hostName}/fhapi/v1/api/rest/${c}`,o={method:e,headers:{Authorization:`Basic ${this.basicAuthKey}`},body:n};return fetch(s,o)}async processRestResponse(e,c){let n,s;switch(e.status){case 200:if(n=await e.json(),!c(n,this.logger,this.verboseErrors))throw s="Received message has an unexpected type!",this.logger.error(s,n),new Error(s);return n;case 401:throw s="Authentication information is missing or invalid.",this.logger.error(s),new Error(s);case 502:throw s=await e.text(),this.logger.error(s),new Error(s);default:throw s=`Received HTTP ${e.status} status code unexpectedly: ${await e.text()}`,this.logger.error(s),new Error(s)}}processWebSocketMessage(e,c){if(c){this.logger.warn("Binary message received. Binary messages are not processed.");return}this.logger.debug("Message received");let n=e.toString(),s=JSON.parse(n);if(H(s,this.logger,this.verboseErrors)){this.webSocketMessageSubject.next(s);return}this.logger.error("Received message has an unexpected type!",n)}};export{_ as SystemAccessPoint,ge as VirtualDeviceType,pt as isChannel,V as isConfiguration,ct as isDevice,q as isDeviceList,k as isDeviceResponse,z as isGetDataPointResponse,X as isSetDataPointResponse,at as isVirtualDevice,J as isVirtualDeviceResponse,H as isWebSocketMessage};
|
|
1
|
+
import{iface as R,indexKey as T,opt as m}from"ts-interface-checker";var me=R([],{displayName:m("string"),functionID:m("string"),room:m("string"),floor:m("string"),inputs:m(R([],{[T]:"InOutPut"})),outputs:m(R([],{[T]:"InOutPut"})),parameters:m(R([],{[T]:"string"})),type:m("string")}),l={Channel:me};import{iface as le,indexKey as fe}from"ts-interface-checker";var Se=le([],{[fe]:"SysAP"}),A={Configuration:Se};import{iface as P,indexKey as Y,opt as f}from"ts-interface-checker";var he=P([],{displayName:f("string"),room:f("string"),floor:f("string"),interface:f("string"),nativeId:f("string"),channels:f(P([],{[Y]:"Channel"})),parameters:f(P([],{[Y]:"string"}))}),h={Device:he};import{array as de,iface as ve,indexKey as be}from"ts-interface-checker";var ke=ve([],{[be]:de("string")}),I={DeviceList:ke};import{iface as Z,indexKey as Re}from"ts-interface-checker";var xe=Z([],{[Re]:Z([],{devices:"Devices"})}),E={DeviceResponse:xe};import{iface as De,indexKey as we}from"ts-interface-checker";var Te=De([],{[we]:"Device"}),v={Devices:Te};import{iface as Ae}from"ts-interface-checker";var Pe=Ae([],{code:"string",detail:"string",title:"string"}),C={Error:Pe};import{iface as ee,indexKey as Ie}from"ts-interface-checker";var Ee=ee([],{[Ie]:ee([],{name:"string",rooms:"Rooms"})}),M={Floors:Ee};import{array as Ce,iface as te,indexKey as Me}from"ts-interface-checker";var We=te([],{[Me]:te([],{values:Ce("string")})}),W={GetDataPointResponse:We};import{iface as Oe,opt as re}from"ts-interface-checker";var Qe=Oe([],{value:re("string"),pairingID:re("number")}),S={InOutPut:Qe};import{iface as ie,indexKey as Le}from"ts-interface-checker";var $e=ie([],{[Le]:ie([],{name:"string"})}),O={Rooms:$e};import{iface as d,indexKey as Q}from"ts-interface-checker";var Ke=d([],{[Q]:d([],{channels:d([],{[Q]:d([],{outputs:d([],{[Q]:d([],{value:"string",pairingID:"number"})})})})})}),L={ScenesTriggered:Ke};import{iface as se,indexKey as oe}from"ts-interface-checker";var Be=se([],{[oe]:se([],{[oe]:"string"})}),$={SetDataPointResponse:Be};import{iface as ne,opt as Fe}from"ts-interface-checker";var Ge=ne([],{devices:"Devices",floorplan:ne([],{floors:"Floors"}),sysapName:"string",users:"Users",error:Fe("Error")}),K={SysAP:Ge};import{array as B,iface as ae,indexKey as Ne}from"ts-interface-checker";var Ue=ae([],{[Ne]:ae([],{enabled:"boolean",flags:B("string"),grantedPermissions:B("string"),jid:"string",name:"string",requestedPermissions:B("string"),role:"string"})}),F={Users:Ue};import{array as je,enumtype as He,iface as pe,opt as b}from"ts-interface-checker";var Ve=pe([],{type:"VirtualDeviceType",properties:b(pe([],{ttl:b("string"),displayname:b("string"),flavor:b("string"),capabilities:b(je("number"))}))}),qe=He({BinarySensor:"BinarySensor",BlindActuator:"BlindActuator",SwitchingActuator:"SwitchingActuator",CeilingFanActuator:"CeilingFanActuator",RTC:"RTC",DimActuator:"DimActuator",EVCharging:"evcharging",WindowSensor:"WindowSensor",SimpleDoorlock:"simple_doorlock",ShutterActuator:"ShutterActuator",WeatherStation:"WeatherStation",WeatherTemperatureSensor:"Weather-TemperatureSensor",WeatherWindSensor:"Weather-WindSensor",WeatherBrightnessSensor:"Weather-BrightnessSensor",WeatherRainSensor:"Weather-RainSensor",WindowActuator:"WindowActuator",CODetector:"CODetector",FireDetector:"FireDetector",KNXSwitchSensor:"KNX-SwitchSensor",MediaPlayer:"MediaPlayer",EnergyBattery:"EnergyBattery",EnergyInverter:"EnergyInverter",EnergyMeter:"EnergyMeter",EnergyInverterBattery:"EnergyInverterBattery",EnergyInverterMeter:"EnergyInverterMeter",EnergyInverterMeterBattery:"EnergyInverterMeterBattery",EnergyMeterBattery:"EnergyMeterBattery",AirQualityCO2:"AirQualityCO2",AirQualityCO:"AirQualityCO",AirQualityFull:"AirQualityFull",AirQualityHumidity:"AirQualityHumidity",AirQualityNO2:"AirQualityNO2",AirQualityO3:"AirQualityO3",AirQualityPM10:"AirQualityPM10",AirQualityPM25:"AirQualityPM25",AirQualityPressure:"AirQualityPressure",AirQualityTemperature:"AirQualityTemperature",AirQualityVOC:"AirQualityVOC",EnergyMeterV2:"EnergyMeterv2",HomeApplianceLaundry:"HomeAppliance-Laundry",HVAC:"HVAC",SplitUnit:"SplitUnit"}),G={VirtualDevice:Ve,VirtualDeviceType:qe};import{iface as x,indexKey as ce}from"ts-interface-checker";var ze=x([],{[ce]:x([],{devices:x([],{[ce]:x([],{serial:"string"})})})}),N={VirtualDeviceResponse:ze};import{array as ue,iface as D,indexKey as U,opt as Xe}from"ts-interface-checker";var Je=D([],{[U]:D([],{datapoints:D([],{[U]:"string"}),devices:"Devices",devicesAdded:ue("string"),devicesRemoved:ue("string"),scenesTriggered:"ScenesTriggered",parameters:Xe(D([],{[U]:"string"}))})}),j={WebSocketMessage:Je};import{createCheckers as u}from"ts-interface-checker";var ge=(t=>(t.BinarySensor="BinarySensor",t.BlindActuator="BlindActuator",t.SwitchingActuator="SwitchingActuator",t.CeilingFanActuator="CeilingFanActuator",t.RTC="RTC",t.DimActuator="DimActuator",t.EVCharging="evcharging",t.WindowSensor="WindowSensor",t.SimpleDoorlock="simple_doorlock",t.ShutterActuator="ShutterActuator",t.WeatherStation="WeatherStation",t.WeatherTemperatureSensor="Weather-TemperatureSensor",t.WeatherWindSensor="Weather-WindSensor",t.WeatherBrightnessSensor="Weather-BrightnessSensor",t.WeatherRainSensor="Weather-RainSensor",t.WindowActuator="WindowActuator",t.CODetector="CODetector",t.FireDetector="FireDetector",t.KNXSwitchSensor="KNX-SwitchSensor",t.MediaPlayer="MediaPlayer",t.EnergyBattery="EnergyBattery",t.EnergyInverter="EnergyInverter",t.EnergyMeter="EnergyMeter",t.EnergyInverterBattery="EnergyInverterBattery",t.EnergyInverterMeter="EnergyInverterMeter",t.EnergyInverterMeterBattery="EnergyInverterMeterBattery",t.EnergyMeterBattery="EnergyMeterBattery",t.AirQualityCO2="AirQualityCO2",t.AirQualityCO="AirQualityCO",t.AirQualityFull="AirQualityFull",t.AirQualityHumidity="AirQualityHumidity",t.AirQualityNO2="AirQualityNO2",t.AirQualityO3="AirQualityO3",t.AirQualityPM10="AirQualityPM10",t.AirQualityPM25="AirQualityPM25",t.AirQualityPressure="AirQualityPressure",t.AirQualityTemperature="AirQualityTemperature",t.AirQualityVOC="AirQualityVOC",t.EnergyMeterV2="EnergyMeterv2",t.HomeApplianceLaundry="HomeAppliance-Laundry",t.HVAC="HVAC",t.SplitUnit="SplitUnit",t))(ge||{});var{Channel:_e}=u(l,S),{Configuration:Ye}=u(A,v,h,l,S,M,O,K,F,C),{Device:Ze}=u(h,l,S),{DeviceList:et}=u(I),{DeviceResponse:tt}=u(E,v,h,l,S),{GetDataPointResponse:rt}=u(W),{SetDataPointResponse:it}=u($),{VirtualDevice:st}=u(G),{VirtualDeviceResponse:ot}=u(N),{WebSocketMessage:nt}=u(j,v,h,l,S,L);function g(a,p,e,c){if(c)try{return p.check(a),!0}catch(n){return e.error("Object validation failed!",n),!1}return p.test(a)}function H(a,p,e=!1){return g(a,nt,p,e)}function V(a,p,e=!1){return g(a,Ye,p,e)}function q(a,p,e=!1){return g(a,et,p,e)}function k(a,p,e=!1){return g(a,tt,p,e)}function z(a,p,e=!1){return g(a,rt,p,e)}function X(a,p,e=!1){return g(a,it,p,e)}function at(a,p,e=!1){return g(a,st,p,e)}function J(a,p,e=!1){return g(a,ot,p,e)}function pt(a,p,e=!1){return g(a,_e,p,e)}function ct(a,p,e=!1){return g(a,Ze,p,e)}import{EventEmitter as ut}from"events";import{interval as gt,Subject as ye,switchMap as yt,takeUntil as mt}from"rxjs";import{WebSocket as w}from"ws";var _=class extends ut{constructor(e,c,n,s=!0,o=!1,y=console,lt){super();this.hostName=e;this.userName=c;this.password=n;this.tlsEnabled=s;this.verboseErrors=o;this.logger=y;this.scheduler=lt;this.basicAuthKey=Buffer.from(`${c}:${n}`,"utf8").toString("base64")}basicAuthKey;webSocket;webSocketMessageSubject=new ye;webSocketKeepaliveTimerReset$=new ye;webSocketKeepaliveTimer$=this.webSocketKeepaliveTimerReset$.pipe(yt(()=>gt(3e4,this.scheduler).pipe(mt(this.webSocketKeepaliveTimerReset$))));webSocketKeepaliveSubscription;connectWebSocket(e=!0){if(this.webSocket?.readyState===w.OPEN)throw new Error("Web socket is already connected");this.webSocket=this.createWebSocket(e),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0,this.webSocketKeepaliveSubscription=this.webSocketKeepaliveTimer$.subscribe(()=>{this.webSocket?.readyState===w.OPEN&&(this.logger.log("keepalive timer expired, sending ping message..."),this.webSocket.ping())}),this.webSocketKeepaliveTimerReset$.next()}async createVirtualDevice(e,c,n){let s=await this.fetchDataViaRest("PUT",`virtualdevice/${e}/${c}`,JSON.stringify(n));return this.processRestResponse(s,J)}createWebSocket(e){this.tlsEnabled&&!e&&this.logger.warn("TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.");let c=`${this.tlsEnabled?"wss":"ws"}://${this.hostName}/fhapi/v1/api/ws`,n={rejectUnauthorized:this.tlsEnabled&&e,headers:{Authorization:`Basic ${this.basicAuthKey}`}},s=new w(c,n);return s.on("error",o=>{this.emit("websocket-error",o),this.logger.error("Error received",o)}),s.on("ping",o=>{this.emit("websocket-ping",o),this.logger.debug("Ping received",o.toString("ascii")),this.webSocketKeepaliveTimerReset$.next(),s.pong(o),this.logger.debug("Pong sent",o.toString("ascii"))}),s.on("pong",o=>{this.emit("websocket-pong",o),this.logger.debug("Pong received",o.toString("ascii"))}),s.on("unexpected-response",(o,y)=>{this.emit("websocket-unexpected-response",o,y),this.logger.error("Unexpected response received")}),s.on("upgrade",o=>{this.emit("websocket-upgrade",o),this.logger.debug("Upgrade request received")}),s.on("open",()=>{this.emit("websocket-open"),this.logger.log("Connection opened")}),s.on("close",(o,y)=>{this.emit("websocket-close",o,y),this.logger.log("Connection closed"),this.webSocketKeepaliveSubscription?.unsubscribe(),this.webSocketKeepaliveSubscription=void 0}),s.on("message",(o,y)=>{this.emit("websocket-message",o,y),this.webSocketKeepaliveTimerReset$.next(),this.processWebSocketMessage(o,y)}),s}disconnectWebSocket(e=!1){if(!this.webSocket||this.webSocket.readyState===w.CLOSED)throw new Error("Web socket is not open");e?this.webSocket.terminate():this.webSocket.close()}async getConfiguration(){let e=await this.fetchDataViaRest("GET","configuration");return this.processRestResponse(e,V)}async getDeviceList(){let e=await this.fetchDataViaRest("GET","devicelist");return this.processRestResponse(e,q)}async getDevice(e,c){let n=await this.fetchDataViaRest("GET",`device/${e}/${c}`);return this.processRestResponse(n,k)}async getDatapoint(e,c,n,s){let o=await this.fetchDataViaRest("GET",`datapoint/${e}/${c}.${n}.${s}`);return this.processRestResponse(o,z)}getWebSocketMessages(){return this.webSocketMessageSubject.asObservable()}async setDatapoint(e,c,n,s,o){let y=await this.fetchDataViaRest("PUT",`datapoint/${e}/${c}.${n}.${s}`,o);return this.processRestResponse(y,X)}async triggerProxyDevice(e,c,n,s){let o=await this.fetchDataViaRest("GET",`proxydevice/${e}/${c}/${n}/action/${s}`);return this.processRestResponse(o,k)}async setProxyDeviceValue(e,c,n,s){let o=await this.fetchDataViaRest("PUT",`proxydevice/${e}/${c}/${n}/value/${s}`);return this.processRestResponse(o,k)}async fetchDataViaRest(e,c,n){let s=`${this.tlsEnabled?"https":"http"}://${this.hostName}/fhapi/v1/api/rest/${c}`,o={method:e,headers:{Authorization:`Basic ${this.basicAuthKey}`},body:n};return fetch(s,o)}async processRestResponse(e,c){let n,s;switch(e.status){case 200:if(n=await e.json(),!c(n,this.logger,this.verboseErrors))throw s="Received message has an unexpected type!",this.logger.error(s,n),new Error(s);return n;case 401:throw s="Authentication information is missing or invalid.",this.logger.error(s),new Error(s);case 502:throw s=await e.text(),this.logger.error(s),new Error(s);default:throw s=`Received HTTP ${e.status} status code unexpectedly: ${await e.text()}`,this.logger.error(s),new Error(s)}}processWebSocketMessage(e,c){if(c){this.logger.warn("Binary message received. Binary messages are not processed.");return}this.logger.debug("Message received");let n=e.toString(),s=JSON.parse(n);if(H(s,this.logger,this.verboseErrors)){this.webSocketMessageSubject.next(s);return}this.logger.error("Received message has an unexpected type!",n)}};export{_ as SystemAccessPoint,ge as VirtualDeviceType,pt as isChannel,V as isConfiguration,ct as isDevice,q as isDeviceList,k as isDeviceResponse,z as isGetDataPointResponse,X as isSetDataPointResponse,at as isVirtualDevice,J as isVirtualDeviceResponse,H as isWebSocketMessage};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/model/validation/channel-ti.ts","../src/model/validation/configuration-ti.ts","../src/model/validation/device-ti.ts","../src/model/validation/device-list-ti.ts","../src/model/validation/device-response-ti.ts","../src/model/validation/devices-ti.ts","../src/model/validation/error-ti.ts","../src/model/validation/floors-ti.ts","../src/model/validation/get-data-point-response-ti.ts","../src/model/validation/in-out-put-ti.ts","../src/model/validation/rooms-ti.ts","../src/model/validation/scenes-triggered-ti.ts","../src/model/validation/set-data-point-response-ti.ts","../src/model/validation/sys-ap-ti.ts","../src/model/validation/users-ti.ts","../src/model/validation/virtual-device-ti.ts","../src/model/validation/virtual-device-response-ti.ts","../src/model/validation/websocket-message-ti.ts","../src/model/validator.ts","../src/model/virtual-device.ts","../src/system-access-point.ts"],"sourcesContent":["import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Channel = iface([], {\n displayName: opt(\"string\"),\n functionID: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n inputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n outputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n type: opt(\"string\"),\n});\n\nexport const ChannelTypeSuite: ITypeSuite = {\n Channel,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Configuration = iface([], {\n [indexKey]: \"SysAP\",\n});\n\nexport const ConfigurationTypeSuite: ITypeSuite = {\n Configuration,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Device = iface([], {\n displayName: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n interface: opt(\"string\"),\n nativeId: opt(\"string\"),\n channels: opt(\n iface([], {\n [indexKey]: \"Channel\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n});\n\nexport const DeviceTypeSuite: ITypeSuite = {\n Device,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceList = iface([], {\n [indexKey]: array(\"string\"),\n});\n\nexport const DeviceListTypeSuite: ITypeSuite = {\n DeviceList,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: \"Devices\",\n }),\n});\n\nexport const DeviceResponseTypeSuite: ITypeSuite = {\n DeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Devices = iface([], {\n [indexKey]: \"Device\",\n});\n\nexport const DevicesTypeSuite: ITypeSuite = {\n Devices,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface } from \"ts-interface-checker\";\n\nconst Error = iface([], {\n code: \"string\",\n detail: \"string\",\n title: \"string\",\n});\n\nexport const ErrorTypeSuite: ITypeSuite = {\n Error,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Floors = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n rooms: \"Rooms\",\n }),\n});\n\nexport const FloorsTypeSuite: ITypeSuite = {\n Floors,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst GetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n values: array(\"string\"),\n }),\n});\n\nexport const GetDataPointResponseTypeSuite: ITypeSuite = {\n GetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst InOutPut = iface([], {\n value: opt(\"string\"),\n pairingID: opt(\"number\"),\n});\n\nexport const InOutPutTypeSuite: ITypeSuite = {\n InOutPut,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Rooms = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n }),\n});\n\nexport const RoomsTypeSuite: ITypeSuite = {\n Rooms,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst ScenesTriggered = iface([], {\n [indexKey]: iface([], {\n channels: iface([], {\n [indexKey]: iface([], {\n outputs: iface([], {\n [indexKey]: iface([], {\n value: \"string\",\n pairingID: \"number\",\n }),\n }),\n }),\n }),\n }),\n});\n\nexport const ScenesTriggeredTypeSuite: ITypeSuite = {\n ScenesTriggered,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst SetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n [indexKey]: \"string\",\n }),\n});\n\nexport const SetDataPointResponseTypeSuite: ITypeSuite = {\n SetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst SysAP = iface([], {\n devices: \"Devices\",\n floorplan: iface([], {\n floors: \"Floors\",\n }),\n sysapName: \"string\",\n users: \"Users\",\n error: opt(\"Error\"),\n});\n\nexport const SysApTypeSuite: ITypeSuite = {\n SysAP,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst Users = iface([], {\n [indexKey]: iface([], {\n enabled: \"boolean\",\n flags: array(\"string\"),\n grantedPermissions: array(\"string\"),\n jid: \"string\",\n name: \"string\",\n requestedPermissions: array(\"string\"),\n role: \"string\",\n }),\n});\n\nexport const UsersTypeSuite: ITypeSuite = {\n Users,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, enumtype, iface, opt } from \"ts-interface-checker\";\n\nconst VirtualDevice = iface([], {\n type: \"VirtualDeviceType\",\n properties: opt(\n iface([], {\n ttl: opt(\"string\"),\n displayname: opt(\"string\"),\n flavor: opt(\"string\"),\n capabilities: opt(array(\"number\")),\n })\n ),\n});\n\nexport const VirtualDeviceType = enumtype({\n BinarySensor: \"BinarySensor\",\n BlindActuator: \"BlindActuator\",\n SwitchingActuator: \"SwitchingActuator\",\n CeilingFanActuator: \"CeilingFanActuator\",\n RTC: \"RTC\",\n DimActuator: \"DimActuator\",\n EVCharging: \"evcharging\",\n WindowSensor: \"WindowSensor\",\n SimpleDoorlock: \"simple_doorlock\",\n ShutterActuator: \"ShutterActuator\",\n WeatherStation: \"WeatherStation\",\n WeatherTemperatureSensor: \"Weather-TemperatureSensor\",\n WeatherWindSensor: \"Weather-WindSensor\",\n WeatherBrightnessSensor: \"Weather-BrightnessSensor\",\n WeatherRainSensor: \"Weather-RainSensor\",\n WindowActuator: \"WindowActuator\",\n CODetector: \"CODetector\",\n FireDetector: \"FireDetector\",\n KNXSwitchSensor: \"KNX-SwitchSensor\",\n MediaPlayer: \"MediaPlayer\",\n EnergyBattery: \"EnergyBattery\",\n EnergyInverter: \"EnergyInverter\",\n EnergyMeter: \"EnergyMeter\",\n EnergyInverterBattery: \"EnergyInverterBattery\",\n EnergyInverterMeter: \"EnergyInverterMeter\",\n EnergyInverterMeterBattery: \"EnergyInverterMeterBattery\",\n EnergyMeterBattery: \"EnergyMeterBattery\",\n AirQualityCO2: \"AirQualityCO2\",\n AirQualityCO: \"AirQualityCO\",\n AirQualityFull: \"AirQualityFull\",\n AirQualityHumidity: \"AirQualityHumidity\",\n AirQualityNO2: \"AirQualityNO2\",\n AirQualityO3: \"AirQualityO3\",\n AirQualityPM10: \"AirQualityPM10\",\n AirQualityPM25: \"AirQualityPM25\",\n AirQualityPressure: \"AirQualityPressure\",\n AirQualityTemperature: \"AirQualityTemperature\",\n AirQualityVOC: \"AirQualityVOC\",\n EnergyMeterV2: \"EnergyMeterv2\",\n HomeApplianceLaundry: \"HomeAppliance-Laundry\",\n HVAC: \"HVAC\",\n SplitUnit: \"SplitUnit\",\n});\n\nexport const VirtualDeviceTypeSuite: ITypeSuite = {\n VirtualDevice,\n VirtualDeviceType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst VirtualDeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: iface([], {\n [indexKey]: iface([], {\n serial: \"string\",\n }),\n }),\n }),\n});\n\nexport const VirtualDeviceResponseTypeSuite: ITypeSuite = {\n VirtualDeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst WebSocketMessage = iface([], {\n [indexKey]: iface([], {\n datapoints: iface([], {\n [indexKey]: \"string\",\n }),\n devices: \"Devices\",\n devicesAdded: array(\"string\"),\n devicesRemoved: array(\"string\"),\n scenesTriggered: \"ScenesTriggered\",\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n }),\n});\n\nexport const WebSocketMessageTypeSuite: ITypeSuite = {\n WebSocketMessage,\n};\n","import {\n ChannelTypeSuite,\n DeviceTypeSuite,\n DevicesTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite,\n WebSocketMessageTypeSuite,\n DeviceListTypeSuite,\n SetDataPointResponseTypeSuite,\n GetDataPointResponseTypeSuite,\n ConfigurationTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite,\n DeviceResponseTypeSuite,\n VirtualDeviceTypeSuite,\n VirtualDeviceResponseTypeSuite,\n} from \"./validation\";\nimport type { Checker } from \"ts-interface-checker\";\nimport { createCheckers } from \"ts-interface-checker\";\nimport { type WebSocketMessage as Message } from \"./websocket-message\";\nimport { type Configuration as Config } from \"./configuration\";\nimport { type Channel as Chan } from \"./channel\";\nimport { type Device as Dev } from \"./device\";\nimport { type DeviceList as DevList } from \"./device-list\";\nimport { type DeviceResponse as DevResponse } from \"./device-response\";\nimport { type GetDataPointResponse as GetResponse } from \"./get-data-point-response\";\nimport { type SetDataPointResponse as SetResponse } from \"./set-data-point-response\";\nimport { type VirtualDeviceResponse as VDeviceResponse } from \"./virtual-device-response\";\nimport { type VirtualDevice as VDevice } from \"./virtual-device\";\nimport { type Logger } from \"./logger\";\n\nconst { Channel } = createCheckers(ChannelTypeSuite, InOutPutTypeSuite);\n\nconst { Configuration } = createCheckers(\n ConfigurationTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite\n);\n\nconst { Device } = createCheckers(\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { DeviceList } = createCheckers(DeviceListTypeSuite);\n\nconst { DeviceResponse } = createCheckers(\n DeviceResponseTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { GetDataPointResponse } = createCheckers(GetDataPointResponseTypeSuite);\n\nconst { SetDataPointResponse } = createCheckers(SetDataPointResponseTypeSuite);\n\nconst { VirtualDevice } = createCheckers(VirtualDeviceTypeSuite);\n\nconst { VirtualDeviceResponse } = createCheckers(\n VirtualDeviceResponseTypeSuite\n);\n\nconst { WebSocketMessage } = createCheckers(\n WebSocketMessageTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite\n);\n\nfunction check(\n obj: unknown,\n checker: Checker,\n logger: Logger,\n verbose: boolean\n): boolean {\n if (verbose) {\n try {\n checker.check(obj);\n return true;\n } catch (error) {\n logger.error(\"Object validation failed!\", error);\n return false;\n }\n }\n\n return checker.test(obj);\n}\n\n/**\n * Determines whether the specified object is a web socket message.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a web socket message.\n */\nexport function isWebSocketMessage(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Message {\n return check(obj, WebSocketMessage, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a configuration.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a configuration.\n */\nexport function isConfiguration(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Config {\n return check(obj, Configuration, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device list.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device list.\n */\nexport function isDeviceList(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevList {\n return check(obj, DeviceList, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device response.\n */\nexport function isDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevResponse {\n return check(obj, DeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a get data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a get data point request.\n */\nexport function isGetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is GetResponse {\n return check(obj, GetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a set data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a set data point request.\n */\nexport function isSetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is SetResponse {\n return check(obj, SetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a virtual device.\n */\nexport function isVirtualDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDevice {\n return check(obj, VirtualDevice, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a virtual device request.\n */\nexport function isVirtualDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDeviceResponse {\n return check(obj, VirtualDeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a channel.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a channel.\n */\nexport function isChannel(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Chan {\n return check(obj, Channel, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device.\n */\nexport function isDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Dev {\n return check(obj, Device, logger, verbose);\n}\n","/** Defines a virtual device. */\nexport interface VirtualDevice {\n /** The virtual device type. */\n type: VirtualDeviceType;\n /** The virtual device properties */\n properties?: {\n /** The time to live value indicates the number of seconds the system access point will wait for a message before it assumes the device to be unresponsive. */\n ttl?: string;\n /** The display name for the virtual device. */\n displayname?: string;\n /** The virtual device flavor. */\n flavor?: string;\n /** The virtual device capabilities. */\n capabilities?: Array<number>;\n };\n}\n\n/** Defines the possible types of virtual devices. */\nexport enum VirtualDeviceType {\n /** A binary sensor */\n BinarySensor = \"BinarySensor\",\n /** A blind actuator */\n BlindActuator = \"BlindActuator\",\n /** A switching actuator */\n SwitchingActuator = \"SwitchingActuator\",\n /** A ceiling fan actuator */\n CeilingFanActuator = \"CeilingFanActuator\",\n /** A real time clock */\n RTC = \"RTC\",\n /** A dimmer actuator */\n DimActuator = \"DimActuator\",\n /** A charger for an electronic vehicle */\n EVCharging = \"evcharging\",\n /** A window sensor */\n WindowSensor = \"WindowSensor\",\n /** A simple door lock */\n SimpleDoorlock = \"simple_doorlock\",\n /** A shutter actuator */\n ShutterActuator = \"ShutterActuator\",\n /** A weather station */\n WeatherStation = \"WeatherStation\",\n /** A temperature sensor */\n WeatherTemperatureSensor = \"Weather-TemperatureSensor\",\n /** A wind sensor */\n WeatherWindSensor = \"Weather-WindSensor\",\n /** A brightness sensor */\n WeatherBrightnessSensor = \"Weather-BrightnessSensor\",\n /** A rain sensor */\n WeatherRainSensor = \"Weather-RainSensor\",\n /** A window actuator */\n WindowActuator = \"WindowActuator\",\n /** A detector for carbon monoxide (CO) */\n CODetector = \"CODetector\",\n /** A fire detector */\n FireDetector = \"FireDetector\",\n /** A KNX switch sensor */\n KNXSwitchSensor = \"KNX-SwitchSensor\",\n /** A media player */\n MediaPlayer = \"MediaPlayer\",\n /** A battery */\n EnergyBattery = \"EnergyBattery\",\n /** An inverter */\n EnergyInverter = \"EnergyInverter\",\n /** An energy meter */\n EnergyMeter = \"EnergyMeter\",\n /** A device combining inverter and battery characteristics */\n EnergyInverterBattery = \"EnergyInverterBattery\",\n /** A device combining inverter and energy meter characteristics */\n EnergyInverterMeter = \"EnergyInverterMeter\",\n /** A device combining inverter, battery and energy meter characteristics */\n EnergyInverterMeterBattery = \"EnergyInverterMeterBattery\",\n /** A device combining battery and energy meter characteristics */\n EnergyMeterBattery = \"EnergyMeterBattery\",\n /** An air quality sensor measuring carbon dioxide (CO2) */\n AirQualityCO2 = \"AirQualityCO2\",\n /** An air quality sensor measuring carbon monoxide (CO) */\n AirQualityCO = \"AirQualityCO\",\n /** An full air quality sensor */\n AirQualityFull = \"AirQualityFull\",\n /** An air quality sensor measuring humidity */\n AirQualityHumidity = \"AirQualityHumidity\",\n /** An air quality sensor measuring nitrogen dioxide (NO2) */\n AirQualityNO2 = \"AirQualityNO2\",\n /** An air quality sensor measuring ozone (O3) */\n AirQualityO3 = \"AirQualityO3\",\n /** An air quality sensor measuring coarse particulate matter with in the 10 micron scale */\n AirQualityPM10 = \"AirQualityPM10\",\n /** An air quality sensor measuring coarse particulate matter with in the 25 micron scale */\n AirQualityPM25 = \"AirQualityPM25\",\n /** An air quality sensor measuring barometric pressure */\n AirQualityPressure = \"AirQualityPressure\",\n /** An air quality sensor measuring temperature */\n AirQualityTemperature = \"AirQualityTemperature\",\n /** An air quality sensor measuring volatile organic compounds */\n AirQualityVOC = \"AirQualityVOC\",\n /** A version 2 energy meter */\n EnergyMeterV2 = \"EnergyMeterv2\",\n HomeApplianceLaundry = \"HomeAppliance-Laundry\",\n HVAC = \"HVAC\",\n SplitUnit = \"SplitUnit\",\n}\n","import { EventEmitter } from \"events\";\nimport {\n interval,\n type Observable,\n type SchedulerLike,\n Subject,\n type Subscription,\n switchMap,\n takeUntil,\n} from \"rxjs\";\nimport { type ClientOptions, type RawData, WebSocket } from \"ws\";\nimport {\n type Configuration,\n type DeviceList,\n type DeviceResponse,\n type GetDataPointResponse,\n isConfiguration,\n isDeviceList,\n isDeviceResponse,\n isGetDataPointResponse,\n isSetDataPointResponse,\n isWebSocketMessage,\n type Logger,\n type SetDataPointResponse,\n type VirtualDevice,\n type VirtualDeviceResponse,\n type WebSocketMessage,\n} from \"./model\";\nimport { isVirtualDeviceResponse } from \"./model/validator\";\n\n/** The HTTP request method */\ntype HttpRequestMethod = \"GET\" | \"POST\" | \"DELETE\" | \"PATCH\" | \"PUT\";\n\n/** The class representing a System Access Point. */\nexport class SystemAccessPoint extends EventEmitter {\n /** The basic authentication key used for requests. */\n public readonly basicAuthKey: string;\n private webSocket?: WebSocket;\n private readonly webSocketMessageSubject = new Subject<WebSocketMessage>();\n private readonly webSocketKeepaliveTimerReset$ = new Subject<void>();\n private readonly webSocketKeepaliveTimer$ =\n this.webSocketKeepaliveTimerReset$.pipe(\n switchMap(() =>\n interval(30000, this.scheduler).pipe(\n takeUntil(this.webSocketKeepaliveTimerReset$)\n )\n )\n );\n private webSocketKeepaliveSubscription?: Subscription;\n\n /**\n * Constructs a new SystemAccessPoint instance\n *\n * @constructor\n * @param hostName {string} The system access point host name.\n * @param userName {string} The user name that shall be used to authenticate with the system access point.\n * @param password {string} The password that shall be used to authenticate with the system access point.\n * @param tlsEnabled {boolean} Determines whether the communication with the system access point shall be protected by TLS.\n * @param verboseErrors {boolean} Determines whether verbose error messages shall be used, for example for message validation.\n * @param logger {Logger} The logger instance to be used. If no explicit implementation is provided, the this.logger will be used for logging.\n */\n constructor(\n private readonly hostName: string,\n readonly userName: string,\n readonly password: string,\n private readonly tlsEnabled = true,\n private readonly verboseErrors = false,\n private readonly logger: Logger = console,\n readonly scheduler?: SchedulerLike\n ) {\n super();\n\n // Create Basic Authentication key\n this.basicAuthKey = Buffer.from(`${userName}:${password}`, \"utf8\").toString(\n \"base64\"\n );\n }\n\n /**\n * Connects to the System Access Point web socket.\n * @param certificateVerification {boolean} Determines whether the TLS certificate presented by the server will be verified.\n */\n public connectWebSocket(certificateVerification: boolean = true): void {\n if (this.webSocket && this.webSocket.readyState === WebSocket.OPEN) {\n throw new Error(\"Web socket is already connected\");\n }\n\n this.webSocket = this.createWebSocket(certificateVerification);\n // (Re-)create the web socket keepalive timer\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n this.webSocketKeepaliveSubscription =\n this.webSocketKeepaliveTimer$.subscribe(() => {\n if (!(this.webSocket && this.webSocket.readyState === WebSocket.OPEN))\n return;\n\n this.logger.log(\"keepalive timer expired, sending ping message...\");\n this.webSocket.ping();\n });\n this.webSocketKeepaliveTimerReset$.next();\n }\n\n /**\n * Creates a new virtual device.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The serial number to be assigned to the device.\n * @param virtualDevice {VirtualDevice} The virtual device to be created.\n * @returns {Promise.<VirtualDeviceResponse>} The response to the virtual device request.\n */\n public async createVirtualDevice(\n sysApUuid: string,\n deviceSerial: string,\n virtualDevice: VirtualDevice\n ): Promise<VirtualDeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `virtualdevice/${sysApUuid}/${deviceSerial}`,\n JSON.stringify(virtualDevice)\n );\n\n // Process response\n return this.processRestResponse(response, isVirtualDeviceResponse);\n }\n\n private createWebSocket(certificateVerification: boolean): WebSocket {\n // Disabling certificate verification is discouraged, issue a warning\n if (this.tlsEnabled && !certificateVerification) {\n this.logger.warn(\n \"TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.\"\n );\n }\n\n const url = `${this.tlsEnabled ? \"wss\" : \"ws\"}://${\n this.hostName\n }/fhapi/v1/api/ws`;\n const options: ClientOptions = {\n rejectUnauthorized: this.tlsEnabled && certificateVerification,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n };\n const webSocket = new WebSocket(url, options);\n webSocket.on(\"error\", (error: Error) => {\n this.emit(\"websocket-error\", error);\n this.logger.error(\"Error received\", error);\n });\n webSocket.on(\"ping\", (data: Buffer) => {\n this.emit(\"websocket-ping\", data);\n this.logger.debug(\"Ping received\", data.toString(\"ascii\"));\n this.webSocketKeepaliveTimerReset$.next();\n webSocket.pong(data);\n this.logger.debug(\"Pong sent\", data.toString(\"ascii\"));\n });\n webSocket.on(\"pong\", (data: Buffer) => {\n this.emit(\"websocket-pong\", data);\n this.logger.debug(\"Pong received\", data.toString(\"ascii\"));\n });\n webSocket.on(\"unexpected-response\", (request, response) => {\n this.emit(\"websocket-unexpected-response\", request, response);\n this.logger.error(\"Unexpected response received\");\n });\n webSocket.on(\"upgrade\", (request) => {\n this.emit(\"websocket-upgrade\", request);\n this.logger.debug(\"Upgrade request received\");\n });\n webSocket.on(\"open\", () => {\n this.emit(\"websocket-open\");\n this.logger.log(\"Connection opened\");\n });\n webSocket.on(\"close\", (code, reason) => {\n this.emit(\"websocket-close\", code, reason);\n this.logger.log(\"Connection closed\");\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n });\n webSocket.on(\"message\", (data: RawData, isBinary: boolean) => {\n this.emit(\"websocket-message\", data, isBinary);\n this.webSocketKeepaliveTimerReset$.next();\n this.processWebSocketMessage(data, isBinary);\n });\n return webSocket;\n }\n\n /**\n * Disconnects from the System Access Point web socket.\n * @param force {boolean} Determines whether or not the connection will be closed forcibly.\n */\n public disconnectWebSocket(force: boolean = false): void {\n if (!this.webSocket || this.webSocket.readyState === WebSocket.CLOSED) {\n throw new Error(\"Web socket is not open\");\n }\n\n if (force) {\n this.webSocket.terminate();\n } else {\n this.webSocket.close();\n }\n }\n\n /**\n * Gets the configuration from the system access point.\n * @returns {Promise.<Configuration>} The system access point configuration.\n */\n public async getConfiguration(): Promise<Configuration> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n \"configuration\"\n );\n\n // Process response\n return this.processRestResponse(response, isConfiguration);\n }\n\n /**\n * Gets the device list from the system access point.\n * @returns {Promise.<DeviceList>} The requested device list.\n */\n public async getDeviceList(): Promise<DeviceList> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\"GET\", \"devicelist\");\n\n // Process response\n return this.processRestResponse(response, isDeviceList);\n }\n\n /**\n * Gets the specified device from the system access point.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @returns {Promise.<DeviceResponse>} The response to the device request.\n */\n public async getDevice(\n sysApUuid: string,\n deviceSerial: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `device/${sysApUuid}/${deviceSerial}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Gets the specified data point from the system access point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @returns {Promise.<GetDataPointResponse>} The response to the get data point request.\n */\n public async getDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string\n ): Promise<GetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`\n );\n\n // Process response\n return this.processRestResponse(response, isGetDataPointResponse);\n }\n\n /**\n * Gets the web socket messages.\n * @returns {Observable.<WebSocketMessage>} An observable that is updated with the messages received from the web socket.\n */\n public getWebSocketMessages(): Observable<WebSocketMessage> {\n return this.webSocketMessageSubject.asObservable();\n }\n\n /**\n * Sets a new value for the specificed data point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @param value {string} The new value to be set.\n * @returns {Promise.<SetDataPointResponse>} The response to the set data point request.\n */\n public async setDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string,\n value: string\n ): Promise<SetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`,\n value\n );\n\n // Process response\n return this.processRestResponse(response, isSetDataPointResponse);\n }\n\n /**\n * Triggeres the given action for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param action {string} The action to be triggered.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async triggerProxyDevice(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n action: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/action/${action}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Sets the given value for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param value {string} The value to be set.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async setProxyDeviceValue(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n value: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/value/${value}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n private async fetchDataViaRest(\n method: HttpRequestMethod,\n route: string,\n body?: RequestInit[\"body\"]\n ): Promise<Response> {\n // Set up request info\n const info = `${this.tlsEnabled ? \"https\" : \"http\"}://${\n this.hostName\n }/fhapi/v1/api/rest/${route}`;\n\n // Set up request init\n const init: RequestInit = {\n method: method,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n body: body,\n };\n\n // Get response from system access point\n return fetch(info, init);\n }\n\n private async processRestResponse<TResponse>(\n response: Response,\n typeGuard: (\n obj: unknown,\n logger: Logger,\n verbose: boolean\n ) => obj is TResponse\n ): Promise<TResponse> {\n let body: unknown;\n let message: string;\n\n // Process response\n switch (response.status) {\n case 200:\n body = await response.json();\n if (!typeGuard(body, this.logger, this.verboseErrors)) {\n message = \"Received message has an unexpected type!\";\n this.logger.error(message, body);\n throw new Error(message);\n }\n\n return body;\n case 401:\n message = \"Authentication information is missing or invalid.\";\n this.logger.error(message);\n throw new Error(message);\n case 502:\n message = await response.text();\n this.logger.error(message);\n throw new Error(message);\n default:\n message = `Received HTTP ${\n response.status\n } status code unexpectedly: ${await response.text()}`;\n this.logger.error(message);\n throw new Error(message);\n }\n }\n\n private processWebSocketMessage(data: RawData, isBinary: boolean): void {\n // Do not process binary messages\n if (isBinary) {\n this.logger.warn(\n \"Binary message received. Binary messages are not processed.\"\n );\n return;\n }\n\n this.logger.debug(\"Message received\");\n /*\n * Deserialize the message.\n * The message is expected to be deserializable as a web socket message.\n * If that is not the case, that's an error case.\n */\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const serialized = data.toString();\n const message: unknown = JSON.parse(serialized);\n\n if (isWebSocketMessage(message, this.logger, this.verboseErrors)) {\n this.webSocketMessageSubject.next(message);\n return;\n }\n\n this.logger.error(\"Received message has an unexpected type!\", serialized);\n }\n}\n"],"mappings":"AACA,OAAS,SAAAA,EAAO,YAAAC,EAAU,OAAAC,MAAW,uBAErC,IAAMC,GAAUH,EAAM,CAAC,EAAG,CACxB,YAAaE,EAAI,QAAQ,EACzB,WAAYA,EAAI,QAAQ,EACxB,KAAMA,EAAI,QAAQ,EAClB,MAAOA,EAAI,QAAQ,EACnB,OAAQA,EACNF,EAAM,CAAC,EAAG,CACR,CAACC,CAAQ,EAAG,UACd,CAAC,CACH,EACA,QAASC,EACPF,EAAM,CAAC,EAAG,CACR,CAACC,CAAQ,EAAG,UACd,CAAC,CACH,EACA,WAAYC,EACVF,EAAM,CAAC,EAAG,CACR,CAACC,CAAQ,EAAG,QACd,CAAC,CACH,EACA,KAAMC,EAAI,QAAQ,CACpB,CAAC,EAEYE,EAA+B,CAC1C,QAAAD,EACF,EC3BA,OAAS,SAAAE,GAAO,YAAAC,OAAgB,uBAEhC,IAAMC,GAAgBF,GAAM,CAAC,EAAG,CAC9B,CAACC,EAAQ,EAAG,OACd,CAAC,EAEYE,EAAqC,CAChD,cAAAD,EACF,ECRA,OAAS,SAAAE,EAAO,YAAAC,EAAU,OAAAC,MAAW,uBAErC,IAAMC,GAASH,EAAM,CAAC,EAAG,CACvB,YAAaE,EAAI,QAAQ,EACzB,KAAMA,EAAI,QAAQ,EAClB,MAAOA,EAAI,QAAQ,EACnB,UAAWA,EAAI,QAAQ,EACvB,SAAUA,EAAI,QAAQ,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AEQ,wBAAwBtB,EAAeI,EAAyB,CAEtE,GAAIA,EAAU,CACZ,KAAK,OAAO,KACV,6DACF,EACA,MACF,CAEA,KAAK,OAAO,MAAM,kBAAkB,EAOpC,IAAMmB,EAAavB,EAAK,SAAS,EAC3BsB,EAAmB,KAAK,MAAMC,CAAU,EAE9C,GAAIC,EAAmBF,EAAS,KAAK,OAAQ,KAAK,aAAa,EAAG,CAChE,KAAK,wBAAwB,KAAKA,CAAO,EACzC,MACF,CAEA,KAAK,OAAO,MAAM,2CAA4CC,CAAU,CAC1E,CACF","names":["iface","indexKey","opt","Channel","ChannelTypeSuite","iface","indexKey","Configuration","ConfigurationTypeSuite","iface","indexKey","opt","Device","DeviceTypeSuite","array","iface","indexKey","DeviceList","DeviceListTypeSuite","iface","indexKey","DeviceResponse","DeviceResponseTypeSuite","iface","indexKey","Devices","DevicesTypeSuite","iface","Error","ErrorTypeSuite","iface","indexKey","Floors","FloorsTypeSuite","array","iface","indexKey","GetDataPointResponse","GetDataPointResponseTypeSuite","iface","opt","InOutPut","InOutPutTypeSuite","iface","indexKey","Rooms","RoomsTypeSuite","iface","indexKey","ScenesTriggered","ScenesTriggeredTypeSuite","iface","indexKey","SetDataPointResponse","SetDataPointResponseTypeSuite","iface","opt","SysAP","SysApTypeSuite","array","iface","indexKey","Users","UsersTypeSuite","array","enumtype","iface","opt","VirtualDevice","VirtualDeviceType","VirtualDeviceTypeSuite","iface","indexKey","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","array","iface","indexKey","opt","WebSocketMessage","WebSocketMessageTypeSuite","createCheckers","VirtualDeviceType","Channel","createCheckers","ChannelTypeSuite","InOutPutTypeSuite","Configuration","ConfigurationTypeSuite","DevicesTypeSuite","DeviceTypeSuite","FloorsTypeSuite","RoomsTypeSuite","SysApTypeSuite","UsersTypeSuite","ErrorTypeSuite","Device","DeviceList","DeviceListTypeSuite","DeviceResponse","DeviceResponseTypeSuite","GetDataPointResponse","GetDataPointResponseTypeSuite","SetDataPointResponse","SetDataPointResponseTypeSuite","VirtualDevice","VirtualDeviceTypeSuite","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","WebSocketMessage","WebSocketMessageTypeSuite","ScenesTriggeredTypeSuite","check","obj","checker","logger","verbose","error","isWebSocketMessage","isConfiguration","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isChannel","isDevice","EventEmitter","interval","Subject","switchMap","takeUntil","WebSocket","SystemAccessPoint","EventEmitter","hostName","userName","password","tlsEnabled","verboseErrors","logger","scheduler","Subject","switchMap","interval","takeUntil","certificateVerification","WebSocket","sysApUuid","deviceSerial","virtualDevice","response","isVirtualDeviceResponse","url","options","webSocket","error","data","request","code","reason","isBinary","force","isConfiguration","isDeviceList","isDeviceResponse","channel","dataPoint","isGetDataPointResponse","value","isSetDataPointResponse","deviceClass","action","method","route","body","info","init","typeGuard","message","serialized","isWebSocketMessage"]}
|
|
1
|
+
{"version":3,"sources":["../src/model/validation/channel-ti.ts","../src/model/validation/configuration-ti.ts","../src/model/validation/device-ti.ts","../src/model/validation/device-list-ti.ts","../src/model/validation/device-response-ti.ts","../src/model/validation/devices-ti.ts","../src/model/validation/error-ti.ts","../src/model/validation/floors-ti.ts","../src/model/validation/get-data-point-response-ti.ts","../src/model/validation/in-out-put-ti.ts","../src/model/validation/rooms-ti.ts","../src/model/validation/scenes-triggered-ti.ts","../src/model/validation/set-data-point-response-ti.ts","../src/model/validation/sys-ap-ti.ts","../src/model/validation/users-ti.ts","../src/model/validation/virtual-device-ti.ts","../src/model/validation/virtual-device-response-ti.ts","../src/model/validation/websocket-message-ti.ts","../src/model/validator.ts","../src/model/virtual-device.ts","../src/system-access-point.ts"],"sourcesContent":["import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Channel = iface([], {\n displayName: opt(\"string\"),\n functionID: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n inputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n outputs: opt(\n iface([], {\n [indexKey]: \"InOutPut\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n type: opt(\"string\"),\n});\n\nexport const ChannelTypeSuite: ITypeSuite = {\n Channel,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Configuration = iface([], {\n [indexKey]: \"SysAP\",\n});\n\nexport const ConfigurationTypeSuite: ITypeSuite = {\n Configuration,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst Device = iface([], {\n displayName: opt(\"string\"),\n room: opt(\"string\"),\n floor: opt(\"string\"),\n interface: opt(\"string\"),\n nativeId: opt(\"string\"),\n channels: opt(\n iface([], {\n [indexKey]: \"Channel\",\n })\n ),\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n});\n\nexport const DeviceTypeSuite: ITypeSuite = {\n Device,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceList = iface([], {\n [indexKey]: array(\"string\"),\n});\n\nexport const DeviceListTypeSuite: ITypeSuite = {\n DeviceList,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst DeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: \"Devices\",\n }),\n});\n\nexport const DeviceResponseTypeSuite: ITypeSuite = {\n DeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Devices = iface([], {\n [indexKey]: \"Device\",\n});\n\nexport const DevicesTypeSuite: ITypeSuite = {\n Devices,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface } from \"ts-interface-checker\";\n\nconst ErrorType = iface([], {\n code: \"string\",\n detail: \"string\",\n title: \"string\",\n});\n\nexport const ErrorTypeSuite: ITypeSuite = {\n Error: ErrorType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Floors = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n rooms: \"Rooms\",\n }),\n});\n\nexport const FloorsTypeSuite: ITypeSuite = {\n Floors,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst GetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n values: array(\"string\"),\n }),\n});\n\nexport const GetDataPointResponseTypeSuite: ITypeSuite = {\n GetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst InOutPut = iface([], {\n value: opt(\"string\"),\n pairingID: opt(\"number\"),\n});\n\nexport const InOutPutTypeSuite: ITypeSuite = {\n InOutPut,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst Rooms = iface([], {\n [indexKey]: iface([], {\n name: \"string\",\n }),\n});\n\nexport const RoomsTypeSuite: ITypeSuite = {\n Rooms,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst ScenesTriggered = iface([], {\n [indexKey]: iface([], {\n channels: iface([], {\n [indexKey]: iface([], {\n outputs: iface([], {\n [indexKey]: iface([], {\n value: \"string\",\n pairingID: \"number\",\n }),\n }),\n }),\n }),\n }),\n});\n\nexport const ScenesTriggeredTypeSuite: ITypeSuite = {\n ScenesTriggered,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst SetDataPointResponse = iface([], {\n [indexKey]: iface([], {\n [indexKey]: \"string\",\n }),\n});\n\nexport const SetDataPointResponseTypeSuite: ITypeSuite = {\n SetDataPointResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, opt } from \"ts-interface-checker\";\n\nconst SysAP = iface([], {\n devices: \"Devices\",\n floorplan: iface([], {\n floors: \"Floors\",\n }),\n sysapName: \"string\",\n users: \"Users\",\n error: opt(\"Error\"),\n});\n\nexport const SysApTypeSuite: ITypeSuite = {\n SysAP,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey } from \"ts-interface-checker\";\n\nconst Users = iface([], {\n [indexKey]: iface([], {\n enabled: \"boolean\",\n flags: array(\"string\"),\n grantedPermissions: array(\"string\"),\n jid: \"string\",\n name: \"string\",\n requestedPermissions: array(\"string\"),\n role: \"string\",\n }),\n});\n\nexport const UsersTypeSuite: ITypeSuite = {\n Users,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, enumtype, iface, opt } from \"ts-interface-checker\";\n\nconst VirtualDevice = iface([], {\n type: \"VirtualDeviceType\",\n properties: opt(\n iface([], {\n ttl: opt(\"string\"),\n displayname: opt(\"string\"),\n flavor: opt(\"string\"),\n capabilities: opt(array(\"number\")),\n })\n ),\n});\n\nexport const VirtualDeviceType = enumtype({\n BinarySensor: \"BinarySensor\",\n BlindActuator: \"BlindActuator\",\n SwitchingActuator: \"SwitchingActuator\",\n CeilingFanActuator: \"CeilingFanActuator\",\n RTC: \"RTC\",\n DimActuator: \"DimActuator\",\n EVCharging: \"evcharging\",\n WindowSensor: \"WindowSensor\",\n SimpleDoorlock: \"simple_doorlock\",\n ShutterActuator: \"ShutterActuator\",\n WeatherStation: \"WeatherStation\",\n WeatherTemperatureSensor: \"Weather-TemperatureSensor\",\n WeatherWindSensor: \"Weather-WindSensor\",\n WeatherBrightnessSensor: \"Weather-BrightnessSensor\",\n WeatherRainSensor: \"Weather-RainSensor\",\n WindowActuator: \"WindowActuator\",\n CODetector: \"CODetector\",\n FireDetector: \"FireDetector\",\n KNXSwitchSensor: \"KNX-SwitchSensor\",\n MediaPlayer: \"MediaPlayer\",\n EnergyBattery: \"EnergyBattery\",\n EnergyInverter: \"EnergyInverter\",\n EnergyMeter: \"EnergyMeter\",\n EnergyInverterBattery: \"EnergyInverterBattery\",\n EnergyInverterMeter: \"EnergyInverterMeter\",\n EnergyInverterMeterBattery: \"EnergyInverterMeterBattery\",\n EnergyMeterBattery: \"EnergyMeterBattery\",\n AirQualityCO2: \"AirQualityCO2\",\n AirQualityCO: \"AirQualityCO\",\n AirQualityFull: \"AirQualityFull\",\n AirQualityHumidity: \"AirQualityHumidity\",\n AirQualityNO2: \"AirQualityNO2\",\n AirQualityO3: \"AirQualityO3\",\n AirQualityPM10: \"AirQualityPM10\",\n AirQualityPM25: \"AirQualityPM25\",\n AirQualityPressure: \"AirQualityPressure\",\n AirQualityTemperature: \"AirQualityTemperature\",\n AirQualityVOC: \"AirQualityVOC\",\n EnergyMeterV2: \"EnergyMeterv2\",\n HomeApplianceLaundry: \"HomeAppliance-Laundry\",\n HVAC: \"HVAC\",\n SplitUnit: \"SplitUnit\",\n});\n\nexport const VirtualDeviceTypeSuite: ITypeSuite = {\n VirtualDevice,\n VirtualDeviceType,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { iface, indexKey } from \"ts-interface-checker\";\n\nconst VirtualDeviceResponse = iface([], {\n [indexKey]: iface([], {\n devices: iface([], {\n [indexKey]: iface([], {\n serial: \"string\",\n }),\n }),\n }),\n});\n\nexport const VirtualDeviceResponseTypeSuite: ITypeSuite = {\n VirtualDeviceResponse,\n};\n","import type { ITypeSuite } from \"ts-interface-checker\";\nimport { array, iface, indexKey, opt } from \"ts-interface-checker\";\n\nconst WebSocketMessage = iface([], {\n [indexKey]: iface([], {\n datapoints: iface([], {\n [indexKey]: \"string\",\n }),\n devices: \"Devices\",\n devicesAdded: array(\"string\"),\n devicesRemoved: array(\"string\"),\n scenesTriggered: \"ScenesTriggered\",\n parameters: opt(\n iface([], {\n [indexKey]: \"string\",\n })\n ),\n }),\n});\n\nexport const WebSocketMessageTypeSuite: ITypeSuite = {\n WebSocketMessage,\n};\n","import {\n ChannelTypeSuite,\n DeviceTypeSuite,\n DevicesTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite,\n WebSocketMessageTypeSuite,\n DeviceListTypeSuite,\n SetDataPointResponseTypeSuite,\n GetDataPointResponseTypeSuite,\n ConfigurationTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite,\n DeviceResponseTypeSuite,\n VirtualDeviceTypeSuite,\n VirtualDeviceResponseTypeSuite,\n} from \"./validation\";\nimport type { Checker } from \"ts-interface-checker\";\nimport { createCheckers } from \"ts-interface-checker\";\nimport { type WebSocketMessage as Message } from \"./websocket-message\";\nimport { type Configuration as Config } from \"./configuration\";\nimport { type Channel as Chan } from \"./channel\";\nimport { type Device as Dev } from \"./device\";\nimport { type DeviceList as DevList } from \"./device-list\";\nimport { type DeviceResponse as DevResponse } from \"./device-response\";\nimport { type GetDataPointResponse as GetResponse } from \"./get-data-point-response\";\nimport { type SetDataPointResponse as SetResponse } from \"./set-data-point-response\";\nimport { type VirtualDeviceResponse as VDeviceResponse } from \"./virtual-device-response\";\nimport { type VirtualDevice as VDevice } from \"./virtual-device\";\nimport { type Logger } from \"./logger\";\n\nconst { Channel } = createCheckers(ChannelTypeSuite, InOutPutTypeSuite);\n\nconst { Configuration } = createCheckers(\n ConfigurationTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n FloorsTypeSuite,\n RoomsTypeSuite,\n SysApTypeSuite,\n UsersTypeSuite,\n ErrorTypeSuite\n);\n\nconst { Device } = createCheckers(\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { DeviceList } = createCheckers(DeviceListTypeSuite);\n\nconst { DeviceResponse } = createCheckers(\n DeviceResponseTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite\n);\n\nconst { GetDataPointResponse } = createCheckers(GetDataPointResponseTypeSuite);\n\nconst { SetDataPointResponse } = createCheckers(SetDataPointResponseTypeSuite);\n\nconst { VirtualDevice } = createCheckers(VirtualDeviceTypeSuite);\n\nconst { VirtualDeviceResponse } = createCheckers(\n VirtualDeviceResponseTypeSuite\n);\n\nconst { WebSocketMessage } = createCheckers(\n WebSocketMessageTypeSuite,\n DevicesTypeSuite,\n DeviceTypeSuite,\n ChannelTypeSuite,\n InOutPutTypeSuite,\n ScenesTriggeredTypeSuite\n);\n\nfunction check(\n obj: unknown,\n checker: Checker,\n logger: Logger,\n verbose: boolean\n): boolean {\n if (verbose) {\n try {\n checker.check(obj);\n return true;\n } catch (error) {\n logger.error(\"Object validation failed!\", error);\n return false;\n }\n }\n\n return checker.test(obj);\n}\n\n/**\n * Determines whether the specified object is a web socket message.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a web socket message.\n */\nexport function isWebSocketMessage(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Message {\n return check(obj, WebSocketMessage, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a configuration.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a configuration.\n */\nexport function isConfiguration(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Config {\n return check(obj, Configuration, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device list.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device list.\n */\nexport function isDeviceList(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevList {\n return check(obj, DeviceList, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device response.\n */\nexport function isDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is DevResponse {\n return check(obj, DeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a get data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a get data point request.\n */\nexport function isGetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is GetResponse {\n return check(obj, GetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a valid response to a set data point request.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a set data point request.\n */\nexport function isSetDataPointResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is SetResponse {\n return check(obj, SetDataPointResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a virtual device.\n */\nexport function isVirtualDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDevice {\n return check(obj, VirtualDevice, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a virtual device response.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a response to a virtual device request.\n */\nexport function isVirtualDeviceResponse(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is VDeviceResponse {\n return check(obj, VirtualDeviceResponse, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a channel.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a channel.\n */\nexport function isChannel(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Chan {\n return check(obj, Channel, logger, verbose);\n}\n\n/**\n * Determines whether the specified object is a device.\n * @param obj {object} The object to be tested\n * @param logger {Logger} The logger instance to be used.\n * @param verbose {boolean} Determines whether validation errors shall be logged. Default value is false.\n * @returns {boolean} A value indicating whether the specified object is a device.\n */\nexport function isDevice(\n obj: unknown,\n logger: Logger,\n verbose = false\n): obj is Dev {\n return check(obj, Device, logger, verbose);\n}\n","/** Defines a virtual device. */\nexport interface VirtualDevice {\n /** The virtual device type. */\n type: VirtualDeviceType;\n /** The virtual device properties */\n properties?: {\n /** The time to live value indicates the number of seconds the system access point will wait for a message before it assumes the device to be unresponsive. */\n ttl?: string;\n /** The display name for the virtual device. */\n displayname?: string;\n /** The virtual device flavor. */\n flavor?: string;\n /** The virtual device capabilities. */\n capabilities?: Array<number>;\n };\n}\n\n/** Defines the possible types of virtual devices. */\nexport enum VirtualDeviceType {\n /** A binary sensor */\n BinarySensor = \"BinarySensor\",\n /** A blind actuator */\n BlindActuator = \"BlindActuator\",\n /** A switching actuator */\n SwitchingActuator = \"SwitchingActuator\",\n /** A ceiling fan actuator */\n CeilingFanActuator = \"CeilingFanActuator\",\n /** A real time clock */\n RTC = \"RTC\",\n /** A dimmer actuator */\n DimActuator = \"DimActuator\",\n /** A charger for an electronic vehicle */\n EVCharging = \"evcharging\",\n /** A window sensor */\n WindowSensor = \"WindowSensor\",\n /** A simple door lock */\n SimpleDoorlock = \"simple_doorlock\",\n /** A shutter actuator */\n ShutterActuator = \"ShutterActuator\",\n /** A weather station */\n WeatherStation = \"WeatherStation\",\n /** A temperature sensor */\n WeatherTemperatureSensor = \"Weather-TemperatureSensor\",\n /** A wind sensor */\n WeatherWindSensor = \"Weather-WindSensor\",\n /** A brightness sensor */\n WeatherBrightnessSensor = \"Weather-BrightnessSensor\",\n /** A rain sensor */\n WeatherRainSensor = \"Weather-RainSensor\",\n /** A window actuator */\n WindowActuator = \"WindowActuator\",\n /** A detector for carbon monoxide (CO) */\n CODetector = \"CODetector\",\n /** A fire detector */\n FireDetector = \"FireDetector\",\n /** A KNX switch sensor */\n KNXSwitchSensor = \"KNX-SwitchSensor\",\n /** A media player */\n MediaPlayer = \"MediaPlayer\",\n /** A battery */\n EnergyBattery = \"EnergyBattery\",\n /** An inverter */\n EnergyInverter = \"EnergyInverter\",\n /** An energy meter */\n EnergyMeter = \"EnergyMeter\",\n /** A device combining inverter and battery characteristics */\n EnergyInverterBattery = \"EnergyInverterBattery\",\n /** A device combining inverter and energy meter characteristics */\n EnergyInverterMeter = \"EnergyInverterMeter\",\n /** A device combining inverter, battery and energy meter characteristics */\n EnergyInverterMeterBattery = \"EnergyInverterMeterBattery\",\n /** A device combining battery and energy meter characteristics */\n EnergyMeterBattery = \"EnergyMeterBattery\",\n /** An air quality sensor measuring carbon dioxide (CO2) */\n AirQualityCO2 = \"AirQualityCO2\",\n /** An air quality sensor measuring carbon monoxide (CO) */\n AirQualityCO = \"AirQualityCO\",\n /** An full air quality sensor */\n AirQualityFull = \"AirQualityFull\",\n /** An air quality sensor measuring humidity */\n AirQualityHumidity = \"AirQualityHumidity\",\n /** An air quality sensor measuring nitrogen dioxide (NO2) */\n AirQualityNO2 = \"AirQualityNO2\",\n /** An air quality sensor measuring ozone (O3) */\n AirQualityO3 = \"AirQualityO3\",\n /** An air quality sensor measuring coarse particulate matter with in the 10 micron scale */\n AirQualityPM10 = \"AirQualityPM10\",\n /** An air quality sensor measuring coarse particulate matter with in the 25 micron scale */\n AirQualityPM25 = \"AirQualityPM25\",\n /** An air quality sensor measuring barometric pressure */\n AirQualityPressure = \"AirQualityPressure\",\n /** An air quality sensor measuring temperature */\n AirQualityTemperature = \"AirQualityTemperature\",\n /** An air quality sensor measuring volatile organic compounds */\n AirQualityVOC = \"AirQualityVOC\",\n /** A version 2 energy meter */\n EnergyMeterV2 = \"EnergyMeterv2\",\n HomeApplianceLaundry = \"HomeAppliance-Laundry\",\n HVAC = \"HVAC\",\n SplitUnit = \"SplitUnit\",\n}\n","import { EventEmitter } from \"node:events\";\nimport {\n interval,\n type Observable,\n type SchedulerLike,\n Subject,\n type Subscription,\n switchMap,\n takeUntil,\n} from \"rxjs\";\nimport { type ClientOptions, type RawData, WebSocket } from \"ws\";\nimport {\n type Configuration,\n type DeviceList,\n type DeviceResponse,\n type GetDataPointResponse,\n isConfiguration,\n isDeviceList,\n isDeviceResponse,\n isGetDataPointResponse,\n isSetDataPointResponse,\n isWebSocketMessage,\n type Logger,\n type SetDataPointResponse,\n type VirtualDevice,\n type VirtualDeviceResponse,\n type WebSocketMessage,\n} from \"./model\";\nimport { isVirtualDeviceResponse } from \"./model/validator\";\n\n/** The HTTP request method */\ntype HttpRequestMethod = \"GET\" | \"POST\" | \"DELETE\" | \"PATCH\" | \"PUT\";\n\n/** The class representing a System Access Point. */\nexport class SystemAccessPoint extends EventEmitter {\n /** The basic authentication key used for requests. */\n public readonly basicAuthKey: string;\n private webSocket?: WebSocket;\n private readonly webSocketMessageSubject = new Subject<WebSocketMessage>();\n private readonly webSocketKeepaliveTimerReset$ = new Subject<void>();\n private readonly webSocketKeepaliveTimer$ =\n this.webSocketKeepaliveTimerReset$.pipe(\n switchMap(() =>\n interval(30000, this.scheduler).pipe(\n takeUntil(this.webSocketKeepaliveTimerReset$)\n )\n )\n );\n private webSocketKeepaliveSubscription?: Subscription;\n\n /**\n * Constructs a new SystemAccessPoint instance\n *\n * @constructor\n * @param hostName {string} The system access point host name.\n * @param userName {string} The user name that shall be used to authenticate with the system access point.\n * @param password {string} The password that shall be used to authenticate with the system access point.\n * @param tlsEnabled {boolean} Determines whether the communication with the system access point shall be protected by TLS.\n * @param verboseErrors {boolean} Determines whether verbose error messages shall be used, for example for message validation.\n * @param logger {Logger} The logger instance to be used. If no explicit implementation is provided, the this.logger will be used for logging.\n */\n constructor(\n private readonly hostName: string,\n readonly userName: string,\n readonly password: string,\n private readonly tlsEnabled = true,\n private readonly verboseErrors = false,\n private readonly logger: Logger = console,\n readonly scheduler?: SchedulerLike\n ) {\n super();\n\n // Create Basic Authentication key\n this.basicAuthKey = Buffer.from(`${userName}:${password}`, \"utf8\").toString(\n \"base64\"\n );\n }\n\n /**\n * Connects to the System Access Point web socket.\n * @param certificateVerification {boolean} Determines whether the TLS certificate presented by the server will be verified.\n */\n public connectWebSocket(certificateVerification: boolean = true): void {\n if (this.webSocket?.readyState === WebSocket.OPEN) {\n throw new Error(\"Web socket is already connected\");\n }\n\n this.webSocket = this.createWebSocket(certificateVerification);\n // (Re-)create the web socket keepalive timer\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n this.webSocketKeepaliveSubscription =\n this.webSocketKeepaliveTimer$.subscribe(() => {\n if (this.webSocket?.readyState !== WebSocket.OPEN) return;\n\n this.logger.log(\"keepalive timer expired, sending ping message...\");\n this.webSocket.ping();\n });\n this.webSocketKeepaliveTimerReset$.next();\n }\n\n /**\n * Creates a new virtual device.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The serial number to be assigned to the device.\n * @param virtualDevice {VirtualDevice} The virtual device to be created.\n * @returns {Promise.<VirtualDeviceResponse>} The response to the virtual device request.\n */\n public async createVirtualDevice(\n sysApUuid: string,\n deviceSerial: string,\n virtualDevice: VirtualDevice\n ): Promise<VirtualDeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `virtualdevice/${sysApUuid}/${deviceSerial}`,\n JSON.stringify(virtualDevice)\n );\n\n // Process response\n return this.processRestResponse(response, isVirtualDeviceResponse);\n }\n\n private createWebSocket(certificateVerification: boolean): WebSocket {\n // Disabling certificate verification is discouraged, issue a warning\n if (this.tlsEnabled && !certificateVerification) {\n this.logger.warn(\n \"TLS certificate verification is disabled! This poses a security risk, activating certificate verification is strictly recommended.\"\n );\n }\n\n const url = `${this.tlsEnabled ? \"wss\" : \"ws\"}://${\n this.hostName\n }/fhapi/v1/api/ws`;\n const options: ClientOptions = {\n rejectUnauthorized: this.tlsEnabled && certificateVerification,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n };\n const webSocket = new WebSocket(url, options);\n webSocket.on(\"error\", (error: Error) => {\n this.emit(\"websocket-error\", error);\n this.logger.error(\"Error received\", error);\n });\n webSocket.on(\"ping\", (data: Buffer) => {\n this.emit(\"websocket-ping\", data);\n this.logger.debug(\"Ping received\", data.toString(\"ascii\"));\n this.webSocketKeepaliveTimerReset$.next();\n webSocket.pong(data);\n this.logger.debug(\"Pong sent\", data.toString(\"ascii\"));\n });\n webSocket.on(\"pong\", (data: Buffer) => {\n this.emit(\"websocket-pong\", data);\n this.logger.debug(\"Pong received\", data.toString(\"ascii\"));\n });\n webSocket.on(\"unexpected-response\", (request, response) => {\n this.emit(\"websocket-unexpected-response\", request, response);\n this.logger.error(\"Unexpected response received\");\n });\n webSocket.on(\"upgrade\", (request) => {\n this.emit(\"websocket-upgrade\", request);\n this.logger.debug(\"Upgrade request received\");\n });\n webSocket.on(\"open\", () => {\n this.emit(\"websocket-open\");\n this.logger.log(\"Connection opened\");\n });\n webSocket.on(\"close\", (code, reason) => {\n this.emit(\"websocket-close\", code, reason);\n this.logger.log(\"Connection closed\");\n this.webSocketKeepaliveSubscription?.unsubscribe();\n this.webSocketKeepaliveSubscription = undefined;\n });\n webSocket.on(\"message\", (data: RawData, isBinary: boolean) => {\n this.emit(\"websocket-message\", data, isBinary);\n this.webSocketKeepaliveTimerReset$.next();\n this.processWebSocketMessage(data, isBinary);\n });\n return webSocket;\n }\n\n /**\n * Disconnects from the System Access Point web socket.\n * @param force {boolean} Determines whether or not the connection will be closed forcibly.\n */\n public disconnectWebSocket(force: boolean = false): void {\n if (!this.webSocket || this.webSocket.readyState === WebSocket.CLOSED) {\n throw new Error(\"Web socket is not open\");\n }\n\n if (force) {\n this.webSocket.terminate();\n } else {\n this.webSocket.close();\n }\n }\n\n /**\n * Gets the configuration from the system access point.\n * @returns {Promise.<Configuration>} The system access point configuration.\n */\n public async getConfiguration(): Promise<Configuration> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n \"configuration\"\n );\n\n // Process response\n return this.processRestResponse(response, isConfiguration);\n }\n\n /**\n * Gets the device list from the system access point.\n * @returns {Promise.<DeviceList>} The requested device list.\n */\n public async getDeviceList(): Promise<DeviceList> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\"GET\", \"devicelist\");\n\n // Process response\n return this.processRestResponse(response, isDeviceList);\n }\n\n /**\n * Gets the specified device from the system access point.\n * @param sysApUuid {string} The UUID identifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @returns {Promise.<DeviceResponse>} The response to the device request.\n */\n public async getDevice(\n sysApUuid: string,\n deviceSerial: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `device/${sysApUuid}/${deviceSerial}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Gets the specified data point from the system access point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @returns {Promise.<GetDataPointResponse>} The response to the get data point request.\n */\n public async getDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string\n ): Promise<GetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`\n );\n\n // Process response\n return this.processRestResponse(response, isGetDataPointResponse);\n }\n\n /**\n * Gets the web socket messages.\n * @returns {Observable.<WebSocketMessage>} An observable that is updated with the messages received from the web socket.\n */\n public getWebSocketMessages(): Observable<WebSocketMessage> {\n return this.webSocketMessageSubject.asObservable();\n }\n\n /**\n * Sets a new value for the specificed data point.\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceSerial {string} The device serial number.\n * @param channel {string} The channel identifier.\n * @param dataPoint {string} The datapoint identifier.\n * @param value {string} The new value to be set.\n * @returns {Promise.<SetDataPointResponse>} The response to the set data point request.\n */\n public async setDatapoint(\n sysApUuid: string,\n deviceSerial: string,\n channel: string,\n dataPoint: string,\n value: string\n ): Promise<SetDataPointResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `datapoint/${sysApUuid}/${deviceSerial}.${channel}.${dataPoint}`,\n value\n );\n\n // Process response\n return this.processRestResponse(response, isSetDataPointResponse);\n }\n\n /**\n * Triggeres the given action for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param action {string} The action to be triggered.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async triggerProxyDevice(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n action: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"GET\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/action/${action}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n /**\n * Sets the given value for the specified proxy device. Please note that this method is part of the experimental API!\n * @param sysApUuid {string} The UUID idenfifying the system access point.\n * @param deviceClass {string} The device class.\n * @param deviceSerial {string} The device serial number.\n * @param value {string} The value to be set.\n * @returns {Promise.<DeviceResponse>} The response to the request.\n */\n public async setProxyDeviceValue(\n sysApUuid: string,\n deviceClass: string,\n deviceSerial: string,\n value: string\n ): Promise<DeviceResponse> {\n // Get response from system access point\n const response: Response = await this.fetchDataViaRest(\n \"PUT\",\n `proxydevice/${sysApUuid}/${deviceClass}/${deviceSerial}/value/${value}`\n );\n\n // Process response\n return this.processRestResponse(response, isDeviceResponse);\n }\n\n private async fetchDataViaRest(\n method: HttpRequestMethod,\n route: string,\n body?: RequestInit[\"body\"]\n ): Promise<Response> {\n // Set up request info\n const info = `${this.tlsEnabled ? \"https\" : \"http\"}://${\n this.hostName\n }/fhapi/v1/api/rest/${route}`;\n\n // Set up request init\n const init: RequestInit = {\n method: method,\n headers: {\n Authorization: `Basic ${this.basicAuthKey}`,\n },\n body: body,\n };\n\n // Get response from system access point\n return fetch(info, init);\n }\n\n private async processRestResponse<TResponse>(\n response: Response,\n typeGuard: (\n obj: unknown,\n logger: Logger,\n verbose: boolean\n ) => obj is TResponse\n ): Promise<TResponse> {\n let body: unknown;\n let message: string;\n\n // Process response\n switch (response.status) {\n case 200:\n body = await response.json();\n if (!typeGuard(body, this.logger, this.verboseErrors)) {\n message = \"Received message has an unexpected type!\";\n this.logger.error(message, body);\n throw new Error(message);\n }\n\n return body;\n case 401:\n message = \"Authentication information is missing or invalid.\";\n this.logger.error(message);\n throw new Error(message);\n case 502:\n message = await response.text();\n this.logger.error(message);\n throw new Error(message);\n default:\n message = `Received HTTP ${\n response.status\n } status code unexpectedly: ${await response.text()}`;\n this.logger.error(message);\n throw new Error(message);\n }\n }\n\n private processWebSocketMessage(data: RawData, isBinary: boolean): void {\n // Do not process binary messages\n if (isBinary) {\n this.logger.warn(\n \"Binary message received. Binary messages are not processed.\"\n );\n return;\n }\n\n this.logger.debug(\"Message received\");\n /*\n * Deserialize the message.\n * The message is expected to be deserializable as a web socket message.\n * If that is not the case, that's an error case.\n */\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const serialized = data.toString();\n const message: unknown = JSON.parse(serialized);\n\n if (isWebSocketMessage(message, this.logger, this.verboseErrors)) {\n this.webSocketMessageSubject.next(message);\n return;\n }\n\n this.logger.error(\"Received message has an unexpected type!\", ser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","opt","Channel","ChannelTypeSuite","iface","indexKey","Configuration","ConfigurationTypeSuite","iface","indexKey","opt","Device","DeviceTypeSuite","array","iface","indexKey","DeviceList","DeviceListTypeSuite","iface","indexKey","DeviceResponse","DeviceResponseTypeSuite","iface","indexKey","Devices","DevicesTypeSuite","iface","ErrorType","ErrorTypeSuite","iface","indexKey","Floors","FloorsTypeSuite","array","iface","indexKey","GetDataPointResponse","GetDataPointResponseTypeSuite","iface","opt","InOutPut","InOutPutTypeSuite","iface","indexKey","Rooms","RoomsTypeSuite","iface","indexKey","ScenesTriggered","ScenesTriggeredTypeSuite","iface","indexKey","SetDataPointResponse","SetDataPointResponseTypeSuite","iface","opt","SysAP","SysApTypeSuite","array","iface","indexKey","Users","UsersTypeSuite","array","enumtype","iface","opt","VirtualDevice","VirtualDeviceType","VirtualDeviceTypeSuite","iface","indexKey","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","array","iface","indexKey","opt","WebSocketMessage","WebSocketMessageTypeSuite","createCheckers","VirtualDeviceType","Channel","createCheckers","ChannelTypeSuite","InOutPutTypeSuite","Configuration","ConfigurationTypeSuite","DevicesTypeSuite","DeviceTypeSuite","FloorsTypeSuite","RoomsTypeSuite","SysApTypeSuite","UsersTypeSuite","ErrorTypeSuite","Device","DeviceList","DeviceListTypeSuite","DeviceResponse","DeviceResponseTypeSuite","GetDataPointResponse","GetDataPointResponseTypeSuite","SetDataPointResponse","SetDataPointResponseTypeSuite","VirtualDevice","VirtualDeviceTypeSuite","VirtualDeviceResponse","VirtualDeviceResponseTypeSuite","WebSocketMessage","WebSocketMessageTypeSuite","ScenesTriggeredTypeSuite","check","obj","checker","logger","verbose","error","isWebSocketMessage","isConfiguration","isDeviceList","isDeviceResponse","isGetDataPointResponse","isSetDataPointResponse","isVirtualDevice","isVirtualDeviceResponse","isChannel","isDevice","EventEmitter","interval","Subject","switchMap","takeUntil","WebSocket","SystemAccessPoint","EventEmitter","hostName","userName","password","tlsEnabled","verboseErrors","logger","scheduler","Subject","switchMap","interval","takeUntil","certificateVerification","WebSocket","sysApUuid","deviceSerial","virtualDevice","response","isVirtualDeviceResponse","url","options","webSocket","error","data","request","code","reason","isBinary","force","isConfiguration","isDeviceList","isDeviceResponse","channel","dataPoint","isGetDataPointResponse","value","isSetDataPointResponse","deviceClass","action","method","route","body","info","init","typeGuard","message","serialized","isWebSocketMessage"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freeathome-local-api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"preview": false,
|
|
5
5
|
"description": "A client library for the BUSCH-JAEGER free@home local API implemented in TypeScript",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/lion-and-bear/freeathome-local-api-client.git"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"free@home",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"name": "Philip Gerke",
|
|
23
23
|
"url": "https://www.philipgerke.com"
|
|
24
24
|
},
|
|
25
|
-
"homepage": "https://github.com/
|
|
25
|
+
"homepage": "https://github.com/lion-and-bear/freeathome-local-api-client#readme",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/
|
|
28
|
+
"url": "https://github.com/lion-and-bear/freeathome-local-api-client/issues"
|
|
29
29
|
},
|
|
30
30
|
"main": "dist/index.js",
|
|
31
31
|
"module": "dist/index.mjs",
|
|
@@ -51,26 +51,26 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"rxjs": "^7.8.2",
|
|
53
53
|
"ts-interface-checker": "^1.0.2",
|
|
54
|
-
"ws": "^8.
|
|
54
|
+
"ws": "^8.20.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@eslint/eslintrc": "^3.3.
|
|
58
|
-
"@eslint/js": "^9.39.
|
|
57
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
58
|
+
"@eslint/js": "^9.39.4",
|
|
59
59
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
60
60
|
"@types/jasmine": "^6.0.0",
|
|
61
|
-
"@types/node": "^24.
|
|
61
|
+
"@types/node": "^24.12.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
64
|
-
"@typescript-eslint/parser": "^8.
|
|
65
|
-
"c8": "^
|
|
66
|
-
"eslint": "^9.39.
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
64
|
+
"@typescript-eslint/parser": "^8.57.2",
|
|
65
|
+
"c8": "^11.0.0",
|
|
66
|
+
"eslint": "^9.39.4",
|
|
67
67
|
"eslint-config-prettier": "^10.1.8",
|
|
68
68
|
"eslint-plugin-import": "^2.32.0",
|
|
69
69
|
"eslint-plugin-n": "^17.24.0",
|
|
70
70
|
"eslint-plugin-prettier": "^5.5.5",
|
|
71
71
|
"eslint-plugin-promise": "^7.2.1",
|
|
72
|
-
"globals": "^17.
|
|
73
|
-
"jasmine": "^6.
|
|
72
|
+
"globals": "^17.4.0",
|
|
73
|
+
"jasmine": "^6.1.0",
|
|
74
74
|
"jasmine-spec-reporter": "^7.0.0",
|
|
75
75
|
"prettier": "^3.8.1",
|
|
76
76
|
"rimraf": "^6.1.3",
|