20
20
21
21
InkBird and EasyBBQ (from PyleUSA) are brands that use the iBBQ protocol in their products.
22
22
"""
23
+ try :
24
+ from typing import Optional , Tuple
25
+ except ImportError :
26
+ pass
23
27
24
28
import struct
25
29
@@ -38,10 +42,10 @@ class _SettingsResult(ComplexCharacteristic):
38
42
39
43
uuid = StandardUUID (0xFFF1 )
40
44
41
- def __init__ (self ):
45
+ def __init__ (self ) -> None :
42
46
super ().__init__ (properties = Characteristic .NOTIFY )
43
47
44
- def bind (self , service ) :
48
+ def bind (self , service : "IBBQService" ) -> _bleio . PacketBuffer :
45
49
"""Bind to an IBBQService."""
46
50
bound_characteristic = super ().bind (service )
47
51
bound_characteristic .set_cccd (notify = True )
@@ -54,10 +58,10 @@ class _RealtimeData(ComplexCharacteristic):
54
58
55
59
uuid = StandardUUID (0xFFF4 )
56
60
57
- def __init__ (self ):
61
+ def __init__ (self ) -> None :
58
62
super ().__init__ (properties = Characteristic .NOTIFY )
59
63
60
- def bind (self , service ) :
64
+ def bind (self , service : "IBBQService" ) -> _bleio . PacketBuffer :
61
65
"""Bind to an IBBQService."""
62
66
bound_characteristic = super ().bind (service )
63
67
bound_characteristic .set_cccd (notify = True )
@@ -74,7 +78,7 @@ class IBBQService(Service):
74
78
_UNITS_CELSIUS_MSG = b"\x02 \x00 \x00 \x00 \x00 \x00 "
75
79
_REQUEST_BATTERY_LEVEL_MSG = b"\x08 \x24 \x00 \x00 \x00 \x00 "
76
80
77
- def __init__ (self , service = None ):
81
+ def __init__ (self , service : Optional [ "IBBQService" ] = None ) -> None :
78
82
super ().__init__ (service = service )
79
83
# Defer creating buffers until needed, since MTU is not known yet.
80
84
self ._settings_result_buf = None
@@ -106,27 +110,27 @@ def __init__(self, service=None):
106
110
)
107
111
"""Send control messages here."""
108
112
109
- def init (self ):
113
+ def init (self ) -> None :
110
114
"""Perform initial "pairing", which is not regular BLE pairing."""
111
115
self .account_and_verify = self ._CREDENTIALS_MSG
112
116
self .settings_data = self ._REALTIME_DATA_ENABLE_MSG
113
117
114
- def display_fahrenheit (self ):
118
+ def display_fahrenheit (self ) -> None :
115
119
"""Display temperatures on device in degrees Fahrenheit.
116
120
117
121
Note: This does not change the units returned by `temperatures`.
118
122
"""
119
123
self .settings_data = self ._UNITS_FAHRENHEIT_MSG
120
124
121
- def display_celsius (self ):
125
+ def display_celsius (self ) -> None :
122
126
"""Display temperatures on device in degrees Celsius.
123
127
124
128
Note: This does not change the units returned by `temperatures`.
125
129
"""
126
130
self .settings_data = self ._UNITS_CELSIUS_MSG
127
131
128
132
@property
129
- def temperatures (self ):
133
+ def temperatures (self ) -> Optional [ Tuple ] :
130
134
"""Return a tuple of temperatures for all the possible temperature probes on the device.
131
135
Temperatures are in degrees Celsius. Unconnected probes return 0.0.
132
136
"""
@@ -145,7 +149,7 @@ def temperatures(self):
145
149
return None
146
150
147
151
@property
148
- def battery_level (self ):
152
+ def battery_level (self ) -> Optional [ Tuple [ float , float ]] :
149
153
"""Get current battery level in volts as ``(current_voltage, max_voltage)``.
150
154
Results are approximate and may differ from the
151
155
actual battery voltage by 0.1v or so.
0 commit comments