bt-sensors-plugin-sk 1.3.0 → 1.3.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/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## WHAT'S NEW
4
4
 
5
+
6
+ # Version 1.3.1
7
+
8
+ - JBD Protection status
9
+ - SensorPush devices (untested)
10
+
5
11
  # Version 1.3.0
6
12
 
7
13
  - JikongBMS support (aka JKBMS)
@@ -112,7 +118,7 @@ It's pretty easy to write and deploy your own sensor class for any currently uns
112
118
  |[Jikong](https://jikongbms.com/)| https://jikongbms.com/product/ |
113
119
  |[Junctek](https://www.junteks.com)|[Junctek BMS](https://www.junteks.com/pages/product/index) |
114
120
  |[Remoran](https://remoran.eu)| [Remoran Wave.3](https://remoran.eu/wave.html)|
115
- |[AC DC Systems](https://marinedcac.com) | [Bank Manager] hybrid (Pb and Li) charger(https://marinedcac.com/pages/bankmanager)|
121
+ |[AC DC Systems](https://marinedcac.com) | [Bank Manager](https://marinedcac.com/pages/bankmanager) hybrid (Pb and Li) charger|
116
122
  |[Ective](https://ective.de/)| Also Topband(?), Skanbatt and others |
117
123
 
118
124
  ### Environmental
@@ -128,6 +134,7 @@ It's pretty easy to write and deploy your own sensor class for any currently uns
128
134
  |[Govee](http://www.govee.com)| Govee H50xx and H510x Temperature and humidity sensors |
129
135
  |[BTHome](https://bthome.io/)| NOTE: Framework for IOT sensor devices. |
130
136
  |[Inkbird](https://inkbird.com/)| TH-2 Temp and Humidity Sensor |
137
+ |[SensorPush](https://www.sensorpush.com/)| Temperature, Humidity and Atmospheric Pressure sensor|
131
138
 
132
139
 
133
140
  ### Tanks
package/index.js CHANGED
@@ -550,6 +550,7 @@ module.exports = function (app) {
550
550
  c.debug=app.debug
551
551
 
552
552
  const sensor = new c(device, config?.params, config?.gattParams)
553
+
553
554
  sensor._paths=config.paths //this might be a good candidate for refactoring
554
555
  sensor._app=app
555
556
  sensor._adapter=adapter //HACK!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Bluetooth Sensors for Signalk - see https://www.npmjs.com/package/bt-sensors-plugin-sk#supported-sensors for a list of supported sensors",
5
5
  "main": "index.js",
6
6
  "dependencies": {
Binary file
@@ -62,7 +62,24 @@ class JBDBMS extends BTSensor {
62
62
  .read=(buffer)=>{return buffer.readUInt16BE(12)}
63
63
 
64
64
  this.addMetadatum('protectionStatus', '', 'Protection Status',
65
- (buffer)=>{return buffer.readUInt16BE(20)} )
65
+ (buffer)=>{
66
+ const bits = buffer.readUInt16BE(20).toString(2)
67
+ return {
68
+ singleCellOvervolt: bits[0]=='1',
69
+ singleCellUndervolt: bits[1]=='1',
70
+ packOvervolt: (bits[2]=='1'),
71
+ packUndervolt: bits[3]=='1',
72
+ chargeOvertemp:bits[4]=='1',
73
+ chargeUndertemp:bits[5]=='1',
74
+ dischargeOvertemp:bits[6]=='1',
75
+ dischargeUndertemp:bits[7]=='1',
76
+ chargeOvercurrent:bits[8]=='1',
77
+ dischargeOvercurrent:bits[9]=='1',
78
+ shortCircut:bits[10]=='1',
79
+ frontEndDetectionICError:bits[11]=='1',
80
+ softwareLockMOS:bits[12]=='1',
81
+ }
82
+ })
66
83
  .default="electrical.batteries.{batteryID}.protectionStatus"
67
84
 
68
85
  this.addDefaultPath('SOC','electrical.batteries.capacity.stateOfCharge')
@@ -0,0 +1,123 @@
1
+ const BTSensor = require("../BTSensor");
2
+ class SensorPush extends BTSensor{
3
+ static Domain = BTSensor.SensorDomains.environmental
4
+
5
+ static async identify(device){
6
+
7
+ const name = await this.getDeviceProp(device,"Name")
8
+ const regex= /^SensorPush\s(HT|HTP)\s[0-9a-fA-F]{4}$/
9
+ if (name && name.match(regex))
10
+ return this
11
+ else
12
+ return null
13
+ }
14
+ static ImageFile="SensorPush.webp"
15
+ static Manufacturer="Cousins & Sears - Creative Technologists - Brooklyn, NY USA"
16
+ static ServiceUUID = "EF090000-11D6-42BA-93B8-9DD7EC090AB0"
17
+ static Characteristics =
18
+ {
19
+ tx: "EF090003-11D6-42BA-93B8-9DD7EC090AA9",
20
+ adv: "EF090005-11D6-42BA-93B8-9DD7EC090AA9",
21
+ batt: "EF090007-11D6-42BA-93B8-9DD7EC090AA9",
22
+ LED: "EF09000C-11D6-42BA-93B8-9DD7EC090AA9",
23
+ temp: "EF090080-11D6-42BA-93B8-9DD7EC090AA9",
24
+ hum: "EF090081-11D6-42BA-93B8-9DD7EC090AA9",
25
+ bar: "EF090082-11D6-42BA-93B8-9DD7EC090AA9"
26
+ }
27
+ pollFreq=30
28
+ hasGATT(){
29
+ return true
30
+ }
31
+ usingGATT(){
32
+ return true
33
+ }
34
+
35
+
36
+ async emitGATT(){
37
+ this.characteristics.temp.writeValue(0x01000000).then(async ()=>{
38
+ this.emitData("temp", await this.characteristics.temp.readValue())
39
+ this.emitData("hum", await this.characteristics.temp.readValue())
40
+ })
41
+ this.characteristics.bar.writeValue(0x01000000).then(async ()=>{
42
+ this.emitData("bar", await this.characteristics.bar.readValue())
43
+ })
44
+ }
45
+
46
+ initSchema(){
47
+ super.initSchema()
48
+ this.getGATTParams()["useGATT"].default=true
49
+
50
+ this.addDefaultParam("zone")
51
+
52
+ this.addParameter(
53
+ "tx",
54
+ {
55
+ title:'transmission rate in db',
56
+ type: 'number',
57
+ enum: [-21, -18, -15, -12, -9, -6, -3, 0, 1, 2, 3, 4, 5],
58
+ default: -3,
59
+ isRequired: true
60
+ }
61
+ )
62
+ this.addParameter(
63
+ "adv",
64
+ {
65
+ title:'advertising interval in ms',
66
+ type: 'number',
67
+ default: 1285,
68
+ minimum: Math.round((32*625)/1000),
69
+ maximum: Math.round((32767*625)/1000),
70
+ isRequired: true
71
+ }
72
+ )
73
+
74
+ this.addParameter(
75
+ "LED",
76
+ {
77
+ type: 'number',
78
+ title:'LED flashes per second (0=off, 1-127, 128=once every second',
79
+ default: 0,
80
+ minimum: 0,
81
+ maximum: 128,
82
+ isRequired: true
83
+ }
84
+ )
85
+
86
+ this.addDefaultPath("batt","sensors.batteryVoltage")
87
+ .read=(buffer)=>{ return buffer.readUInt16LE()/100}
88
+
89
+ this.addDefaultPath("temp","environment.temperature")
90
+ .read=(buffer)=>{ return buffer.readInt32E()/100}
91
+
92
+ this.addDefaultPath("humidity","environment.humidity")
93
+ .read=(buffer)=>{ return buffer.readInt32E()/10000}
94
+
95
+ this.addDefaultPath("pressure","environment.pressure")
96
+ .read=(buffer)=>{ return buffer.readInt32E()/100}
97
+
98
+ }
99
+
100
+ async initGATTConnection(isReconnecting){
101
+ await super.initGATTConnection(isReconnecting)
102
+ const gattServer = await this.getGATTServer()
103
+ const service = await gattServer.getPrimaryService(this.constructor.ServiceUUID)
104
+ this.characteristics={}
105
+ for (const c in this.constructor.Characteristics) {
106
+ this.characteristics[c] = await service.getCharacteristic(this.constructor.Characteristics[c])
107
+ }
108
+ if (this.tx) this.characteristics.tx.writeValueWithoutResponse(this.tx)
109
+ if (this.LED) this.characteristics.LED.writeValueWithoutResponse(this.LED)
110
+ if (this.adv) this.characteristics.tx.writeValueWithoutResponse(Math.round((this.adv/625)*1000))
111
+ }
112
+ async initGATTNotifications() {
113
+
114
+ }
115
+
116
+ async deactivateGATT(){
117
+ for (const c in this.characteristics) {
118
+ await this.stopGATTNotifications(this.characteristics[c])
119
+ }
120
+ await super.deactivateGATT()
121
+ }
122
+ }
123
+ module.exports=SensorPush