Skip to content

Commit 348a97a

Browse files
committed
Implement BLE Energy sensor
1 parent 5eb8b77 commit 348a97a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/attributes.js

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports.names = {
3535
"2a6d": "Pressure",
3636
"2a6e": "Temperature",
3737
"2a6f": "Humidity",
38+
"2af2": "Energy",
3839
// https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-members/
3940
"fe0f": "Philips",
4041
"fe95": "Xiaomi",
@@ -197,6 +198,11 @@ exports.handlers = {
197198
// probably not meant for advertising, but seems useful!
198199
return {analog: a[0] | (a.length > 1 ? (a[1] << 8) : 0)}
199200
},
201+
"2af2": function (a) { // Energy
202+
return {
203+
energy: a.readUInt32BE()
204+
}
205+
},
200206
// org.bluetooth.characteristic.digital_output 0x2A57 ?
201207
"ffff": function (a) { // 0xffff isn't standard anything - just transmit it as 'data'
202208
if (a.length == 1)

lib/homeassistant.js

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const deviceTypes = {
3333
unit_of_measurement: "%",
3434
device_class: "battery"
3535
},
36+
energy: {
37+
unit_of_measurement: "Wh",
38+
device_class: "energy"
39+
},
3640
illuminance: { // lx
3741
unit_of_measurement: "lx",
3842
device_class: "illuminance"

0 commit comments

Comments
 (0)