Skip to content

Commit 90406b2

Browse files
bthome.py - more binary properties added
1 parent 924ea2e commit 90406b2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

datatypes.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Object id,Property,Data type,Factor,Example,Result,Unit
1414
0x0D,pm2.5,uint16 (2 bytes),1,0D120C,3090,ug/m3
1515
0x0E,pm10,uint16 (2 bytes),1,0E021C,7170,ug/m3
1616
0x0F,generic boolean,uint8 (1 byte),0F01,"0 (False = Off) 1 (True = On)"
17+
0x10,power,uint8 (1 byte),1001,"0 (False = Off) 1 (True = On)"
18+
0x11,opening,uint8 (1 byte),1100,"0 (False = Closed) 1 (True = Open)"
1719
0x12,co2,uint16 (2 bytes),1,12E204,1250,ppm
1820
0x13,tvoc,uint16 (2 bytes),1,133301,307,ug/m3
1921
0x14,moisture,uint16 (2 bytes),0.01,14020C,30.74,%
@@ -31,11 +33,9 @@ Object id,Property,Data type,Factor,Example,Result,Unit
3133
0x20,moisture,uint8 (1 byte),2001,"0 (False = Dry) 1 (True = Wet)"
3234
0x21,motion,uint8 (1 byte),2100,"0 (False = Clear) 1 (True = Detected)"
3335
0x22,moving,uint8 (1 byte),2201,"0 (False = Not moving) 1 (True = Moving)"
34-
3536
0x23,occupancy,uint8 (1 byte),2301,"0 (False = Clear) 1 (True = Detected)"
36-
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)"
38-
0x10,power,uint8 (1 byte),1001,"0 (False = Off) 1 (True = On)"
38+
3939
0x25,presence,uint8 (1 byte),2500,"0 (False = Away) 1 (True = Home)"
4040
0x26,problem,uint8 (1 byte),2601,"0 (False = OK) 1 (True = Problem)"
4141
0x27,running,uint8 (1 byte),2701,"0 (False = Not Running) 1 (True = Running)"

src/bthome.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class BTHome:
5252
PM2_5_UINT16_X1 = const(0x0D) # ug/m^3
5353
PM10_UINT16_X1 = const(0x0E) # ug/m^3
5454
GENERIC_BOOLEAN = const(0x0F) # 0 (False = Off) 1 (True = On)
55+
POWER_BINARY = const(0x10) # 0 (False = Off) 1 (True = On)
56+
OPENING_BINARY = const(0x11) # 0 (False = Closed) 1 (True = Open)
5557
CO2_UINT16_X1 = const(0x12) # ppm
5658
TVOC_UINT16_X1 = const(0x13) # ug/m^3
5759
MOISTURE_UINT16_X100 = const(0x14) # %
@@ -69,6 +71,8 @@ class BTHome:
6971
MOISTURE_BINARY = const(0x20) # 0 (False = Dry) 1 (True = Wet)
7072
MOTION_BINARY = const(0x21) # 0 (False = Clear) 1 (True = Detected)
7173
MOVING_BINARY = const(0x22) # 0 (False = Not moving) 1 (True = Moving)
74+
OCCUPANCY_BINARY = const(0x23) # 0 (False = Clear) 1 (True = Detected)
75+
PLUG_BINARY = const(0x24) # 0 (False = Unplugged) 1 (True = Plugged in)
7276
HUMIDITY_UINT8_X1 = const(0x2E) # %
7377
MOISTURE_UINT8_X1 = const(0x2F) # %
7478
COUNT_UINT16_X1 = const(0x3D)
@@ -127,6 +131,8 @@ class BTHome:
127131
PM2_5_UINT16_X1: "pm2.5", # 0x0D
128132
PM10_UINT16_X1: "pm10", # 0x0E
129133
GENERIC_BOOLEAN: "generic_boolean", # 0x0F
134+
POWER_BINARY: "power_on", # 0x10
135+
OPENING_BINARY: "opening", # 0x11
130136
CO2_UINT16_X1: "co2", # 0x12
131137
TVOC_UINT16_X1: "tvoc", # 0x13
132138
MOISTURE_UINT16_X100: "moisture", # 0x14
@@ -144,6 +150,8 @@ class BTHome:
144150
MOISTURE_BINARY: "moisture_detected", # 0x20
145151
MOTION_BINARY: "motion", # 0x21
146152
MOVING_BINARY: "moving", # 0x22
153+
OCCUPANCY_BINARY: "occupancy", # 0x23
154+
PLUG_BINARY: "plug", # 0x24
147155
HUMIDITY_UINT8_X1: "humidity", # 0x2E
148156
MOISTURE_UINT8_X1: "moisture", # 0x2F
149157
COUNT_UINT16_X1: "count", # 0x3D
@@ -225,9 +233,12 @@ class BTHome:
225233
moisture_detected = False
226234
motion = False
227235
moving = False
236+
opening = False
237+
plug = False
228238
pm10 = 0
229239
pm2_5 = 0
230240
power = 0
241+
power_on = False
231242
precipitation = 0
232243
pressure = 0
233244
raw = bytes()
@@ -334,6 +345,8 @@ def _pack_raw_text(self, object_id, value):
334345
PM2_5_UINT16_X1: _pack_int16_x1, # 0x0D
335346
PM10_UINT16_X1: _pack_int16_x1, # 0x0E
336347
GENERIC_BOOLEAN: _pack_binary, # 0x0F
348+
POWER_BINARY: _pack_binary, # 0x10
349+
OPENING_BINARY: _pack_binary, # 0x11
337350
CO2_UINT16_X1: _pack_int16_x1, # 0x12
338351
TVOC_UINT16_X1: _pack_int16_x1,
339352
MOISTURE_UINT16_X100: _pack_int16_x100,
@@ -351,6 +364,8 @@ def _pack_raw_text(self, object_id, value):
351364
MOISTURE_BINARY: _pack_binary,
352365
MOTION_BINARY: _pack_binary,
353366
MOVING_BINARY: _pack_binary,
367+
OCCUPANCY_BINARY: _pack_binary,
368+
PLUG_BINARY: _pack_binary,
354369
HUMIDITY_UINT8_X1: _pack_int8_x1,
355370
MOISTURE_UINT8_X1: _pack_int8_x1,
356371
COUNT_UINT16_X1: _pack_int16_x1,

0 commit comments

Comments
 (0)