Skip to content

Commit 21d5283

Browse files
bthome.py - more binary properties added
1 parent 7242d5a commit 21d5283

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

datatypes.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ Object id,Property,Data type,Factor,Example,Result,Unit
2626
0x1B,garage door,uint8 (1 byte),1B01,"0 (False = Closed) 1 (True = Open)"
2727
0x1C,gas,uint8 (1 byte),1C01,"0 (False = Clear) 1 (True = Detected)"
2828
0x1D,heat,uint8 (1 byte),1D00,"0 (False = Normal) 1 (True = Hot)"
29-
3029
0x1E,light,uint8 (1 byte),1E01,"0 (False = No light) 1 (True = Light detected)"
3130
0x1F,lock,uint8 (1 byte),1F01,"0 (False = Locked) 1 (True = Unlocked)"
3231
0x20,moisture,uint8 (1 byte),2001,"0 (False = Dry) 1 (True = Wet)"
3332
0x21,motion,uint8 (1 byte),2100,"0 (False = Clear) 1 (True = Detected)"
3433
0x22,moving,uint8 (1 byte),2201,"0 (False = Not moving) 1 (True = Moving)"
34+
3535
0x23,occupancy,uint8 (1 byte),2301,"0 (False = Clear) 1 (True = Detected)"
3636
0x11,opening,uint8 (1 byte),1100,"0 (False = Closed) 1 (True = Open)"
3737
0x24,plug,uint8 (1 byte),2400,"0 (False = Unplugged) 1 (True = Plugged in)"

src/bthome.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class BTHome:
6464
GARAGE_DOOR_BINARY = const(0x1B) # 0 (False = Closed) 1 (True = Open)
6565
GAS_BINARY = const(0x1C) # 0 (False = Clear) 1 (True = Detected)
6666
HEAT_BINARY = const(0x1D) # 0 (False = Normal) 1 (True = Hot)
67+
LIGHT_BINARY = const(0x1E) # 0 (False = No light) 1 (True = Light detected)
68+
LOCK_BINARY = const(0x1F) # 0 (False = Locked) 1 (True = Unlocked)
69+
MOISTURE_BINARY = const(0x20) # 0 (False = Dry) 1 (True = Wet)
70+
MOTION_BINARY = const(0x21) # 0 (False = Clear) 1 (True = Detected)
71+
MOVING_BINARY = const(0x22) # 0 (False = Not moving) 1 (True = Moving)
6772
HUMIDITY_UINT8_X1 = const(0x2E) # %
6873
MOISTURE_UINT8_X1 = const(0x2F) # %
6974
COUNT_UINT16_X1 = const(0x3D)
@@ -134,6 +139,11 @@ class BTHome:
134139
GARAGE_DOOR_BINARY: "garage_door", # 0x1B
135140
GAS_BINARY: "gas_detected", # 0x1C
136141
HEAT_BINARY: "heat", # 0x1D
142+
LIGHT_BINARY: "light", # 0x1E
143+
LOCK_BINARY: "lock", # 0x1F
144+
MOISTURE_BINARY: "moisture_detected", # 0x20
145+
MOTION_BINARY: "motion", # 0x21
146+
MOVING_BINARY: "moving", # 0x22
137147
HUMIDITY_UINT8_X1: "humidity", # 0x2E
138148
MOISTURE_UINT8_X1: "moisture", # 0x2F
139149
COUNT_UINT16_X1: "count", # 0x3D
@@ -175,10 +185,13 @@ class BTHome:
175185
}
176186

177187
# Properties below are updated externally when sensor values are read.
188+
# See "Sensor Data" table at https://bthome.io/format/ Property column.
178189
# There is some overlap in property names in the BTHome format. For
179190
# example: moisture as in percent and moisture as in detected.
180-
# In these cases, the binary property will have "_detected" appended.
181-
# See "Sensor Data" table at https://bthome.io/format/ Property column.
191+
# In these cases, the binary property will have the description of a
192+
# True condition to further describe the property. Examples are:
193+
# _charging, in the case of battery; _detected, in the case of gas,
194+
# moisture, or motion.
182195
acceleration = 0
183196
battery = 0
184197
battery_low = False
@@ -205,8 +218,13 @@ class BTHome:
205218
heat = False
206219
humidity = 0
207220
illuminance = 0
221+
light = False
222+
lock = False
208223
mass = 0
209224
moisture = 0
225+
moisture_detected = False
226+
motion = False
227+
moving = False
210228
pm10 = 0
211229
pm2_5 = 0
212230
power = 0
@@ -328,6 +346,11 @@ def _pack_raw_text(self, object_id, value):
328346
GARAGE_DOOR_BINARY: _pack_binary,
329347
GAS_BINARY: _pack_binary,
330348
HEAT_BINARY: _pack_binary,
349+
LIGHT_BINARY: _pack_binary,
350+
LOCK_BINARY: _pack_binary,
351+
MOISTURE_BINARY: _pack_binary,
352+
MOTION_BINARY: _pack_binary,
353+
MOVING_BINARY: _pack_binary,
331354
HUMIDITY_UINT8_X1: _pack_int8_x1,
332355
MOISTURE_UINT8_X1: _pack_int8_x1,
333356
COUNT_UINT16_X1: _pack_int16_x1,

0 commit comments

Comments
 (0)