@@ -26,16 +26,22 @@ class BTHome:
2626 # Device name used in BLE advertisements.
2727 _local_name = ""
2828
29- # For most sensors, naming convention is:
29+ # For most sensors defined below, the naming convention is:
3030 # <const_name> ::= <property> "_" <data-type> "_x" <inverse of factor>
3131 # Example, temperature sint16 0.01 becomes:
3232 # TEMPERATURE_SINT16_x100
33- # For binary sensors (0x15 .. 0x2D), naming convention is:
33+ # Some properties have no factor, because it doesn't make sense for what's
34+ # being communicated. Examples: packet id, button press, firmware version.
35+ # The naming convention for these is simply:
36+ # <const_name> ::= <property> "_" <data-type>
37+ # Binary sensors also have no factor and are alway represented as an
38+ # 8-bit unsigned integer.
39+ # For binary sensors (0x15 .. 0x2D), the naming convention is:
3440 # <const_name> ::= <property> "_" BINARY
3541 # Example, "battery charging" becomes:
3642 # BATTERY_CHARGING_BINARY
37- # All binary sensors are packed as 8-bit unsigned bytes.
38- # See "Sensor Data" table at https://bthome.io/format/
43+ #
44+ # See also: "Sensor Data" table at https://bthome.io/format/
3945 PACKET_ID_UINT8 = const (0x00 )
4046 BATTERY_UINT8_X1 = const (0x01 ) # %
4147 TEMPERATURE_SINT16_X100 = const (0x02 ) # °C
@@ -84,6 +90,8 @@ class BTHome:
8490 WINDOW_BINARY = const (0x2D ) # 0 (False = Closed) 1 (True = Open)
8591 HUMIDITY_UINT8_X1 = const (0x2E ) # %
8692 MOISTURE_UINT8_X1 = const (0x2F ) # %
93+ BUTTON_UINT8 = const (0x3A ) # 01 = press, 02 = long press, etc.
94+ DIMMER_UINT16 = const (0x03A ) # 01xx = rotate left xx steps, 02xx = rotate right xx steps
8795 COUNT_UINT16_X1 = const (0x3D )
8896 COUNT_UINT32_X1 = const (0x3E )
8997 ROTATION_SINT16_X10 = const (0x3F ) # °
@@ -172,6 +180,8 @@ class BTHome:
172180 WINDOW_BINARY : "window" , # 0x2D
173181 HUMIDITY_UINT8_X1 : "humidity" , # 0x2E
174182 MOISTURE_UINT8_X1 : "moisture" , # 0x2F
183+ BUTTON_UINT8 : "button" , # 0x3A
184+ DIMMER_UINT16 : "dimmer" , # 0x3C
175185 COUNT_UINT16_X1 : "count" , # 0x3D
176186 COUNT_UINT32_X1 : "count" , # 0x3E
177187 ROTATION_SINT16_X10 : "rotation" , # 0x3F
@@ -404,6 +414,8 @@ def _pack_raw_text(self, object_id, value):
404414 WINDOW_BINARY : _pack_binary ,
405415 HUMIDITY_UINT8_X1 : _pack_int8_x1 ,
406416 MOISTURE_UINT8_X1 : _pack_int8_x1 ,
417+ BUTTON_UINT8 : _pack_int8_x1 ,
418+ DIMMER_UINT16 : _pack_int16_x1 ,
407419 COUNT_UINT16_X1 : _pack_int16_x1 ,
408420 COUNT_UINT32_X1 : _pack_int32_x1 ,
409421 ROTATION_SINT16_X10 : _pack_int16_x10 ,
0 commit comments