bt-sensors-plugin-sk 1.2.0-beta.0.0.1.test → 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/.vscode/launch.json +7 -0
- package/BTSensor.js +57 -11
- package/Queue.js +48 -0
- package/README.md +34 -12
- package/classLoader.js +38 -0
- package/index.js +71 -105
- package/package.json +2 -1
- package/plugin_defaults.json +99 -10
- package/public/893.js +1 -1
- package/sensor_classes/ATC.js +5 -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 +12 -12
- package/sensor_classes/GoveeH510x.js +4 -5
- package/sensor_classes/IBeacon.js +13 -9
- package/sensor_classes/Inkbird.js +4 -2
- 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 +19 -10
- package/sensor_classes/Renogy/RenogySensor.js +1 -1
- 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/UltrasonicWindMeter.js +13 -5
- package/sensor_classes/VictronACCharger.js +19 -8
- package/sensor_classes/VictronBatteryMonitor.js +41 -24
- 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 +18 -7
- package/sensor_classes/VictronLynxSmartBMS.js +15 -13
- package/sensor_classes/VictronOrionXS.js +15 -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 +20 -19
- package/src/components/PluginConfigurationPanel.js +52 -27
- package/testqueue.js +64 -0
|
@@ -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(){
|
|
@@ -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")
|
|
@@ -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)
|
|
@@ -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
|
|
@@ -125,7 +142,7 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
125
142
|
return new Promise((resolve,reject )=>{
|
|
126
143
|
if (!this.valueIfVariant(this.currentProperties.Paired))
|
|
127
144
|
reject(`${this.getName()} must be paired with the Signalk server to use GATT protocol`)
|
|
128
|
-
this.
|
|
145
|
+
this.deviceConnect().then(async ()=>{
|
|
129
146
|
this.debug(`${this.getName()} connected.`)
|
|
130
147
|
if (!this.gattServer) {
|
|
131
148
|
this.gattServer = await this.device.gatt()
|
|
@@ -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,23 +10,34 @@ class VictronInverterRS extends VictronSensor{
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
initSchema() {
|
|
14
|
+
super.initSchema()
|
|
15
|
+
this.addDefaultParam("id")
|
|
16
16
|
this.addMetadatum('deviceState','', 'inverter device state',
|
|
17
|
-
|
|
17
|
+
(buff)=>{return VC.OperationMode.get(buff.readIntU8(0))})
|
|
18
|
+
.default='electrical.inverters.{id}.state'
|
|
19
|
+
|
|
18
20
|
const md = this.addMetadatum('chargerError','', 'charger error',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
(buff)=>{return VC.ChargerError(buff.readIntU8(1))})
|
|
22
|
+
md.default='electrical.inverters.{id}.error'
|
|
23
|
+
md.notify=true
|
|
21
24
|
|
|
22
25
|
this.addMetadatum('batteryVoltage','V', 'battery voltage',
|
|
23
26
|
(buff)=>{return this.NaNif(buff.readInt16LE(2),0x7FFF)/100})
|
|
27
|
+
.default='electrical.inverters.{id}.battery.voltage'
|
|
28
|
+
.
|
|
24
29
|
this.addMetadatum('pvPower','W', 'PV power',
|
|
25
30
|
(buff)=>{return this.NaNif(buff.readUInt16LE(4), 0xffff)})
|
|
31
|
+
.default='electrical.inverters.{id}.power'
|
|
32
|
+
|
|
26
33
|
this.addMetadatum('yieldToday','W', 'yield yoday in watts',
|
|
27
34
|
(buff)=>{return this.NaNif(buff.readUInt16LE(6), 0xffff)*10})
|
|
35
|
+
.default='electrical.inverters.{id}.yieldToday'
|
|
36
|
+
|
|
28
37
|
this.addMetadatum('acOutPower','W', 'AC out power in watts',
|
|
29
|
-
(buff)=>{this.NaNif(buff.readInt16LE(8), 0x7fff)})
|
|
38
|
+
(buff)=>{this.NaNif(buff.readInt16LE(8), 0x7fff)})
|
|
39
|
+
.default='electrical.inverters.{id}.ac.power'
|
|
40
|
+
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
emitValuesFrom(decData){
|
|
@@ -22,26 +22,28 @@ class VictronLynxSmartBMS extends VictronSensor{
|
|
|
22
22
|
return await this.identifyMode(device, 0x0A)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.initMetadata()
|
|
28
|
-
}
|
|
29
|
-
initMetadata(){
|
|
25
|
+
initSchema(){
|
|
26
|
+
super.initSchema()
|
|
30
27
|
this.addMetadatum('error','', 'error code',
|
|
31
28
|
(buff)=>{return buff.readUInt8(0)})
|
|
32
29
|
|
|
33
|
-
this.
|
|
34
|
-
(buff)=>{return this.NaNif(buff.readUInt16LE(1),0xFFFF)*60}
|
|
35
|
-
this.
|
|
36
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
37
|
-
this.
|
|
38
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(5),0x7FFF)/10}
|
|
30
|
+
this.addDefaultPath('ttg','electrical.batteries.capacity.timeRemaining')
|
|
31
|
+
.read=(buff)=>{return this.NaNif(buff.readUInt16LE(1),0xFFFF)*60}
|
|
32
|
+
this.addDefaultPath('voltage','electrical.batteries.voltage')
|
|
33
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
34
|
+
this.addDefaultPath('current','electrical.batteries.current')
|
|
35
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(5),0x7FFF)/10}
|
|
36
|
+
|
|
39
37
|
this.addMetadatum('ioStatus','','IO Status', //TODO
|
|
40
38
|
(buff)=>{return buff.readUInt16LE(7)})
|
|
39
|
+
|
|
41
40
|
this.addMetadatum('warningsAndAlarms','','warnings and alarms')
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
this.addDefaultPath('soc','electrical.batteries.capacity.stateOfCharge')
|
|
43
43
|
this.addMetadatum('consumedAh','Ah','amp-hours consumed')
|
|
44
|
-
|
|
44
|
+
.default="electrical.batteries.{batteryID}.capacity.ampHoursConsumed"
|
|
45
|
+
|
|
46
|
+
this.addDefaultPath('temp', 'electrical.batteries.temperature')
|
|
45
47
|
}
|
|
46
48
|
emitValuesFrom(buffer){
|
|
47
49
|
super.emitValuesFrom(buffer)
|
|
@@ -8,22 +8,34 @@ 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
|
+
this.addDefaultParam("id")
|
|
13
14
|
this.addMetadatum('deviceState','', 'device state',
|
|
14
15
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
16
|
+
.default="electrical.chargers.{id}.state"
|
|
17
|
+
|
|
15
18
|
this.addMetadatum('chargerError','', 'charger error',
|
|
16
19
|
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
20
|
+
.default="electrical.chargers.{id}.error"
|
|
21
|
+
|
|
17
22
|
this.addMetadatum('outputVoltage','V', 'output voltage',
|
|
18
23
|
(buff)=>{return this.NaNif(buff.readInt16LE(2),0x7FF)/100})
|
|
24
|
+
.default="electrical.chargers.{id}.output.voltage"
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
this.addMetadatum('current','A','output current',
|
|
20
28
|
(buff)=>{return this.NaNif(buff.readUInt16LE(4),0xFFFF)/10})
|
|
29
|
+
.default="electrical.chargers.{id}.output.current"
|
|
21
30
|
this.addMetadatum('inputVoltage','V', 'input voltage',
|
|
22
31
|
(buff)=>{return this.NaNif(buff.readInt16LE(6),0x07FF)/100})
|
|
32
|
+
.default="electrical.chargers.{id}.input.voltage"
|
|
23
33
|
this.addMetadatum('inputCurrent','A','input current',
|
|
24
34
|
(buff)=>{return this.NaNif(buff.readUInt16LE(8),0xFFFF)/10})
|
|
35
|
+
.default="electrical.chargers.{id}.input.current"
|
|
25
36
|
this.addMetadatum('deviceOffReason','', 'device off reason',
|
|
26
|
-
(buff)=>{return VC.OffReasons(buff.
|
|
37
|
+
(buff)=>{return VC.OffReasons(buff.readUInt32BE(10))})
|
|
38
|
+
.default="electrical.chargers.{id}.offReason"
|
|
27
39
|
}
|
|
28
40
|
|
|
29
41
|
}
|
|
@@ -23,13 +23,12 @@ 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()
|
|
29
|
+
this.addDefaultParam("id")
|
|
31
30
|
this.addMetadatum('deviceState','', 'device state',
|
|
32
|
-
|
|
31
|
+
(buff)=>{return VC.OperationMode.get(buff.readUInt8(1))})
|
|
33
32
|
this.addMetadatum('outputStatus','', 'output status', //TODO
|
|
34
33
|
(buff)=>{return (buff.readUInt8(2))})
|
|
35
34
|
|
|
@@ -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)
|