utils.py
utils
¶
Helpful utils for processing mug data.
Attributes¶
Functions¶
bytes_to_big_int
¶
bytes_to_big_int(
data: bytearray | bytes, signed: bool = False
) -> int
Convert bytes to big int.
Source code in ember_mug/utils.py
43 44 45 |
|
bytes_to_little_int
¶
bytes_to_little_int(data: bytearray | bytes) -> int
Convert bytes to little int.
Source code in ember_mug/utils.py
38 39 40 |
|
convert_temp_to_celsius
¶
convert_temp_to_celsius(temp: float) -> float
Convert to Celsius.
Source code in ember_mug/utils.py
53 54 55 |
|
convert_temp_to_fahrenheit
¶
convert_temp_to_fahrenheit(temp: float) -> float
Convert to fahrenheit.
Source code in ember_mug/utils.py
48 49 50 |
|
decode_byte_string
¶
decode_byte_string(data: bytes | bytearray) -> str
Convert bytes to text as Ember expects.
Source code in ember_mug/utils.py
22 23 24 25 26 27 28 29 30 |
|
discover_services
async
¶
discover_services(client: BleakClient) -> dict[str, Any]
Log all services and all values for debugging/development.
Source code in ember_mug/utils.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
encode_byte_string
¶
encode_byte_string(data: str) -> bytes
Encode string from Ember Mug.
Source code in ember_mug/utils.py
33 34 35 |
|
get_colour_from_int
¶
get_colour_from_int(colour_id: int) -> DeviceColour | None
Extrapolate device colour from integer in advertiser data.
Source code in ember_mug/utils.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
get_model_from_id_and_gen
¶
get_model_from_id_and_gen(
model_id: int, generation: int
) -> DeviceModel | None
Extract model from identifier in advertiser data.
Source code in ember_mug/utils.py
108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
get_model_from_single_int_and_services
¶
get_model_from_single_int_and_services(
model_id: int, service_uuids: list[str]
) -> DeviceModel | None
Extrapolate device model from integer in advertiser data.
Source code in ember_mug/utils.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
get_model_info_from_advertiser_data
¶
get_model_info_from_advertiser_data(
advertisement: AdvertisementData,
) -> ModelInfo
Extract model info from manufacturer data in advertiser data.
Source code in ember_mug/utils.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
guess_model_from_name
¶
guess_model_from_name(
name: str | None,
) -> DeviceModel | None
Guess model from BLE name.
Source code in ember_mug/utils.py
123 124 125 126 127 128 129 130 131 |
|
temp_from_bytes
¶
temp_from_bytes(
temp_bytes: bytearray, metric: bool = True
) -> float
Get temperature from bytearray and convert to Fahrenheit if needed.
Source code in ember_mug/utils.py
58 59 60 61 62 63 |
|