bt-sensors-plugin-sk 1.1.0 → 1.1.1
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/.vscode/launch.json +7 -0
- package/README.md +8 -2
- package/package.json +1 -1
- package/public/159.js +2 -0
- package/public/159.js.LICENSE.txt +14 -0
- package/public/30.js +8 -0
- package/public/30.js.LICENSE.txt +65 -0
- package/public/540.js +2 -0
- package/public/540.js.LICENSE.txt +8 -0
- package/public/893.js +1 -0
- package/public/main.js +100 -0
- package/public/remoteEntry.js +129 -0
- package/sensor_classes/IBeacon.js +9 -2
- package/sensor_classes/VictronBatteryMonitor.js +11 -4
- package/sensor_classes/VictronDCEnergyMeter.js +11 -4
- package/sensor_classes/VictronOrionXS.js +1 -2
- package/testqueue.js +64 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
Copyright (c) 2018 Jed Watson.
|
|
9
|
+
Licensed under the MIT License (MIT), see
|
|
10
|
+
http://jedwatson.github.io/classnames
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @license React
|
|
15
|
+
* react-is.production.min.js
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A better abstraction over CSS.
|
|
25
|
+
*
|
|
26
|
+
* @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
|
|
27
|
+
* @website https://github.com/cssinjs/jss
|
|
28
|
+
* @license MIT
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** @license React v0.19.1
|
|
32
|
+
* scheduler.production.min.js
|
|
33
|
+
*
|
|
34
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
35
|
+
*
|
|
36
|
+
* This source code is licensed under the MIT license found in the
|
|
37
|
+
* LICENSE file in the root directory of this source tree.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/** @license React v16.13.1
|
|
41
|
+
* react-is.production.min.js
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the MIT license found in the
|
|
46
|
+
* LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** @license React v16.14.0
|
|
50
|
+
* react-dom.production.min.js
|
|
51
|
+
*
|
|
52
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the MIT license found in the
|
|
55
|
+
* LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/** @license React v16.14.0
|
|
59
|
+
* react-jsx-runtime.production.min.js
|
|
60
|
+
*
|
|
61
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
62
|
+
*
|
|
63
|
+
* This source code is licensed under the MIT license found in the
|
|
64
|
+
* LICENSE file in the root directory of this source tree.
|
|
65
|
+
*/
|
package/public/540.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 540.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunkbt_sensors_plugin_sk=self.webpackChunkbt_sensors_plugin_sk||[]).push([[540],{5287:(e,r,t)=>{var n=t(5228),o="function"==typeof Symbol&&Symbol.for,u=o?Symbol.for("react.element"):60103,f=o?Symbol.for("react.portal"):60106,l=o?Symbol.for("react.fragment"):60107,c=o?Symbol.for("react.strict_mode"):60108,i=o?Symbol.for("react.profiler"):60114,a=o?Symbol.for("react.provider"):60109,s=o?Symbol.for("react.context"):60110,p=o?Symbol.for("react.forward_ref"):60112,y=o?Symbol.for("react.suspense"):60113,d=o?Symbol.for("react.memo"):60115,h=o?Symbol.for("react.lazy"):60116,v="function"==typeof Symbol&&Symbol.iterator;function m(e){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)r+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_={};function S(e,r,t){this.props=e,this.context=r,this.refs=_,this.updater=t||b}function k(){}function g(e,r,t){this.props=e,this.context=r,this.refs=_,this.updater=t||b}S.prototype.isReactComponent={},S.prototype.setState=function(e,r){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(m(85));this.updater.enqueueSetState(this,e,r,"setState")},S.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},k.prototype=S.prototype;var w=g.prototype=new k;w.constructor=g,n(w,S.prototype),w.isPureReactComponent=!0;var $={current:null},C=Object.prototype.hasOwnProperty,E={key:!0,ref:!0,__self:!0,__source:!0};function R(e,r,t){var n,o={},f=null,l=null;if(null!=r)for(n in void 0!==r.ref&&(l=r.ref),void 0!==r.key&&(f=""+r.key),r)C.call(r,n)&&!E.hasOwnProperty(n)&&(o[n]=r[n]);var c=arguments.length-2;if(1===c)o.children=t;else if(1<c){for(var i=Array(c),a=0;a<c;a++)i[a]=arguments[a+2];o.children=i}if(e&&e.defaultProps)for(n in c=e.defaultProps)void 0===o[n]&&(o[n]=c[n]);return{$$typeof:u,type:e,key:f,ref:l,props:o,_owner:$.current}}function x(e){return"object"==typeof e&&null!==e&&e.$$typeof===u}var P=/\/+/g,j=[];function O(e,r,t,n){if(j.length){var o=j.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function A(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>j.length&&j.push(e)}function I(e,r,t,n){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l=!1;if(null===e)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case u:case f:l=!0}}if(l)return t(n,e,""===r?"."+q(e,0):r),1;if(l=0,r=""===r?".":r+":",Array.isArray(e))for(var c=0;c<e.length;c++){var i=r+q(o=e[c],c);l+=I(o,i,t,n)}else if("function"==typeof(i=null===e||"object"!=typeof e?null:"function"==typeof(i=v&&e[v]||e["@@iterator"])?i:null))for(e=i.call(e),c=0;!(o=e.next()).done;)l+=I(o=o.value,i=r+q(o,c++),t,n);else if("object"===o)throw t=""+e,Error(m(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t,""));return l}function U(e,r,t){return null==e?0:I(e,"",r,t)}function q(e,r){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var r={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,(function(e){return r[e]}))}(e.key):r.toString(36)}function F(e,r){e.func.call(e.context,r,e.count++)}function L(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?M(e,n,t,(function(e){return e})):null!=e&&(x(e)&&(e=function(e,r){return{$$typeof:u,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}(e,o+(!e.key||r&&r.key===e.key?"":(""+e.key).replace(P,"$&/")+"/")+t)),n.push(e))}function M(e,r,t,n,o){var u="";null!=t&&(u=(""+t).replace(P,"$&/")+"/"),U(e,L,r=O(r,u,n,o)),A(r)}var D={current:null};function V(){var e=D.current;if(null===e)throw Error(m(321));return e}var B={ReactCurrentDispatcher:D,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:$,IsSomeRendererActing:{current:!1},assign:n};r.Children={map:function(e,r,t){if(null==e)return e;var n=[];return M(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;U(e,F,r=O(null,null,r,t)),A(r)},count:function(e){return U(e,(function(){return null}),null)},toArray:function(e){var r=[];return M(e,r,null,(function(e){return e})),r},only:function(e){if(!x(e))throw Error(m(143));return e}},r.Component=S,r.Fragment=l,r.Profiler=i,r.PureComponent=g,r.StrictMode=c,r.Suspense=y,r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,r.cloneElement=function(e,r,t){if(null==e)throw Error(m(267,e));var o=n({},e.props),f=e.key,l=e.ref,c=e._owner;if(null!=r){if(void 0!==r.ref&&(l=r.ref,c=$.current),void 0!==r.key&&(f=""+r.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(a in r)C.call(r,a)&&!E.hasOwnProperty(a)&&(o[a]=void 0===r[a]&&void 0!==i?i[a]:r[a])}var a=arguments.length-2;if(1===a)o.children=t;else if(1<a){i=Array(a);for(var s=0;s<a;s++)i[s]=arguments[s+2];o.children=i}return{$$typeof:u,type:e.type,key:f,ref:l,props:o,_owner:c}},r.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:s,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},r.createElement=R,r.createFactory=function(e){var r=R.bind(null,e);return r.type=e,r},r.createRef=function(){return{current:null}},r.forwardRef=function(e){return{$$typeof:p,render:e}},r.isValidElement=x,r.lazy=function(e){return{$$typeof:h,_ctor:e,_status:-1,_result:null}},r.memo=function(e,r){return{$$typeof:d,type:e,compare:void 0===r?null:r}},r.useCallback=function(e,r){return V().useCallback(e,r)},r.useContext=function(e,r){return V().useContext(e,r)},r.useDebugValue=function(){},r.useEffect=function(e,r){return V().useEffect(e,r)},r.useImperativeHandle=function(e,r,t){return V().useImperativeHandle(e,r,t)},r.useLayoutEffect=function(e,r){return V().useLayoutEffect(e,r)},r.useMemo=function(e,r){return V().useMemo(e,r)},r.useReducer=function(e,r,t){return V().useReducer(e,r,t)},r.useRef=function(e){return V().useRef(e)},r.useState=function(e){return V().useState(e)},r.version="16.14.0"},6540:(e,r,t)=>{e.exports=t(5287)}}]);
|
package/public/893.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkbt_sensors_plugin_sk=self.webpackChunkbt_sensors_plugin_sk||[]).push([[893],{2995:(e,t,n)=>{n.r(t),n.d(t,{default:()=>v});var s=n(3490),a=n(4810),o=n(4147),r=n.n(o),l=n(7606),c=n(4952),i=n(3768),u=n(1431),g=n(9676),d=n(7041),m=n(3657),f=n(5027),p=n(7265),h=n(6890),E=n(8207);const w=e=>console.log.bind(console,e);var S;const v=e=>{const[t,n]=(0,o.useState)({}),[v,b]=(0,o.useState)({}),[y,D]=(0,o.useState)({}),[A,$]=(0,o.useState)({"ui:submitButtonOptions":{props:{disabled:!1,className:"btn btn-info"},norender:!0,submitText:"Submit"}}),[_,k]=(0,o.useState)([]),[x,C]=(0,o.useState)(),[T,M]=(0,o.useState)(new Map),[j,O]=(0,o.useState)({progress:0,maxTimeout:100,deviceCount:0,totalDevices:0}),[N,B]=(0,o.useState)("unknown"),[J,L]=(0,o.useState)();function U(e,t){console.log(`sending ${e}`),console.log(t);const n=new Headers;return n.append("Content-Type","application/json"),fetch(`/plugins/bt-sensors-plugin-sk/${e}`,{credentials:"include",method:"POST",body:JSON.stringify(t),headers:n})}async function P(e){return console.log(`fetching ${e}`),fetch(`/plugins/bt-sensors-plugin-sk/${e}`,{credentials:"include"})}async function z(){console.log("getProgress");const e=await P("progress");if(200!=e.status)throw new Error(`Unable get progres: ${e.statusText} (${e.status}) `);const t=await e.json();return console.log(t),t}function H(){console.log("refreshing sensor map"),async function(){console.log("getSensorData");const e=await P("sensors");if(200!=e.status)throw new Error(`Unable get sensor data: ${e.statusText} (${e.status}) `);const t=await e.json();return console.log(t),t}().then((e=>{M(new Map(e.map((e=>[e.info.mac,e]))))})).catch((e=>{L(e)}))}return(0,o.useEffect)((()=>{console.log("useEffect([])"),P("sendPluginState").then((async e=>{const t=await e.json();B(t.state),console.log("Setting up eventsource");const n=new EventSource("/plugins/bt-sensors-plugin-sk/sse");return n.addEventListener("newsensor",(e=>{console.log("newsensor");let t=JSON.parse(e.data);S.has(t.info.mac)||(console.log(`New sensor: ${t.info.mac}`),M(new Map(S.set(t.info.mac,t))))})),n.addEventListener("sensorchanged",(e=>{let t=JSON.parse(e.data);if(console.log("sensorchanged"),console.log(t),S.has(t.mac)){let e=S.get(t.mac);Object.assign(e.info,t),M(new Map(S))}})),n.addEventListener("progress",(e=>{console.log("progress");const t=JSON.parse(e.data);O(t),console.log(t)})),n.addEventListener("pluginstate",(e=>{console.log("pluginstate");const t=JSON.parse(e.data);B(t.state)})),()=>n.close()})).catch((e=>{L(e)}))}),[]),(0,o.useEffect)((()=>{console.log("useEffect([pluginState])"),"started"==N?(H(),async function(){console.log("getBaseData");const e=await P("base");if(200!=e.status)throw new Error(`Unable get base data: ${e.statusText} (${e.status}) `);const t=await e.json();return console.log(t),t}().then((e=>{n(e.schema),b(e.data)})).catch((e=>{L(e)})),z().then((e=>{O(e)})).catch((e=>{L(e)}))):(M(new Map),n({}),b({}))}),[N]),(0,o.useEffect)((()=>{console.log("useEffect([error])"),console.log(J)}),[J]),(0,o.useEffect)((()=>{console.log("useEffect([sensorMap])"),S=T,k(Array.from(T.entries()).map((e=>{const t=T.get(e[0]),n=t.config,s=Object.keys(n).length>0;return r().createElement(h.A,{action:!0,onClick:()=>{t&&(n.mac_address=e[0],D(t.schema),C(n))}},r().createElement("div",{class:"d-flex justify-content-between align-items-center",style:s?{fontWeight:"normal"}:{fontStyle:"italic"}},`${t._changesMade?"*":""}${t.info.name} MAC: ${t.info.mac} RSSI: ${a=t.info.RSSI,null==a?NaN:a}`,r().createElement("div",{class:"d-flex justify-content-between "},function(e){return null==e.info.lastContactDelta||e.info.lastContactDelta>e.config.discoveryTimeout?r().createElement(i.A,null):e.info.signalStrength>80?r().createElement(u.A,null):e.info.signalStrength>60?r().createElement(g.A,null):e.info.signalStrength>40?r().createElement(d.A,null):e.info.signalStrength>20?r().createElement(m.A,null):r().createElement(f.A,null)}(t))));var a})))}),[T]),"stopped"==N?r().createElement("h1",null,"Enable plugin to see configuration"):r().createElement("div",null,J?r().createElement("h2",{style:"color: red;"},J.message):"",r().createElement(s.Ay,{schema:t,validator:a.Ay,onChange:e=>b(e.formData),onSubmit:({formData:e},t)=>{var n;C(null),n=e,console.log("updateBaseData"),U("sendBaseData",n).then((e=>{200!=e.status?L(new Error(`Unable to update base data: ${e.statusText} (${e.status})`)):(z().then((e=>{O(e)})).catch((e=>{L(e)})),H())}))},onError:w("errors"),formData:v}),r().createElement("p",null),r().createElement("p",null),j.deviceCount<j.totalDevices?r().createElement(E.A,{max:j.maxTimeout,now:j.progress}):"",r().createElement("h2",null,T.size>0?"Bluetooth Devices click to configure":""),r().createElement("h2",null,T.size>0?"(* means sensor has unsaved changes)":""),r().createElement("p",null),r().createElement("div",{style:{paddingBottom:20},class:"d-flex flex-wrap justify-content-start align-items-start"},r().createElement(p.A,{style:{maxHeight:"300px",overflowY:"auto"}},_),r().createElement("div",{style:{paddingLeft:10,paddingTop:10,display:0==Object.keys(y).length?"none":""}},r().createElement(s.Ay,{schema:y,validator:a.Ay,uiSchema:A,onChange:e=>{T.get(e.formData.mac_address)._changesMade=!0,C(e.formData)},onSubmit:({formData:e},t)=>{var n;console.log(e),n=e,console.log("updateSensorData"),U("sendSensorData",n).then((e=>{if(200!=e.status)throw new Error(e.statusText);T.get(n.mac_address)._changesMade=!1,T.get(n.mac_address).config=n})),D({}),alert("Changes saved")},onError:w("errors"),formData:x},r().createElement("div",null,r().createElement(l.A,{direction:"row",style:{spacing:5}},r().createElement(c.A,{type:"submit",color:"primary",variant:"contained"},"Save"),r().createElement(c.A,{variant:"contained",onClick:()=>{var e;e=x.mac_address,console.log("undoChanges"),T.get(e)._changesMade=!1,C(T.get(e).config)}},"Undo"),r().createElement(c.A,{variant:"contained",color:"secondary",onClick:e=>{return t=x.mac_address,void(window.confirm(`Delete configuration for ${t}?`)&&function(e){console.log("removeSensorData");try{U("removeSensorData",{mac_address:e}).then((e=>{if(200!=e.status)throw new Error(e.statusText)})),S.delete(e),M(new Map(S)),D({})}catch{}}(t));var t}},"Delete")))))))}}}]);
|
package/public/main.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/******/ "use strict";
|
|
11
|
+
/******/ var __webpack_modules__ = ({});
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
/******/ // The module cache
|
|
14
|
+
/******/ var __webpack_module_cache__ = {};
|
|
15
|
+
/******/
|
|
16
|
+
/******/ // The require function
|
|
17
|
+
/******/ function __webpack_require__(moduleId) {
|
|
18
|
+
/******/ // Check if module is in cache
|
|
19
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
20
|
+
/******/ if (cachedModule !== undefined) {
|
|
21
|
+
/******/ return cachedModule.exports;
|
|
22
|
+
/******/ }
|
|
23
|
+
/******/ // Create a new module (and put it into the cache)
|
|
24
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
25
|
+
/******/ // no module.id needed
|
|
26
|
+
/******/ // no module.loaded needed
|
|
27
|
+
/******/ exports: {}
|
|
28
|
+
/******/ };
|
|
29
|
+
/******/
|
|
30
|
+
/******/ // Execute the module function
|
|
31
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
32
|
+
/******/
|
|
33
|
+
/******/ // Return the exports of the module
|
|
34
|
+
/******/ return module.exports;
|
|
35
|
+
/******/ }
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
38
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
39
|
+
/******/
|
|
40
|
+
/******/ // expose the module cache
|
|
41
|
+
/******/ __webpack_require__.c = __webpack_module_cache__;
|
|
42
|
+
/******/
|
|
43
|
+
/************************************************************************/
|
|
44
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
45
|
+
/******/ (() => {
|
|
46
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
47
|
+
/******/ })();
|
|
48
|
+
/******/
|
|
49
|
+
/******/ /* webpack/runtime/sharing */
|
|
50
|
+
/******/ (() => {
|
|
51
|
+
/******/ __webpack_require__.S = {};
|
|
52
|
+
/******/ var initPromises = {};
|
|
53
|
+
/******/ var initTokens = {};
|
|
54
|
+
/******/ __webpack_require__.I = (name, initScope) => {
|
|
55
|
+
/******/ if(!initScope) initScope = [];
|
|
56
|
+
/******/ // handling circular init calls
|
|
57
|
+
/******/ var initToken = initTokens[name];
|
|
58
|
+
/******/ if(!initToken) initToken = initTokens[name] = {};
|
|
59
|
+
/******/ if(initScope.indexOf(initToken) >= 0) return;
|
|
60
|
+
/******/ initScope.push(initToken);
|
|
61
|
+
/******/ // only runs once
|
|
62
|
+
/******/ if(initPromises[name]) return initPromises[name];
|
|
63
|
+
/******/ // creates a new share scope if needed
|
|
64
|
+
/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {};
|
|
65
|
+
/******/ // runs all init snippets from all modules reachable
|
|
66
|
+
/******/ var scope = __webpack_require__.S[name];
|
|
67
|
+
/******/ var warn = (msg) => {
|
|
68
|
+
/******/ if (typeof console !== "undefined" && console.warn) console.warn(msg);
|
|
69
|
+
/******/ };
|
|
70
|
+
/******/ var uniqueName = "bt-sensors-plugin-sk";
|
|
71
|
+
/******/ var register = (name, version, factory, eager) => {
|
|
72
|
+
/******/ var versions = scope[name] = scope[name] || {};
|
|
73
|
+
/******/ var activeVersion = versions[version];
|
|
74
|
+
/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager };
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/ var initExternal = (id) => {
|
|
77
|
+
/******/ var handleError = (err) => (warn("Initialization of sharing external failed: " + err));
|
|
78
|
+
/******/ try {
|
|
79
|
+
/******/ var module = __webpack_require__(id);
|
|
80
|
+
/******/ if(!module) return;
|
|
81
|
+
/******/ var initFn = (module) => (module && module.init && module.init(__webpack_require__.S[name], initScope))
|
|
82
|
+
/******/ if(module.then) return promises.push(module.then(initFn, handleError));
|
|
83
|
+
/******/ var initResult = initFn(module);
|
|
84
|
+
/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError));
|
|
85
|
+
/******/ } catch(err) { handleError(err); }
|
|
86
|
+
/******/ }
|
|
87
|
+
/******/ var promises = [];
|
|
88
|
+
/******/ switch(name) {
|
|
89
|
+
/******/ }
|
|
90
|
+
/******/ if(!promises.length) return initPromises[name] = 1;
|
|
91
|
+
/******/ return initPromises[name] = Promise.all(promises).then(() => (initPromises[name] = 1));
|
|
92
|
+
/******/ };
|
|
93
|
+
/******/ })();
|
|
94
|
+
/******/
|
|
95
|
+
/************************************************************************/
|
|
96
|
+
/******/
|
|
97
|
+
/******/ // module cache are used so entry inlining is disabled
|
|
98
|
+
/******/
|
|
99
|
+
/******/ })()
|
|
100
|
+
;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
var bt_sensors_plugin_sk;
|
|
10
|
+
/******/ (() => { // webpackBootstrap
|
|
11
|
+
/******/ "use strict";
|
|
12
|
+
/******/ var __webpack_modules__ = ({
|
|
13
|
+
|
|
14
|
+
/***/ "webpack/container/entry/Bluetooth Sensors for Signalk":
|
|
15
|
+
/*!***********************!*\
|
|
16
|
+
!*** container entry ***!
|
|
17
|
+
\***********************/
|
|
18
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
19
|
+
|
|
20
|
+
eval("var moduleMap = {\n\t\"./PluginConfigurationPanel\": () => {\n\t\tvar e = new Error(\"Cannot find module './src/components/PluginConfigurationPanel'\"); e.code = 'MODULE_NOT_FOUND'; throw e;\n\t}\n};\nvar get = (module, getScope) => {\n\t__webpack_require__.R = getScope;\n\tgetScope = (\n\t\t__webpack_require__.o(moduleMap, module)\n\t\t\t? moduleMap[module]()\n\t\t\t: Promise.resolve().then(() => {\n\t\t\t\tthrow new Error('Module \"' + module + '\" does not exist in container.');\n\t\t\t})\n\t);\n\t__webpack_require__.R = undefined;\n\treturn getScope;\n};\nvar init = (shareScope, initScope) => {\n\tif (!__webpack_require__.S) return;\n\tvar name = \"default\"\n\tvar oldScope = __webpack_require__.S[name];\n\tif(oldScope && oldScope !== shareScope) throw new Error(\"Container initialization failed as it has already been initialized with a different share scope\");\n\t__webpack_require__.S[name] = shareScope;\n\treturn __webpack_require__.I(name, initScope);\n};\n\n// This exports getters to disallow modifications\n__webpack_require__.d(exports, {\n\tget: () => (get),\n\tinit: () => (init)\n});\n\n//# sourceURL=webpack://bt-sensors-plugin-sk/container_entry?");
|
|
21
|
+
|
|
22
|
+
/***/ })
|
|
23
|
+
|
|
24
|
+
/******/ });
|
|
25
|
+
/************************************************************************/
|
|
26
|
+
/******/ // The module cache
|
|
27
|
+
/******/ var __webpack_module_cache__ = {};
|
|
28
|
+
/******/
|
|
29
|
+
/******/ // The require function
|
|
30
|
+
/******/ function __webpack_require__(moduleId) {
|
|
31
|
+
/******/ // Check if module is in cache
|
|
32
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
33
|
+
/******/ if (cachedModule !== undefined) {
|
|
34
|
+
/******/ return cachedModule.exports;
|
|
35
|
+
/******/ }
|
|
36
|
+
/******/ // Create a new module (and put it into the cache)
|
|
37
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
38
|
+
/******/ // no module.id needed
|
|
39
|
+
/******/ // no module.loaded needed
|
|
40
|
+
/******/ exports: {}
|
|
41
|
+
/******/ };
|
|
42
|
+
/******/
|
|
43
|
+
/******/ // Execute the module function
|
|
44
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
45
|
+
/******/
|
|
46
|
+
/******/ // Return the exports of the module
|
|
47
|
+
/******/ return module.exports;
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/
|
|
50
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
51
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
52
|
+
/******/
|
|
53
|
+
/******/ // expose the module cache
|
|
54
|
+
/******/ __webpack_require__.c = __webpack_module_cache__;
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/sharing */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ __webpack_require__.S = {};
|
|
77
|
+
/******/ var initPromises = {};
|
|
78
|
+
/******/ var initTokens = {};
|
|
79
|
+
/******/ __webpack_require__.I = (name, initScope) => {
|
|
80
|
+
/******/ if(!initScope) initScope = [];
|
|
81
|
+
/******/ // handling circular init calls
|
|
82
|
+
/******/ var initToken = initTokens[name];
|
|
83
|
+
/******/ if(!initToken) initToken = initTokens[name] = {};
|
|
84
|
+
/******/ if(initScope.indexOf(initToken) >= 0) return;
|
|
85
|
+
/******/ initScope.push(initToken);
|
|
86
|
+
/******/ // only runs once
|
|
87
|
+
/******/ if(initPromises[name]) return initPromises[name];
|
|
88
|
+
/******/ // creates a new share scope if needed
|
|
89
|
+
/******/ if(!__webpack_require__.o(__webpack_require__.S, name)) __webpack_require__.S[name] = {};
|
|
90
|
+
/******/ // runs all init snippets from all modules reachable
|
|
91
|
+
/******/ var scope = __webpack_require__.S[name];
|
|
92
|
+
/******/ var warn = (msg) => {
|
|
93
|
+
/******/ if (typeof console !== "undefined" && console.warn) console.warn(msg);
|
|
94
|
+
/******/ };
|
|
95
|
+
/******/ var uniqueName = "bt-sensors-plugin-sk";
|
|
96
|
+
/******/ var register = (name, version, factory, eager) => {
|
|
97
|
+
/******/ var versions = scope[name] = scope[name] || {};
|
|
98
|
+
/******/ var activeVersion = versions[version];
|
|
99
|
+
/******/ if(!activeVersion || (!activeVersion.loaded && (!eager != !activeVersion.eager ? eager : uniqueName > activeVersion.from))) versions[version] = { get: factory, from: uniqueName, eager: !!eager };
|
|
100
|
+
/******/ };
|
|
101
|
+
/******/ var initExternal = (id) => {
|
|
102
|
+
/******/ var handleError = (err) => (warn("Initialization of sharing external failed: " + err));
|
|
103
|
+
/******/ try {
|
|
104
|
+
/******/ var module = __webpack_require__(id);
|
|
105
|
+
/******/ if(!module) return;
|
|
106
|
+
/******/ var initFn = (module) => (module && module.init && module.init(__webpack_require__.S[name], initScope))
|
|
107
|
+
/******/ if(module.then) return promises.push(module.then(initFn, handleError));
|
|
108
|
+
/******/ var initResult = initFn(module);
|
|
109
|
+
/******/ if(initResult && initResult.then) return promises.push(initResult['catch'](handleError));
|
|
110
|
+
/******/ } catch(err) { handleError(err); }
|
|
111
|
+
/******/ }
|
|
112
|
+
/******/ var promises = [];
|
|
113
|
+
/******/ switch(name) {
|
|
114
|
+
/******/ }
|
|
115
|
+
/******/ if(!promises.length) return initPromises[name] = 1;
|
|
116
|
+
/******/ return initPromises[name] = Promise.all(promises).then(() => (initPromises[name] = 1));
|
|
117
|
+
/******/ };
|
|
118
|
+
/******/ })();
|
|
119
|
+
/******/
|
|
120
|
+
/************************************************************************/
|
|
121
|
+
/******/
|
|
122
|
+
/******/ // module cache are used so entry inlining is disabled
|
|
123
|
+
/******/ // startup
|
|
124
|
+
/******/ // Load entry module and return exports
|
|
125
|
+
/******/ var __webpack_exports__ = __webpack_require__("webpack/container/entry/Bluetooth Sensors for Signalk");
|
|
126
|
+
/******/ bt_sensors_plugin_sk = __webpack_exports__;
|
|
127
|
+
/******/
|
|
128
|
+
/******/ })()
|
|
129
|
+
;
|
|
@@ -4,12 +4,19 @@ class IBeacon extends BTSensor {
|
|
|
4
4
|
static isSystem = true;
|
|
5
5
|
|
|
6
6
|
static async identify(device) {
|
|
7
|
-
const md = await this.getDeviceProp(device,'ManufacturerData');
|
|
7
|
+
/*const md = await this.getDeviceProp(device,'ManufacturerData');
|
|
8
8
|
if (md && Object.hasOwn(md, 0x004c)) {
|
|
9
9
|
if (md[0x004c].value.slice(0,2).join() == [0x02, 0x15].join()) {
|
|
10
10
|
return this
|
|
11
11
|
}
|
|
12
|
-
}
|
|
12
|
+
}*/
|
|
13
|
+
// IBeacon protocol (see above) is incorporated into multiple BT devices
|
|
14
|
+
// The identify:: method above will misidentify any sensor (Govee for example)
|
|
15
|
+
// that the scanner finds.
|
|
16
|
+
// Sensors can still be classified as IBeacons, they'll appear as Unknown devices in
|
|
17
|
+
// the config. Users can then select IBeacon from the dropdown to
|
|
18
|
+
// instantiate the sensor as an IBeacon object.
|
|
19
|
+
|
|
13
20
|
return null
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -64,11 +64,18 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
64
64
|
this.addMetadatum( 'ttg','s','time to go',
|
|
65
65
|
(buff,offset=0)=>{return this.NaNif(buff.readUInt16LE(offset),0xFFFF)*60},
|
|
66
66
|
'65970ffe-4bda-4c1e-af4b-551c4cf74769')
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
try {
|
|
68
|
+
if (this.encryptionKey){
|
|
69
|
+
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
70
|
+
if (decData)
|
|
71
|
+
this.auxMode=decData.readInt8(8)&0x3
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
75
|
+
this.debug(e)
|
|
76
|
+
this.auxMode=VC.AuxMode.DISABLED
|
|
71
77
|
}
|
|
78
|
+
|
|
72
79
|
|
|
73
80
|
switch(this.auxMode){
|
|
74
81
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
@@ -16,11 +16,18 @@ class VictronDCEnergyMeter extends VictronSensor{
|
|
|
16
16
|
(buff)=>{return buff.readInt16LE(2)/100})
|
|
17
17
|
this.addMetadatum('alarm','', 'alarm',
|
|
18
18
|
(buff)=>{return buff.readUInt16LE(4)})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
try {
|
|
20
|
+
if (this.encryptionKey){
|
|
21
|
+
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
22
|
+
if (decData)
|
|
23
|
+
this.auxMode=decData.readInt8(8)&0x3
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
27
|
+
this.debug(e)
|
|
28
|
+
this.auxMode=VC.AuxMode.DISABLED
|
|
23
29
|
}
|
|
30
|
+
|
|
24
31
|
switch(this.auxMode){
|
|
25
32
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
26
33
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
@@ -23,8 +23,7 @@ class VictronOrionXS extends VictronSensor{
|
|
|
23
23
|
this.addMetadatum('inputCurrent','A','input current',
|
|
24
24
|
(buff)=>{return this.NaNif(buff.readUInt16LE(8),0xFFFF)/10})
|
|
25
25
|
this.addMetadatum('deviceOffReason','', 'device off reason',
|
|
26
|
-
(buff)=>{return VC.OffReasons(buff.
|
|
27
|
-
}
|
|
26
|
+
(buff)=>{return VC.OffReasons(buff.readUInt32BE(10))}) }
|
|
28
27
|
|
|
29
28
|
}
|
|
30
29
|
module.exports=VictronOrionXS
|
package/testqueue.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import {createBluetooth} from 'node-ble'
|
|
4
|
+
|
|
5
|
+
import {AutoQueue} from "./Queue.js"
|
|
6
|
+
import {Variant} from 'dbus-next'
|
|
7
|
+
|
|
8
|
+
const {bluetooth, destroy} = createBluetooth()
|
|
9
|
+
const connectQueue = new AutoQueue()
|
|
10
|
+
const adapter = await bluetooth.getAdapter("hci0")
|
|
11
|
+
await adapter.startDiscovery()
|
|
12
|
+
|
|
13
|
+
function deviceConnect(mac) {
|
|
14
|
+
|
|
15
|
+
/* CAUTION: HACK AHEAD
|
|
16
|
+
|
|
17
|
+
Bluez for some cockamamie reason (It's 2025 for chrissake.
|
|
18
|
+
BLUETOOTH ISN'T JUST FOR DESKTOPS ANYMORE, BLUEZ DEVS!)
|
|
19
|
+
SUSPENDS scanning while connected to a device.
|
|
20
|
+
|
|
21
|
+
The next line of code gives the scanner a kick in the arse,
|
|
22
|
+
starting it up again so, I dunno, another device might be able
|
|
23
|
+
to connect and sensor classes could maybe get beacon updates.
|
|
24
|
+
|
|
25
|
+
You know, the little things.
|
|
26
|
+
*/
|
|
27
|
+
adapter.waitDevice(mac,(30000)).then((device) =>{
|
|
28
|
+
|
|
29
|
+
return connectQueue.enqueue( async ()=>{
|
|
30
|
+
console.log("Connecting to "+mac)
|
|
31
|
+
try {await device.connect()} catch {(e)=>console.log(e)}
|
|
32
|
+
try {
|
|
33
|
+
console.log("Connected to "+mac)
|
|
34
|
+
console.log("Stopping discovery for "+mac)
|
|
35
|
+
|
|
36
|
+
await adapter.helper.callMethod('StopDiscovery')
|
|
37
|
+
console.log("Discovery stopped for "+mac)
|
|
38
|
+
await adapter.helper.callMethod('SetDiscoveryFilter', {
|
|
39
|
+
Transport: new Variant('s', "le")
|
|
40
|
+
})
|
|
41
|
+
console.log("Starting discovery for "+mac)
|
|
42
|
+
await adapter.helper.callMethod('StartDiscovery')
|
|
43
|
+
console.log("Discovery started for "+mac)
|
|
44
|
+
|
|
45
|
+
} catch (e){
|
|
46
|
+
//probably ignorable error. probably.
|
|
47
|
+
console.log(e)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
/* END HACK*/
|
|
52
|
+
}
|
|
53
|
+
setInterval( ()=>{
|
|
54
|
+
deviceConnect("D1:06:00:C6:16:4A")
|
|
55
|
+
}, 5000)
|
|
56
|
+
setInterval( ()=>{
|
|
57
|
+
|
|
58
|
+
for (const mac of (["D1:06:01:46:49:39","A4:C1:38:3E:7E:94"])){
|
|
59
|
+
try { deviceConnect(mac) } catch { (e)=>console.log(e) }
|
|
60
|
+
}
|
|
61
|
+
}, 10000)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|