Skip to content

Commit 3d90576

Browse files
bthome.py - more object_ids
1 parent 9ace3c4 commit 3d90576

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bthome.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class BTHome:
4949
COUNT_UINT16 = const(0x3D)
5050
COUNT_UINT32 = const(0x3E)
5151
ROTATION_SINT16 = const(0x3F)
52+
DISTANCE_MM_UINT16 = const(0x40)
53+
DISTANCE_M_UINT16 = const(0x41)
54+
DURATION_UINT24 = const(0x42)
5255

5356
# There is more than one way to represent most sensor properties. This
5457
# dictionary maps the object id to the property name.
@@ -75,6 +78,9 @@ class BTHome:
7578
COUNT_UINT16: "count",
7679
COUNT_UINT32: "count",
7780
ROTATION_SINT16: "rotation",
81+
DISTANCE_MM_UINT16: "distance",
82+
DISTANCE_M_UINT16: "distance",
83+
DURATION_UINT24: "duration"
7884
}
7985

8086
# Properties below are updated externally when sensor values are read.
@@ -155,6 +161,10 @@ def _pack_sint16_x100(self, object_id, value):
155161
def _pack_uint16_x1(self, object_id, value):
156162
return pack("<BH", object_id, round(value))
157163

164+
# 16-bit unsigned integer with scalling of 10 (1 decimal place)
165+
def _pack_uint16_x10(self, object_id, value):
166+
return pack("<BH", object_id, round(value * 10))
167+
158168
# 16-bit unsigned integer with scalling of 100 (2 decimal places)
159169
def _pack_uint16_x100(self, object_id, value):
160170
return pack("<BH", object_id, round(value * 100))
@@ -198,6 +208,9 @@ def _pack_uint32_x1(self, object_id, value):
198208
COUNT_UINT16: _pack_uint16_x1,
199209
COUNT_UINT32: _pack_uint32_x1,
200210
ROTATION_SINT16: _pack_sint16_x10,
211+
DISTANCE_MM_UINT16: _pack_uint16_x1,
212+
DISTANCE_M_UINT16: _pack_uint16_x10,
213+
DURATION_UINT24: _pack_uint24_x1000
201214
}
202215

203216
# Concatenate an arbitrary number of sensor readings using parameters

0 commit comments

Comments
 (0)