bt-sensors-plugin-sk 1.1.1 → 1.2.0-beta.0.0.10
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/BTSensor.js +304 -108
- package/Queue.js +48 -0
- package/README.md +36 -22
- package/classLoader.js +38 -0
- package/definitions.json +941 -0
- package/index.js +425 -375
- package/package.json +52 -6
- package/plugin_defaults.json +146 -0
- package/public/893.js +1 -1
- package/public/main.js +1 -100
- package/public/remoteEntry.js +1 -129
- package/sensor_classes/ATC.js +34 -22
- package/sensor_classes/Aranet/AranetSensor.js +4 -0
- package/sensor_classes/Aranet2.js +16 -15
- package/sensor_classes/Aranet4.js +23 -17
- package/sensor_classes/BlackListedDevice.js +4 -0
- package/sensor_classes/DEVELOPMENT.md +1 -6
- package/sensor_classes/GoveeH50xx.js +12 -12
- package/sensor_classes/GoveeH510x.js +7 -8
- package/sensor_classes/IBeacon.js +6 -10
- package/sensor_classes/Inkbird.js +8 -6
- package/sensor_classes/JBDBMS.js +33 -25
- package/sensor_classes/KilovaultHLXPlus.js +33 -16
- package/sensor_classes/LancolVoltageMeter.js +4 -3
- package/sensor_classes/MopekaTankSensor.js +31 -15
- package/sensor_classes/Renogy/RenogySensor.js +15 -6
- package/sensor_classes/RenogyBattery.js +15 -13
- package/sensor_classes/RenogyRoverClient.js +2 -3
- package/sensor_classes/RuuviTag.js +36 -27
- package/sensor_classes/ShellySBHT003C.js +19 -22
- package/sensor_classes/SwitchBotMeterPlus.js +10 -12
- package/sensor_classes/SwitchBotTH.js +13 -16
- package/sensor_classes/UNKNOWN.js +8 -4
- package/sensor_classes/UltrasonicWindMeter.js +13 -5
- package/sensor_classes/Victron/VictronSensor.js +6 -2
- package/sensor_classes/VictronACCharger.js +19 -8
- package/sensor_classes/VictronBatteryMonitor.js +49 -37
- package/sensor_classes/VictronDCDCConverter.js +14 -5
- package/sensor_classes/VictronDCEnergyMeter.js +27 -15
- package/sensor_classes/VictronGXDevice.js +2 -5
- package/sensor_classes/VictronInverter.js +19 -15
- package/sensor_classes/VictronInverterRS.js +19 -8
- package/sensor_classes/VictronLynxSmartBMS.js +15 -13
- package/sensor_classes/VictronOrionXS.js +16 -3
- package/sensor_classes/VictronSmartBatteryProtect.js +5 -6
- package/sensor_classes/VictronSmartLithium.js +18 -18
- package/sensor_classes/VictronSolarCharger.js +31 -18
- package/sensor_classes/VictronVEBus.js +2 -5
- package/sensor_classes/XiaomiMiBeacon.js +31 -21
- package/spec/electrical.json +688 -0
- package/spec/environment.json +401 -0
- package/spec/sensors.json +39 -0
- package/spec/tanks.json +115 -0
- package/src/components/PluginConfigurationPanel.js +393 -0
- package/src/index.js +0 -0
- package/webpack.config.js +71 -0
|
@@ -8,14 +8,17 @@ class RuuviTag extends BTSensor{
|
|
|
8
8
|
return null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
initSchema(){
|
|
12
|
+
super.initSchema()
|
|
13
|
+
this.addDefaultParam("zone")
|
|
14
|
+
|
|
13
15
|
const md = this.valueIfVariant(this.getManufacturerData(this.constructor.manufacturerID))
|
|
14
16
|
this.mode = md[0]
|
|
15
17
|
if (this['_initModeV'+this.mode])
|
|
16
18
|
this['_initModeV'+this.mode]()
|
|
17
19
|
else
|
|
18
20
|
throw new Error("Unrecognized Ruuvitag data mode "+md[0])
|
|
21
|
+
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -35,33 +38,39 @@ class RuuviTag extends BTSensor{
|
|
|
35
38
|
18-23 Any valid mac 48bit MAC address.
|
|
36
39
|
**/
|
|
37
40
|
_initModeV5(){
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
this.addDefaultPath("temp","environment.temperature")
|
|
42
|
+
.read=(buffer)=>{ return parseFloat((273.15+buffer.readInt16BE(1)*.005).toFixed(3))}
|
|
43
|
+
|
|
44
|
+
this.addDefaultPath("humidity","environment.humidity")
|
|
45
|
+
.read=(buffer)=>{ return parseFloat(((buffer.readUInt16BE(3)*.0025)/100).toFixed(2))}
|
|
46
|
+
|
|
47
|
+
this.addDefaultPath("pressure","environment.pressure")
|
|
48
|
+
.read=(buffer)=>{ return buffer.readUInt16BE(5)+50000}
|
|
49
|
+
|
|
47
50
|
this.addMetadatum("accX","Mg","acceleration on X-axis",
|
|
48
51
|
(buffer)=>{ return buffer.readInt16BE(7)}
|
|
49
|
-
)
|
|
52
|
+
).default="sensors.{macAndName}.accX"
|
|
53
|
+
|
|
50
54
|
this.addMetadatum("accY","Mg","acceleration on Y-axis",
|
|
51
55
|
(buffer)=>{ return buffer.readInt16BE(9)}
|
|
52
|
-
)
|
|
56
|
+
) .default="sensors.{macAndName}.accY"
|
|
57
|
+
|
|
53
58
|
this.addMetadatum("accZ","Mg","acceleration on Z-axis",
|
|
54
59
|
(buffer)=>{ return buffer.readInt16BE(11)}
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
60
|
+
) .default="sensors.{macAndName}.accZ"
|
|
61
|
+
|
|
62
|
+
this.addDefaultPath("battV","sensors.batteryVoltage")
|
|
63
|
+
.read=(buffer)=>{ return parseFloat((1.6+(buffer.readUInt16BE(13)>>5)/1000).toFixed(2))}
|
|
64
|
+
|
|
59
65
|
this.addMetadatum("mc","","movement counter",
|
|
60
66
|
(buffer)=>{ return buffer.readUInt16BE(13) && 0x1F}
|
|
61
67
|
)
|
|
68
|
+
.default="sensors.{macAndName}.movementCounter"
|
|
69
|
+
|
|
62
70
|
this.addMetadatum("msc","","measurement sequence counter",
|
|
63
71
|
(buffer)=>{ return buffer.readUInt16BE(15)}
|
|
64
72
|
)
|
|
73
|
+
.default="sensors.{macAndName}.measurementSequenceCounter"
|
|
65
74
|
|
|
66
75
|
}
|
|
67
76
|
|
|
@@ -82,18 +91,18 @@ Offset Allowed values Description
|
|
|
82
91
|
**/
|
|
83
92
|
|
|
84
93
|
_initModeV3(){
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
this.addDefaultPath("humidity","environment.humidity")
|
|
95
|
+
.read=(buffer)=>{ return (buffer.readUInt(1)*.5)/100}
|
|
96
|
+
|
|
97
|
+
this.addDefaultPath("temp", "environment.temperature")
|
|
98
|
+
.read=(buffer)=>{ return (buffer.readInt(2)+(buffer.readInt(3)/100))+273.15}
|
|
99
|
+
|
|
100
|
+
this.addDefaultPath("pressure", "environment.pressure")
|
|
101
|
+
.read=(buffer)=>{ return buffer.readUInt16BE(4)+50000}
|
|
102
|
+
|
|
94
103
|
this.addMetadatum("accX","Mg","acceleration on X-axis",
|
|
95
104
|
(buffer)=>{ return buffer.readInt16BE(6)}
|
|
96
|
-
)
|
|
105
|
+
).
|
|
97
106
|
this.addMetadatum("accY","Mg","acceleration on Y-axis",
|
|
98
107
|
(buffer)=>{ return buffer.readInt16BE(8)}
|
|
99
108
|
)
|
|
@@ -13,11 +13,6 @@ class ShellySBHT003C extends AbstractBTHomeSensor {
|
|
|
13
13
|
*/
|
|
14
14
|
static SHORTENED_LOCAL_NAME = "SBHT-003C";
|
|
15
15
|
|
|
16
|
-
async init() {
|
|
17
|
-
await super.init();
|
|
18
|
-
this.initMetadata();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
/**
|
|
22
17
|
* @typedef ButtonPressEvent {string}
|
|
23
18
|
*/
|
|
@@ -78,31 +73,33 @@ class ShellySBHT003C extends AbstractBTHomeSensor {
|
|
|
78
73
|
return null;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
initSchema() {
|
|
77
|
+
super.initSchema()
|
|
78
|
+
this.addDefaultParam("zone")
|
|
79
|
+
|
|
80
|
+
this.addDefaultPath(
|
|
83
81
|
"battery",
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.addMetadatum(
|
|
82
|
+
"sensors.batteryStrength")
|
|
83
|
+
.read=ShellySBHT003C.parseBatteryLevel
|
|
84
|
+
|
|
85
|
+
this.addDefaultPath(
|
|
89
86
|
"temp",
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
"humidity",
|
|
96
|
-
"ratio",
|
|
87
|
+
"environment.temperature"
|
|
88
|
+
)
|
|
89
|
+
.read=ShellySBHT003C.parseTemperature
|
|
90
|
+
|
|
91
|
+
this.addDefaultPath(
|
|
97
92
|
"humidity",
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
"environment.humidity")
|
|
94
|
+
.read=ShellySBHT003C.parseHumidity,
|
|
95
|
+
|
|
100
96
|
this.addMetadatum(
|
|
101
97
|
"button",
|
|
102
98
|
"enum",
|
|
103
99
|
"button",
|
|
104
100
|
ShellySBHT003C.parseShellySBHT003CButton,
|
|
105
|
-
)
|
|
101
|
+
)
|
|
102
|
+
.default="sensors.{macAndName}.button"
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
105
|
|
|
@@ -30,23 +30,21 @@ class SwitchBotMeterPlus extends BTSensor{
|
|
|
30
30
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async init() {
|
|
34
|
-
await super.init()
|
|
35
|
-
this.initMetadata()
|
|
36
|
-
}
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
initSchema(){
|
|
39
35
|
|
|
40
36
|
// Apply positive/negative (Byte[4] & 0x80), and convert from deg F if selected (Byte[5] & 0x80) Then convert to deg Kelvin
|
|
41
37
|
// Refer https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md#(new)-broadcast-message
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
super.initSchema()
|
|
40
|
+
this.addDefaultParam("zone")
|
|
41
|
+
|
|
42
|
+
this.addDefaultPath('temp', 'environment.temperature')
|
|
43
|
+
.read= (buffer)=>{return (( ( ( (buffer[4] & 0x7f) + ((buffer[3] & 0x0f)/10) ) * ( (buffer[4] & 0x80)>0 ? 1 : -1 ) ) - ( (buffer[5] & 0x80)>0 ? 32 : 0) ) / ( (buffer[5] & 0x80)>0 ? 1.8 : 1) ) + 273.15 }
|
|
44
|
+
this.addDefaultPath('humidity', 'environment.humidity')
|
|
45
|
+
.read=(buffer)=>{return (buffer[5] & 0x7F)/100}
|
|
46
|
+
this.addDefaultPath('battery', 'environment.batteryStrength')
|
|
47
|
+
.read=(buffer)=>{return buffer[2]/100}
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
propertiesChanged(props){
|
|
@@ -9,7 +9,7 @@ class SwitchBotTH extends BTSensor {
|
|
|
9
9
|
}
|
|
10
10
|
const c = await this.identify()
|
|
11
11
|
const sb = new c()
|
|
12
|
-
sb.
|
|
12
|
+
sb.initSchema()
|
|
13
13
|
sb.currentProperties={}
|
|
14
14
|
sb.on("temp", (t)=>console.log(t))
|
|
15
15
|
sb.on("humidity", (h)=>console.log(h))
|
|
@@ -37,23 +37,20 @@ class SwitchBotTH extends BTSensor {
|
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(buffer)=>{
|
|
40
|
+
initSchema(){
|
|
41
|
+
super.initSchema()
|
|
42
|
+
this.addDefaultParam("zone")
|
|
43
|
+
|
|
44
|
+
this.addDefaultPath('temp', 'environment.temperature')
|
|
45
|
+
.read=(buffer)=>{
|
|
47
46
|
return (27315+(((buffer[8] & 0x0F)/10 + (buffer[9] & 0x7F)) * (((buffer[9] & 0x80)>0)?100:-100)))/100
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
(buffer)=>{return (buffer[10] & 0x7F)/100
|
|
52
|
-
})
|
|
47
|
+
}
|
|
48
|
+
this.addDefaultPath('humidity','environment.humidity')
|
|
49
|
+
.read=(buffer)=>{return (buffer[10] & 0x7F)/100}
|
|
53
50
|
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
this.addDefaultPath("battery", "environment.batteryStrength")
|
|
52
|
+
.read=(buffer)=>{return buffer[2]/100}
|
|
53
|
+
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
getManufacturer(){
|
|
@@ -9,10 +9,14 @@ class UNKNOWN extends BTSensor{
|
|
|
9
9
|
await super.init()
|
|
10
10
|
if (!this.currentProperties.Name)
|
|
11
11
|
this.currentProperties.Name= `Unknown device from ${this.getManufacturer()}`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
this.addParameter(
|
|
13
|
+
"sensorClass",
|
|
14
|
+
{
|
|
15
|
+
title: "Sensor Class",
|
|
16
|
+
enum:Array.from(this.constructor.classMap.keys())
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
this.listen()
|
|
16
20
|
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -12,6 +12,9 @@ class UltrasonicWindMeter extends BTSensor{
|
|
|
12
12
|
hasGATT(){
|
|
13
13
|
return true
|
|
14
14
|
}
|
|
15
|
+
usingGATT(){
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
15
18
|
emitGATT(){
|
|
16
19
|
this.battCharacteristic.readValue()
|
|
17
20
|
.then((buffer)=>
|
|
@@ -27,20 +30,25 @@ class UltrasonicWindMeter extends BTSensor{
|
|
|
27
30
|
)
|
|
28
31
|
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
33
|
+
initSchema(){
|
|
34
|
+
super.initSchema()
|
|
35
|
+
this.getGATTParams()["useGATT"].default=true
|
|
36
|
+
this.addDefaultPath("batt",'sensors.batteryStrength')
|
|
37
|
+
.read=(buffer)=>{return (buffer.readUInt8())/100}
|
|
38
|
+
|
|
34
39
|
this.addMetadatum("awa","rad","Apparent Wind Angle",
|
|
35
40
|
(buffer)=>{return ((buffer.readInt16LE())/100)*(Math.PI/180)}
|
|
36
41
|
)
|
|
42
|
+
.default='environment.wind.angleApparent'
|
|
43
|
+
|
|
37
44
|
this.addMetadatum("aws","m/s","Apparent Wind Speed",
|
|
38
45
|
(buffer)=>{return (buffer.readInt16LE()/100)*.514444} //convert knots to m/s
|
|
39
46
|
)
|
|
47
|
+
.default='environment.wind.speedApparent'
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
initGATTConnection(){
|
|
43
|
-
return new Promise((resolve,reject )=>{ this.
|
|
51
|
+
return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
|
|
44
52
|
if (!this.gattServer) {
|
|
45
53
|
this.gattServer = await this.device.gatt()
|
|
46
54
|
this.battService = await this.gattServer.getPrimaryService("0000180f-0000-1000-8000-00805f9b34fb")
|
|
@@ -51,8 +51,12 @@ function sleep(x) {
|
|
|
51
51
|
|
|
52
52
|
async init(){
|
|
53
53
|
await super.init()
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
this.addParameter(
|
|
55
|
+
"encryptionKey",
|
|
56
|
+
{
|
|
57
|
+
title:"Encryption Key"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
56
60
|
this.model_id=this.getManufacturerData(0x2e1)?.readUInt16LE(2)??"Unknown"
|
|
57
61
|
}
|
|
58
62
|
alarmReason(alarmValue){
|
|
@@ -28,31 +28,42 @@ class VictronACCharger extends VictronSensor{
|
|
|
28
28
|
return await this.identifyMode(device, 0x08)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
|
|
32
|
+
initSchema(){
|
|
33
|
+
super.initSchema()
|
|
34
|
+
this.addDefaultParam("id")
|
|
35
|
+
|
|
36
36
|
this.addMetadatum('state','', 'device state',
|
|
37
37
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
38
|
+
.default= "electrical.chargers.{id}.state"
|
|
38
39
|
this.addMetadatum('chargerError','', 'charger error code',
|
|
39
40
|
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
40
|
-
|
|
41
|
+
.default= "electrical.chargers.{id}.error"
|
|
42
|
+
|
|
41
43
|
this.addMetadatum('batt1','V', 'battery 1 voltage')
|
|
44
|
+
.default= "electrical.chargers.{id}.battery1.voltage"
|
|
42
45
|
|
|
43
46
|
this.addMetadatum('curr1','A', 'battery 1 current')
|
|
47
|
+
.default= "electrical.chargers.{id}.battery1.current"
|
|
44
48
|
|
|
45
49
|
this.addMetadatum('batt2','V', 'battery 2 voltage')
|
|
50
|
+
.default= "electrical.chargers.{id}.battery2.voltage"
|
|
46
51
|
|
|
47
52
|
this.addMetadatum('curr2','A', 'battery 2 current')
|
|
53
|
+
.default= "electrical.chargers.{id}.battery2.current"
|
|
48
54
|
|
|
49
55
|
this.addMetadatum('batt3','V', 'battery 3 voltage')
|
|
56
|
+
.default= "electrical.chargers.{id}.battery3.voltage"
|
|
50
57
|
|
|
51
58
|
this.addMetadatum('curr3','A', 'battery 3 current')
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
.default= "electrical.chargers.{id}.battery3.current"
|
|
60
|
+
|
|
61
|
+
this.addMetadatum('temp', 'K', 'charger temperature')
|
|
62
|
+
.default= "electrical.chargers.{id}.temperature"
|
|
54
63
|
|
|
55
64
|
this.addMetadatum('acCurr','A', 'AC current')
|
|
65
|
+
.default= "electrical.chargers.{id}.ac.current"
|
|
66
|
+
|
|
56
67
|
}
|
|
57
68
|
emitValuesFrom(buffer){
|
|
58
69
|
super.emitValuesFrom(buffer)
|
|
@@ -23,7 +23,7 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
23
23
|
d.currentProperties.ManufacturerData={}
|
|
24
24
|
d.currentProperties.ManufacturerData[0x02e1]=b
|
|
25
25
|
d.initMetadata()
|
|
26
|
-
d.
|
|
26
|
+
Object.keys(d.getPaths()).forEach((tag)=>{
|
|
27
27
|
d.on(tag,(v)=>console.log(`${tag}=${v}`))
|
|
28
28
|
})
|
|
29
29
|
b = d.decrypt(b)
|
|
@@ -34,65 +34,76 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
characteristics=[]
|
|
37
|
-
async init(){
|
|
38
|
-
await super.init()
|
|
39
|
-
this.initMetadata()
|
|
40
|
-
}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
|
|
39
|
+
initSchema(){
|
|
40
|
+
super.initSchema()
|
|
41
|
+
this.addDefaultParam("batteryID").default="house"
|
|
42
|
+
//"default": "electrical.batteries.{batteryID}.voltage"
|
|
43
|
+
|
|
44
|
+
this.addDefaultPath('current','electrical.batteries.current')
|
|
45
|
+
.read=(buff,offset=0)=>{return buff.readInt32LE(offset)/1000}
|
|
46
|
+
this.getPath("current").gatt='6597ed8c-4bda-4c1e-af4b-551c4cf74769'
|
|
47
|
+
|
|
46
48
|
this.addMetadatum('power','W', 'house battery wattage',
|
|
47
49
|
(buff,offset=0)=>{return buff.readInt16LE(offset)},
|
|
48
50
|
'6597ed8e-4bda-4c1e-af4b-551c4cf74769')
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
.default="electrical.batteries.{batteryID}.power"
|
|
52
|
+
|
|
53
|
+
this.addDefaultPath('voltage', "electrical.batteries.voltage")
|
|
54
|
+
.read=(buff,offset=0)=>{return this.NaNif(buff.readInt16LE(offset), 0x7FFF)/100}
|
|
55
|
+
this.getPath("voltage").gatt='6597ed8d-4bda-4c1e-af4b-551c4cf74769'
|
|
56
|
+
|
|
52
57
|
const alarmMD = this.addMetadatum('alarm','', 'alarm',
|
|
53
58
|
(buff,offset=0)=>{return buff.readInt16LE(offset)})
|
|
59
|
+
alarmMD.default='"electrical.batteries.{batteryID}.alarm'
|
|
54
60
|
alarmMD.notify=true
|
|
55
61
|
|
|
56
|
-
this.addMetadatum( 'consumed','
|
|
62
|
+
this.addMetadatum( 'consumed','Ah', 'amp-hours consumed',
|
|
57
63
|
(buff,offset=0)=>{return buff.readInt32LE(offset)/10},
|
|
58
64
|
'6597eeff-4bda-4c1e-af4b-551c4cf74769',)
|
|
65
|
+
.default="electrical.batteries.{batteryID}.capacity.ampHoursConsumed"
|
|
59
66
|
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
this.addDefaultPath( 'soc',"electrical.batteries.capacity.stateOfCharge")
|
|
68
|
+
.read=(buff,offset=0)=>{return buff.readUInt16LE(offset)/10000}
|
|
69
|
+
this.getPath("soc").gatt='65970fff-4bda-4c1e-af4b-551c4cf74769'
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
|
|
72
|
+
this.addDefaultPath( 'ttg',"electrical.batteries.capacity.timeRemaining")
|
|
73
|
+
.read=(buff,offset=0)=>{return this.NaNif(buff.readUInt16LE(offset),0xFFFF)*60}
|
|
74
|
+
this.getPath("ttg").gatt='65970ffe-4bda-4c1e-af4b-551c4cf74769'
|
|
75
|
+
|
|
67
76
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} catch
|
|
77
|
+
if (this.encryptionKey){
|
|
78
|
+
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
79
|
+
if (decData)
|
|
80
|
+
this.auxMode=decData.readInt8(8)&0x3
|
|
81
|
+
}
|
|
82
|
+
} catch(e){
|
|
74
83
|
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
75
84
|
this.debug(e)
|
|
76
85
|
this.auxMode=VC.AuxMode.DISABLED
|
|
77
|
-
}
|
|
78
|
-
|
|
86
|
+
}
|
|
79
87
|
|
|
80
88
|
switch(this.auxMode){
|
|
81
89
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
82
90
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
83
91
|
(buff,offset=0)=>{return buff.readInt16LE(offset)/100},
|
|
84
92
|
'6597ed7d-4bda-4c1e-af4b-551c4cf74769')
|
|
85
|
-
|
|
93
|
+
.default="electrical.batteries.secondary.voltage"
|
|
94
|
+
break;
|
|
86
95
|
case VC.AuxMode.MIDPOINT_VOLTAGE:
|
|
87
96
|
this.addMetadatum('midpointVoltage','V', 'midpoint battery voltage',
|
|
88
97
|
(buff,offset=0)=>{return buff.readUInt16LE(offset)/100},
|
|
89
98
|
'6597ed7d-4bda-4c1e-af4b-551c4cf74769')
|
|
99
|
+
.default="electrical.batteries.midpoint.voltage"
|
|
90
100
|
break;
|
|
91
101
|
|
|
92
102
|
case VC.AuxMode.TEMPERATURE:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
|
|
104
|
+
this.addDefaultPath('temperature','electrical.batteries.temperature')
|
|
105
|
+
.read=(buff,offset=0)=>{return (buff.readUInt16LE(offset)/100)}
|
|
106
|
+
this.getPath('temperature').gatt='6597ed7d-4bda-4c1e-af4b-551c4cf74769'
|
|
96
107
|
break;
|
|
97
108
|
default:
|
|
98
109
|
break
|
|
@@ -102,7 +113,7 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
102
113
|
emitValuesFrom(decData){
|
|
103
114
|
this.emitData("ttg",decData,0)
|
|
104
115
|
this.emitData("voltage",decData,2);
|
|
105
|
-
const alarm = this.
|
|
116
|
+
const alarm = this.getPath("alarm").read(decData,4)
|
|
106
117
|
if (alarm>0){
|
|
107
118
|
this.emit(
|
|
108
119
|
`ALARM #${alarm} from ${this.getDisplayName()})`,
|
|
@@ -131,7 +142,7 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
131
142
|
return new Promise((resolve,reject )=>{
|
|
132
143
|
if (!this.valueIfVariant(this.currentProperties.Paired))
|
|
133
144
|
reject(`${this.getName()} must be paired with the Signalk server to use GATT protocol`)
|
|
134
|
-
this.
|
|
145
|
+
this.deviceConnect().then(async ()=>{
|
|
135
146
|
this.debug(`${this.getName()} connected.`)
|
|
136
147
|
if (!this.gattServer) {
|
|
137
148
|
this.gattServer = await this.device.gatt()
|
|
@@ -144,7 +155,8 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
144
155
|
})
|
|
145
156
|
}
|
|
146
157
|
emitGATT(){
|
|
147
|
-
this.
|
|
158
|
+
Object.keys(this.getPaths()).forEach( (tag)=> {
|
|
159
|
+
const datum = this.getPaths()[tag]
|
|
148
160
|
if (datum.gatt) {
|
|
149
161
|
this.gattService.getCharacteristic(datum.gatt).then((gattCharacteristic)=>{
|
|
150
162
|
gattCharacteristic.readValue().then((buffer)=>{
|
|
@@ -157,10 +169,10 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
157
169
|
}
|
|
158
170
|
initGATTNotifications(){
|
|
159
171
|
return new Promise((resolve,reject )=>{
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
Object.keys(this.getPaths()).forEach( (tag)=> {
|
|
173
|
+
const datum = this.getPaths()[tag]
|
|
162
174
|
if (datum.gatt) {
|
|
163
|
-
|
|
175
|
+
this.gattService.getCharacteristic(datum.gatt).then(async (gattCharacteristic)=>{
|
|
164
176
|
const buffer = await gattCharacteristic.readValue()
|
|
165
177
|
this.emitData(tag, buffer)
|
|
166
178
|
|
|
@@ -7,21 +7,30 @@ class VictronDCDCConverter extends VictronSensor{
|
|
|
7
7
|
return await this.identifyMode(device,0x04)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
|
|
11
|
+
initSchema(){
|
|
12
|
+
super.initSchema()
|
|
13
|
+
this.addDefaultPath("id")
|
|
14
|
+
|
|
15
15
|
this.addMetadatum('deviceState','', 'device state',
|
|
16
16
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
17
|
+
.default="electrical.chargers.{id}.state"
|
|
17
18
|
this.addMetadatum('chargerError','', 'charger error',
|
|
18
19
|
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
20
|
+
.default="electrical.chargers.{id}.error"
|
|
21
|
+
|
|
19
22
|
this.addMetadatum('inputVoltage','V', 'input voltage',
|
|
20
23
|
(buff)=>{return this.NaNif(buff.readUInt16LE(2),0xFFFF)/100})
|
|
24
|
+
.default="electrical.chargers.{id}.input.voltage"
|
|
25
|
+
|
|
21
26
|
this.addMetadatum('outputVoltage','V', 'output voltage',
|
|
22
27
|
(buff)=>{return this.NaNif(buff.readInt16LE(4),0x7FFF)/100 })
|
|
28
|
+
.default="electrical.chargers.{id}.output.voltage"
|
|
29
|
+
|
|
23
30
|
this.addMetadatum('offReason','', 'reason unit is off',
|
|
24
31
|
(buff)=>{return VC.OffReasons.get(buff.readUInt32LE(6))})
|
|
32
|
+
.default="electrical.chargers.{id}.offReason"
|
|
33
|
+
|
|
25
34
|
|
|
26
35
|
}
|
|
27
36
|
|
|
@@ -10,28 +10,22 @@ class VictronDCEnergyMeter extends VictronSensor{
|
|
|
10
10
|
}
|
|
11
11
|
async init(){
|
|
12
12
|
await super.init()
|
|
13
|
-
this.addMetadatum('meterType','', 'meter type',
|
|
14
|
-
(buff)=>{return VC.MeterType.get( buff.readInt16LE(0))})
|
|
15
|
-
this.addMetadatum('voltage','','voltage',
|
|
16
|
-
(buff)=>{return buff.readInt16LE(2)/100})
|
|
17
|
-
this.addMetadatum('alarm','', 'alarm',
|
|
18
|
-
(buff)=>{return buff.readUInt16LE(4)})
|
|
19
13
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} catch
|
|
14
|
+
if (this.encryptionKey){
|
|
15
|
+
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
16
|
+
if (decData)
|
|
17
|
+
this.auxMode=decData.readInt8(8)&0x3
|
|
18
|
+
}
|
|
19
|
+
} catch(e){
|
|
26
20
|
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
27
21
|
this.debug(e)
|
|
28
22
|
this.auxMode=VC.AuxMode.DISABLED
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
switch(this.auxMode){
|
|
32
25
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
33
26
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
34
27
|
(buff,offset=0)=>{return buff.readInt16LE(offset)/100})
|
|
28
|
+
.default="electrical.batteries.starter.voltage"
|
|
35
29
|
break;
|
|
36
30
|
|
|
37
31
|
case VC.AuxMode.TEMPERATURE:
|
|
@@ -43,18 +37,36 @@ class VictronDCEnergyMeter extends VictronSensor{
|
|
|
43
37
|
else
|
|
44
38
|
return temp / 100
|
|
45
39
|
})
|
|
40
|
+
.default="electrical.batteries.house.temperature"
|
|
41
|
+
|
|
46
42
|
break;
|
|
47
43
|
default:
|
|
48
44
|
break
|
|
49
45
|
}
|
|
50
|
-
|
|
46
|
+
}
|
|
47
|
+
initSchema(){
|
|
48
|
+
super.initSchema()
|
|
49
|
+
this.addDefaultParam("id")
|
|
50
|
+
this.addMetadatum('meterType','', 'meter type',
|
|
51
|
+
(buff)=>{return VC.MeterType.get( buff.readInt16LE(0))})
|
|
52
|
+
.default="electrical.meters.{id}.type"
|
|
53
|
+
|
|
54
|
+
this.addMetadatum('voltage','V','voltage',
|
|
55
|
+
(buff)=>{return buff.readInt16LE(2)/100})
|
|
56
|
+
.default="electrical.meters.{id}.voltage"
|
|
57
|
+
|
|
58
|
+
this.addMetadatum('alarm','', 'alarm',
|
|
59
|
+
(buff)=>{return buff.readUInt16LE(4)})
|
|
60
|
+
.default="electrical.meters.{id}.alarm"
|
|
61
|
+
this.addMetadatum('current','A', 'current')
|
|
62
|
+
.default="electrical.meters.{id}.current"
|
|
51
63
|
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
emitValuesFrom(decData){
|
|
55
67
|
this.emitData("meterType",decData,0)
|
|
56
68
|
this.emitData("voltage",decData,2);
|
|
57
|
-
const alarm = this.
|
|
69
|
+
const alarm = this.getPath("alarm").read(decData,4)
|
|
58
70
|
if (alarm>0){
|
|
59
71
|
this.emit(
|
|
60
72
|
`ALARM #${alarm} from ${this.getDisplayName()})`,
|