@@ -30,8 +30,8 @@ class BTHome:
30
30
_local_name = ""
31
31
32
32
# Whether the device sends updates at regular intervals or on a trigger like a button.
33
- _interval_advertising = True
34
- _INTERVAL_ADVERTISING_FLAG = 0x4
33
+ _trigger_based = False
34
+ _TRIGGER_BASED_FLAG = 0x4
35
35
36
36
# For most sensors defined below, the naming convention is:
37
37
# <const_name> ::= <property> "_" <data-type> "_x" <inverse of factor>
@@ -314,11 +314,11 @@ class BTHome:
314
314
button = 0
315
315
dimmer = 0
316
316
317
- def __init__ (self , local_name = "BTHome" , interval_advertising = True , debug = False ):
317
+ def __init__ (self , local_name = "BTHome" , trigger_based = False , debug = False ):
318
318
local_name = local_name [:10 ] # Truncate to fit [^4]
319
319
self ._local_name = local_name
320
320
self ._packet_id = 0
321
- self ._interval_advertising = interval_advertising
321
+ self ._trigger_based = trigger_based
322
322
self .debug = debug
323
323
324
324
@property
@@ -493,10 +493,10 @@ def _pack_service_data(self, *args):
493
493
) # indicates a 16-bit service UUID follows
494
494
service_data_bytes += pack ("<H" , BTHome ._SERVICE_UUID16 )
495
495
flags = BTHome ._DEVICE_INFO_FLAGS
496
- if self ._interval_advertising :
497
- flags &= ~ self ._INTERVAL_ADVERTISING_FLAG
496
+ if self ._trigger_based :
497
+ flags |= self ._TRIGGER_BASED_FLAG
498
498
else :
499
- flags |= self ._INTERVAL_ADVERTISING_FLAG
499
+ flags &= ~ self ._TRIGGER_BASED_FLAG
500
500
service_data_bytes += pack ("B" , flags )
501
501
args = sorted (args , key = lambda x : x if isinstance (x , int ) else x [0 ])
502
502
for object_id in args :
0 commit comments