bt-sensors-plugin-sk 1.2.0-beta.0.0.4 → 1.2.0-beta.0.0.5
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 +6 -5
- package/index.js +8 -5
- package/package.json +1 -1
- package/plugin_defaults.json +98 -10
- package/sensor_classes/ATC.js +2 -3
- 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/GoveeH50xx.js +10 -12
- package/sensor_classes/GoveeH510x.js +2 -5
- package/sensor_classes/IBeacon.js +4 -7
- package/sensor_classes/Inkbird.js +2 -2
- package/sensor_classes/JBDBMS.js +29 -19
- package/sensor_classes/KilovaultHLXPlus.js +32 -15
- package/sensor_classes/LancolVoltageMeter.js +4 -3
- package/sensor_classes/RenogyBattery.js +15 -13
- package/sensor_classes/RenogyRoverClient.js +2 -3
- package/sensor_classes/RuuviTag.js +35 -27
- package/sensor_classes/ShellySBHT003C.js +17 -17
- package/sensor_classes/SwitchBotMeterPlus.js +8 -12
- package/sensor_classes/SwitchBotTH.js +11 -16
- package/sensor_classes/VictronACCharger.js +5 -5
- package/sensor_classes/VictronBatteryMonitor.js +40 -23
- package/sensor_classes/VictronDCDCConverter.js +14 -5
- package/sensor_classes/VictronDCEnergyMeter.js +26 -7
- package/sensor_classes/VictronGXDevice.js +2 -5
- package/sensor_classes/VictronInverter.js +18 -14
- package/sensor_classes/VictronInverterRS.js +2 -2
- package/sensor_classes/VictronLynxSmartBMS.js +3 -5
- package/sensor_classes/VictronOrionXS.js +2 -2
- package/sensor_classes/VictronSmartBatteryProtect.js +4 -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 +17 -18
|
@@ -8,14 +8,16 @@ class RuuviTag extends BTSensor{
|
|
|
8
8
|
return null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
initSchema(){
|
|
12
|
+
super.initSchema()
|
|
13
13
|
const md = this.valueIfVariant(this.getManufacturerData(this.constructor.manufacturerID))
|
|
14
14
|
this.mode = md[0]
|
|
15
15
|
if (this['_initModeV'+this.mode])
|
|
16
16
|
this['_initModeV'+this.mode]()
|
|
17
17
|
else
|
|
18
18
|
throw new Error("Unrecognized Ruuvitag data mode "+md[0])
|
|
19
|
+
this.addDefaultParam("zone")
|
|
20
|
+
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -35,33 +37,39 @@ class RuuviTag extends BTSensor{
|
|
|
35
37
|
18-23 Any valid mac 48bit MAC address.
|
|
36
38
|
**/
|
|
37
39
|
_initModeV5(){
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
this.addDefaultPath("temp","environment.temperature")
|
|
41
|
+
.read=(buffer)=>{ return parseFloat((273.15+buffer.readInt16BE(1)*.005).toFixed(3))}
|
|
42
|
+
|
|
43
|
+
this.addDefaultPath("humidity","environment.humidity")
|
|
44
|
+
.read=(buffer)=>{ return parseFloat(((buffer.readUInt16BE(3)*.0025)/100).toFixed(2))}
|
|
45
|
+
|
|
46
|
+
this.addDefaultPath("pressure","environment.pressure")
|
|
47
|
+
.read=(buffer)=>{ return buffer.readUInt16BE(5)+50000}
|
|
48
|
+
|
|
47
49
|
this.addMetadatum("accX","Mg","acceleration on X-axis",
|
|
48
50
|
(buffer)=>{ return buffer.readInt16BE(7)}
|
|
49
|
-
)
|
|
51
|
+
).default="sensors.{macAndName}.accX"
|
|
52
|
+
|
|
50
53
|
this.addMetadatum("accY","Mg","acceleration on Y-axis",
|
|
51
54
|
(buffer)=>{ return buffer.readInt16BE(9)}
|
|
52
|
-
)
|
|
55
|
+
) .default="sensors.{macAndName}.accY"
|
|
56
|
+
|
|
53
57
|
this.addMetadatum("accZ","Mg","acceleration on Z-axis",
|
|
54
58
|
(buffer)=>{ return buffer.readInt16BE(11)}
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
59
|
+
) .default="sensors.{macAndName}.accZ"
|
|
60
|
+
|
|
61
|
+
this.addDefaultPath("battV","sensors.batteryVoltage")
|
|
62
|
+
.read=(buffer)=>{ return parseFloat((1.6+(buffer.readUInt16BE(13)>>5)/1000).toFixed(2))}
|
|
63
|
+
|
|
59
64
|
this.addMetadatum("mc","","movement counter",
|
|
60
65
|
(buffer)=>{ return buffer.readUInt16BE(13) && 0x1F}
|
|
61
66
|
)
|
|
67
|
+
.default="sensors.{macAndName}.movementCounter"
|
|
68
|
+
|
|
62
69
|
this.addMetadatum("msc","","measurement sequence counter",
|
|
63
70
|
(buffer)=>{ return buffer.readUInt16BE(15)}
|
|
64
71
|
)
|
|
72
|
+
.default="sensors.{macAndName}.measurementSequenceCounter"
|
|
65
73
|
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -82,18 +90,18 @@ Offset Allowed values Description
|
|
|
82
90
|
**/
|
|
83
91
|
|
|
84
92
|
_initModeV3(){
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
this.addDefaultPath("humidity","environment.humidity")
|
|
94
|
+
.read=(buffer)=>{ return (buffer.readUInt(1)*.5)/100}
|
|
95
|
+
|
|
96
|
+
this.addDefaultPath("temp", "environment.temperature")
|
|
97
|
+
.read=(buffer)=>{ return (buffer.readInt(2)+(buffer.readInt(3)/100))+273.15}
|
|
98
|
+
|
|
99
|
+
this.addDefaultPath("pressure", "environment.pressure")
|
|
100
|
+
.read=(buffer)=>{ return buffer.readUInt16BE(4)+50000}
|
|
101
|
+
|
|
94
102
|
this.addMetadatum("accX","Mg","acceleration on X-axis",
|
|
95
103
|
(buffer)=>{ return buffer.readInt16BE(6)}
|
|
96
|
-
)
|
|
104
|
+
).
|
|
97
105
|
this.addMetadatum("accY","Mg","acceleration on Y-axis",
|
|
98
106
|
(buffer)=>{ return buffer.readInt16BE(8)}
|
|
99
107
|
)
|
|
@@ -78,31 +78,31 @@ class ShellySBHT003C extends AbstractBTHomeSensor {
|
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
initSchema() {
|
|
82
|
+
super.initSchema()
|
|
83
|
+
this.addDefaultPath(
|
|
83
84
|
"battery",
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.addMetadatum(
|
|
85
|
+
"sensors.batteryStrength")
|
|
86
|
+
.read=ShellySBHT003C.parseBatteryLevel
|
|
87
|
+
|
|
88
|
+
this.addDefaultPath(
|
|
89
89
|
"temp",
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
"humidity",
|
|
96
|
-
"ratio",
|
|
90
|
+
"environment.temperature"
|
|
91
|
+
)
|
|
92
|
+
.read=ShellySBHT003C.parseTemperature
|
|
93
|
+
|
|
94
|
+
this.addDefaultPath(
|
|
97
95
|
"humidity",
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
"environment.humidity")
|
|
97
|
+
.read=ShellySBHT003C.parseHumidity,
|
|
98
|
+
|
|
100
99
|
this.addMetadatum(
|
|
101
100
|
"button",
|
|
102
101
|
"enum",
|
|
103
102
|
"button",
|
|
104
103
|
ShellySBHT003C.parseShellySBHT003CButton,
|
|
105
|
-
)
|
|
104
|
+
)
|
|
105
|
+
.default="sensors.{macAndName}.button"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -30,23 +30,19 @@ 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.addDefaultPath('temp', 'environment.temperature')
|
|
41
|
+
.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 }
|
|
42
|
+
this.addDefaultPath('humidity', 'environment.humidity')
|
|
43
|
+
.read=(buffer)=>{return (buffer[5] & 0x7F)/100}
|
|
44
|
+
this.addDefaultPath('battery', 'environment.batteryStrength')
|
|
45
|
+
.read=(buffer)=>{return buffer[2]/100}
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
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,18 @@ class SwitchBotTH extends BTSensor {
|
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
initMetadata(){
|
|
45
|
-
this.addMetadatum('temp','K', 'temperature',
|
|
46
|
-
(buffer)=>{
|
|
40
|
+
initSchema(){
|
|
41
|
+
super.initSchema()
|
|
42
|
+
this.addDefaultPath('temp', 'environment.temperature')
|
|
43
|
+
.read=(buffer)=>{
|
|
47
44
|
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
|
-
})
|
|
45
|
+
}
|
|
46
|
+
this.addDefaultPath('humidity','environment.humidity')
|
|
47
|
+
.read=(buffer)=>{return (buffer[10] & 0x7F)/100}
|
|
53
48
|
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
this.addDefaultPath("battery", "environment.batteryStrength")
|
|
50
|
+
.read=(buffer)=>{return buffer[2]/100}
|
|
51
|
+
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
getManufacturer(){
|
|
@@ -28,13 +28,13 @@ class VictronACCharger extends VictronSensor{
|
|
|
28
28
|
return await this.identifyMode(device, 0x08)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
initMetadata(){
|
|
31
|
+
|
|
32
|
+
initSchema(){
|
|
33
|
+
super.initSchema()
|
|
34
|
+
|
|
36
35
|
this.addMetadatum('state','', 'device state',
|
|
37
36
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
37
|
+
|
|
38
38
|
this.addMetadatum('chargerError','', 'charger error code',
|
|
39
39
|
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
40
40
|
|
|
@@ -34,59 +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)})
|
|
54
|
-
|
|
59
|
+
alarmMD.default='"electrical.batteries.{batteryID}.alarm'
|
|
55
60
|
alarmMD.notify=true
|
|
56
61
|
|
|
57
|
-
this.addMetadatum( 'consumed','
|
|
62
|
+
this.addMetadatum( 'consumed','Ah', 'amp-hours consumed',
|
|
58
63
|
(buff,offset=0)=>{return buff.readInt32LE(offset)/10},
|
|
59
64
|
'6597eeff-4bda-4c1e-af4b-551c4cf74769',)
|
|
65
|
+
.default="electrical.batteries.{batteryID}.capacity.ampHoursConsumed"
|
|
60
66
|
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
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'
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
|
|
76
|
+
try {
|
|
68
77
|
if (this.encryptionKey){
|
|
69
78
|
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
70
79
|
if (decData)
|
|
71
80
|
this.auxMode=decData.readInt8(8)&0x3
|
|
72
81
|
}
|
|
82
|
+
} catch(e){
|
|
83
|
+
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
84
|
+
this.debug(e)
|
|
85
|
+
this.auxMode=VC.AuxMode.DISABLED
|
|
86
|
+
}
|
|
73
87
|
|
|
74
88
|
switch(this.auxMode){
|
|
75
89
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
76
90
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
77
91
|
(buff,offset=0)=>{return buff.readInt16LE(offset)/100},
|
|
78
92
|
'6597ed7d-4bda-4c1e-af4b-551c4cf74769')
|
|
79
|
-
|
|
93
|
+
.default="electrical.batteries.secondary.voltage"
|
|
94
|
+
break;
|
|
80
95
|
case VC.AuxMode.MIDPOINT_VOLTAGE:
|
|
81
96
|
this.addMetadatum('midpointVoltage','V', 'midpoint battery voltage',
|
|
82
97
|
(buff,offset=0)=>{return buff.readUInt16LE(offset)/100},
|
|
83
98
|
'6597ed7d-4bda-4c1e-af4b-551c4cf74769')
|
|
99
|
+
.default="electrical.batteries.midpoint.voltage"
|
|
84
100
|
break;
|
|
85
101
|
|
|
86
102
|
case VC.AuxMode.TEMPERATURE:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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'
|
|
90
107
|
break;
|
|
91
108
|
default:
|
|
92
109
|
break
|
|
@@ -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,21 +10,22 @@ class VictronDCEnergyMeter extends VictronSensor{
|
|
|
10
10
|
}
|
|
11
11
|
async init(){
|
|
12
12
|
await super.init()
|
|
13
|
-
|
|
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)})
|
|
13
|
+
try {
|
|
19
14
|
if (this.encryptionKey){
|
|
20
15
|
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
21
16
|
if (decData)
|
|
22
17
|
this.auxMode=decData.readInt8(8)&0x3
|
|
23
18
|
}
|
|
19
|
+
} catch(e){
|
|
20
|
+
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
21
|
+
this.debug(e)
|
|
22
|
+
this.auxMode=VC.AuxMode.DISABLED
|
|
23
|
+
}
|
|
24
24
|
switch(this.auxMode){
|
|
25
25
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
26
26
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
27
27
|
(buff,offset=0)=>{return buff.readInt16LE(offset)/100})
|
|
28
|
+
.default="electrical.batteries.starter.voltage"
|
|
28
29
|
break;
|
|
29
30
|
|
|
30
31
|
case VC.AuxMode.TEMPERATURE:
|
|
@@ -36,11 +37,29 @@ class VictronDCEnergyMeter extends VictronSensor{
|
|
|
36
37
|
else
|
|
37
38
|
return temp / 100
|
|
38
39
|
})
|
|
40
|
+
.default="electrical.batteries.house.temperature"
|
|
41
|
+
|
|
39
42
|
break;
|
|
40
43
|
default:
|
|
41
44
|
break
|
|
42
45
|
}
|
|
43
|
-
|
|
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"
|
|
44
63
|
|
|
45
64
|
}
|
|
46
65
|
|
|
@@ -26,11 +26,8 @@ TBD
|
|
|
26
26
|
return await this.identifyMode(device, 0x07)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.initMetadata()
|
|
32
|
-
}
|
|
33
|
-
initMetadata(){
|
|
29
|
+
initSchema(){
|
|
30
|
+
super.initSchema()
|
|
34
31
|
this.addMetadatum('voltage','V', 'channel #1 voltage',
|
|
35
32
|
(buff)=>{return this.NaNif(buff.readInt16LE(0),0xFFFF)/100})
|
|
36
33
|
this.addMetadatum('pvPower','W','DC input power in watts',
|
|
@@ -7,23 +7,27 @@ class VictronInverter extends VictronSensor{
|
|
|
7
7
|
return await this.identifyMode(device, 0x03)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
initMetadata(){
|
|
10
|
+
initSchema(){
|
|
11
|
+
super.initSchema()
|
|
12
|
+
this.addDefaultParam("id")
|
|
13
|
+
|
|
15
14
|
this.addMetadatum('deviceState','', 'inverter device state',
|
|
16
15
|
(buff)=>{return VC.OperationMode.get(buff.readIntU8(0))})
|
|
16
|
+
.default="electrical.inverters.{id}.state"
|
|
17
|
+
|
|
17
18
|
const md = this.addMetadatum('alarmReason','', 'reason for alarm',
|
|
18
19
|
(buff)=>{return buff.readIntU16LE(1)})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
.default="electrical.inverters.{id}.alarm"
|
|
21
|
+
|
|
22
|
+
this.addDefaultPath('dcVoltage','electrical.inverters.dc.voltage')
|
|
23
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
24
|
+
|
|
25
|
+
this.addDefaultPath('acPower','electrical.inverters.ac.power')
|
|
26
|
+
.read=(buff)=>{return this.NaNif( buff.readUInt16LE(5), 0xFFFF )*this.powerFactor}
|
|
27
|
+
|
|
28
|
+
this.addDefaultPath('acVoltage','electrical.inverters.ac.voltage')
|
|
29
|
+
|
|
30
|
+
this.addDefaultPath('acCurrent','electrical.inverters.ac.current')
|
|
27
31
|
|
|
28
32
|
}
|
|
29
33
|
powerFactor = .8 //parameterize anon
|
|
@@ -33,7 +37,7 @@ class VictronInverter extends VictronSensor{
|
|
|
33
37
|
const br = new BitReader(decData.subarray(5))
|
|
34
38
|
this.emit('acVoltage',
|
|
35
39
|
this.NaNif(br.read_unsigned_int(15),0x7FFF)/100)
|
|
36
|
-
this.
|
|
40
|
+
this.emit('acCurrent',
|
|
37
41
|
this.NaNif(br.read_unsigned_int(11),0x7FF)/10)
|
|
38
42
|
const alarm = this.getPath("alarmReason").read(decData)
|
|
39
43
|
if (alarm>0){
|
|
@@ -10,8 +10,8 @@ class VictronInverterRS extends VictronSensor{
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
initSchema() {
|
|
14
|
+
super.initSchema()
|
|
15
15
|
|
|
16
16
|
this.addMetadatum('deviceState','', 'inverter device state',
|
|
17
17
|
(buff)=>{return VC.OperationMode.get(buff.readIntU8(0))})
|
|
@@ -22,11 +22,9 @@ class VictronLynxSmartBMS extends VictronSensor{
|
|
|
22
22
|
return await this.identifyMode(device, 0x0A)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
initMetadata(){
|
|
25
|
+
|
|
26
|
+
initSchema(){
|
|
27
|
+
super.initSchema()
|
|
30
28
|
this.addMetadatum('error','', 'error code',
|
|
31
29
|
(buff)=>{return buff.readUInt8(0)})
|
|
32
30
|
|
|
@@ -8,8 +8,8 @@ class VictronOrionXS extends VictronSensor{
|
|
|
8
8
|
static async identify(device){
|
|
9
9
|
return await this.identifyMode(device, 0x0F)
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
initSchema() {
|
|
12
|
+
super.initSchema()
|
|
13
13
|
this.addMetadatum('deviceState','', 'device state',
|
|
14
14
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
15
15
|
this.addMetadatum('chargerError','', 'charger error',
|
|
@@ -23,13 +23,11 @@ class VictronSmartBatteryProtect extends VictronSensor{
|
|
|
23
23
|
return await this.identifyMode(device, 0x09)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
initMetadata(){
|
|
26
|
+
|
|
27
|
+
initSchema(){
|
|
28
|
+
super.initSchema()
|
|
31
29
|
this.addMetadatum('deviceState','', 'device state',
|
|
32
|
-
|
|
30
|
+
(buff)=>{return VC.OperationMode.get(buff.readUInt8(1))})
|
|
33
31
|
this.addMetadatum('outputStatus','', 'output status', //TODO
|
|
34
32
|
(buff)=>{return (buff.readUInt8(2))})
|
|
35
33
|
|
|
@@ -38,31 +38,31 @@ class VictronSmartLithium extends VictronSensor{
|
|
|
38
38
|
return await this.identifyMode(device, 0x05)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
}
|
|
45
|
-
initMetadata(){
|
|
41
|
+
initSchema(){
|
|
42
|
+
super.initSchema()
|
|
43
|
+
this.addDefaultParam("batteryID")
|
|
46
44
|
|
|
47
45
|
this.addMetadatum('bmsFlags','', 'BMS Flags',
|
|
48
46
|
(buff)=>{return buff.readUInt32LE(0)})
|
|
47
|
+
.default="electrical.batteries.{batteryID}.flags"
|
|
49
48
|
|
|
50
49
|
this.addMetadatum('smartLithiumErrors','', 'Smart Lithium Errors Flags',
|
|
51
50
|
(buff)=>{return buff.readUInt16LE(4)})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.addMetadatum('balancerStatus','', 'balancer status', //TODO
|
|
51
|
+
.default="electrical.batteries.{batteryID}.errors"
|
|
52
|
+
|
|
53
|
+
for (let i=0;i++;i<8){
|
|
54
|
+
this.addMetadatum(`cell${i+1}Voltage`,'V', `cell ${i+1} voltage`)
|
|
55
|
+
.default=`electrical.batteries.{batteryID}.cell${i+1}.voltage`
|
|
56
|
+
}
|
|
57
|
+
this.addDefaultPath('batteryVoltage','electrical.batteries.voltage')
|
|
58
|
+
.read=(buff)=>{return this.NaNif((buff.readUInt16LE(13)&0xFFF),0xFFF)/100}
|
|
59
|
+
|
|
60
|
+
this.addMetadatum('balancerStatus','', 'balancer status',
|
|
63
61
|
(buff)=>{return BALANCERSTATUS[this.NaNif((buff.readUInt8(14)>>4),0xF)]})
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
.default=`electrical.batteries.{batteryID}.balancerStatus`
|
|
63
|
+
|
|
64
|
+
this.addDefaultPath('batteryTemp','electrical.batteries.temperature')
|
|
65
|
+
.read=(buff)=>{return this.NaNif((buff.readUInt8(15)&0x7F),0x7F)+233.15}
|
|
66
66
|
}
|
|
67
67
|
emitValuesFrom(buffer){
|
|
68
68
|
super.emitValuesFrom(buffer)
|