Skip to content

Commit deb8b03

Browse files
bthome.py more object_ids
1 parent 833cc9b commit deb8b03

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bthome.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
_PRESSURE_UINT24_SCALING = const(100)
2525
ILLUMINANCE_UINT24 = const(0x05)
2626
_ILLUMINANCE_UINT24_SCALING = const(100)
27+
MASS_KG_UINT16 = const(0x06)
28+
_MASS_KG_UINT16_SCALING = const(100)
29+
MASS_LB_UINT16 = const(0x07)
30+
_MASS_LB_UINT16_SCALING = const(100)
2731

2832
# Default value decimal places indicate precision
2933
device_name = "BTHome-MPY"
@@ -32,6 +36,7 @@
3236
humidity = 0.00 # percent (relative humidity)
3337
pressure = 0.00 # hectoPascals (millibars)
3438
illuminance = 0.0 # Lux
39+
mass = 0.00 # kg or lb
3540

3641
def _pack_device_name():
3742
assert len(device_name) > 0
@@ -53,6 +58,10 @@ def _pack_bthome_data(object_id):
5358
bthome_bytes = pack('<BL', PRESSURE_UINT24, round(pressure * _PRESSURE_UINT24_SCALING))[:-1]
5459
elif object_id == ILLUMINANCE_UINT24:
5560
bthome_bytes = pack('<BL', ILLUMINANCE_UINT24, round(illuminance * _ILLUMINANCE_UINT24_SCALING))[:-1]
61+
elif object_id == MASS_KG_UINT16:
62+
bthome_bytes = pack('<Bh', MASS_KG_UINT16, round(mass * _MASS_KG_UINT16_SCALING))
63+
elif object_id == MASS_LB_UINT16:
64+
bthome_bytes = pack('<Bh', MASS_LB_UINT16, round(mass * _MASS_LB_UINT16_SCALING))
5665
else:
5766
bthome_bytes = bytes()
5867
print("Packing with data:", bthome_bytes.hex().upper())

0 commit comments

Comments
 (0)