Skip to content

consts.py

consts

Bluetooth UUIDs and other constants used for communicating with the mug.

Attributes

ATTR_LABELS module-attribute

ATTR_LABELS = {
    "name": "Device Name",
    "meta": "Meta",
    "battery": "Battery",
    "firmware": "Firmware",
    "led_colour": "LED Colour",
    "liquid_state": "Liquid State",
    "liquid_level": "Liquid Level",
    "current_temp": "Current Temp",
    "target_temp": "Target Temp",
    "use_metric": "Use Metric",
    "dsk": "DSK",
    "udsk": "UDSK",
    "date_time_zone": "Date Time + Time Zone",
    "battery_voltage": "Voltage",
    "volume_level": "Volume Level",
}

DEFAULT_NAME module-attribute

DEFAULT_NAME = 'Ember Device'

DEVICE_MODEL_NAMES module-attribute

DEVICE_MODEL_NAMES: dict[DeviceModel, str] = {
    CUP_6_OZ: "Ember Cup",
    MUG_1_10_OZ: "Ember Mug (10oz)",
    MUG_1_14_OZ: "Ember Mug (14oz)",
    MUG_2_10_OZ: "Ember Mug 2 (10oz)",
    MUG_2_14_OZ: "Ember Mug 2 (14oz)",
    TRAVEL_MUG_12_OZ: "Ember Travel Mug",
    TUMBLER_16_OZ: "Ember Tumbler",
}

DEVICE_SERVICE_UUIDS module-attribute

DEVICE_SERVICE_UUIDS = (
    str(STANDARD_SERVICE),
    *TRAVEL_MUG_SERVICE_UUIDS,
)

EMBER_BLE_SIG module-attribute

EMBER_BLE_SIG = 961

EXTRA_ATTRS module-attribute

EXTRA_ATTRS = {
    "battery_voltage",
    "date_time_zone",
    "udsk",
    "dsk",
}

INITIAL_ATTRS module-attribute

INITIAL_ATTRS = {
    "meta",
    "udsk",
    "dsk",
    "date_time_zone",
    "firmware",
}

IS_LINUX module-attribute

IS_LINUX = system() == 'Linux'

LIQUID_STATE_LABELS module-attribute

LIQUID_STATE_LABELS: dict[int, str] = {
    STANDBY: "Standby",
    EMPTY: "Empty",
    FILLING: "Filling",
    COLD_NO_TEMP_CONTROL: "Cold (No control)",
    COOLING: "Cooling",
    HEATING: "Heating",
    TARGET_TEMPERATURE: "Perfect",
    WARM_NO_TEMP_CONTROL: "Warm (No control)",
}

LIQUID_STATE_UNKNOWN module-attribute

LIQUID_STATE_UNKNOWN = 'Unknown'

MAC_ADDRESS_REGEX module-attribute

MAC_ADDRESS_REGEX = compile(
    "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$"
)

MIN_MAX_TEMPS module-attribute

MIN_MAX_TEMPS = {
    CELSIUS: MinMaxTemp(49, 63),
    FAHRENHEIT: MinMaxTemp(120, 145),
}

MUG_NAME_PATTERN module-attribute

MUG_NAME_PATTERN = pattern

MUG_NAME_REGEX module-attribute

MUG_NAME_REGEX = compile(
    "^[A-Za-z0-9,.\\[\\]#()!\\\"\\';:|\\-_+<>%= ]{1,16}$"
)

PUSH_EVENT_BATTERY_IDS module-attribute

PUSH_EVENT_BATTERY_IDS = [
    BATTERY_CHANGED,
    CHARGER_CONNECTED,
    CHARGER_DISCONNECTED,
]

TRAVEL_MUG_SERVICE_UUIDS module-attribute

TRAVEL_MUG_SERVICE_UUIDS = (
    str(TRAVEL_MUG_SERVICE),
    str(TRAVEL_MUG_SERVICE_OTHER),
)

UPDATE_ATTRS module-attribute

UPDATE_ATTRS = {
    "name",
    "led_colour",
    "current_temp",
    "target_temp",
    "temperature_unit",
    "battery",
    "liquid_level",
    "liquid_state",
}

UUID_TEMPLATE module-attribute

UUID_TEMPLATE = 'fc54{:0>4x}-236c-4c94-8fa9-944a3e5353fa'

Classes

DeviceColour

Bases: str, Enum

All colours possible found across models.

Source code in ember_mug/consts.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class DeviceColour(str, Enum):
    """All colours possible found across models."""

    SAGE_GREEN = "Sage Green"
    SANDSTONE = "Sandstone"
    BLACK = "Black"
    WHITE = "White"
    GREY = "Grey"
    BLUE = "Blue"
    RED = "Red"
    COPPER = "Copper"
    GOLD = "Gold"
    STAINLESS_STEEL = "Stainless Steel"
    ROSE_GOLD = "Rose Gold"
Attributes
BLACK class-attribute instance-attribute
BLACK = 'Black'
BLUE class-attribute instance-attribute
BLUE = 'Blue'
COPPER class-attribute instance-attribute
COPPER = 'Copper'
GOLD class-attribute instance-attribute
GOLD = 'Gold'
GREY class-attribute instance-attribute
GREY = 'Grey'
RED class-attribute instance-attribute
RED = 'Red'
ROSE_GOLD class-attribute instance-attribute
ROSE_GOLD = 'Rose Gold'
SAGE_GREEN class-attribute instance-attribute
SAGE_GREEN = 'Sage Green'
SANDSTONE class-attribute instance-attribute
SANDSTONE = 'Sandstone'
STAINLESS_STEEL class-attribute instance-attribute
STAINLESS_STEEL = 'Stainless Steel'
WHITE class-attribute instance-attribute
WHITE = 'White'

DeviceModel

Bases: str, Enum

Know device models.

Source code in ember_mug/consts.py
28
29
30
31
32
33
34
35
36
37
38
class DeviceModel(str, Enum):
    """Know device models."""

    CUP_6_OZ = "CM21S"
    MUG_1_10_OZ = "CM17"
    MUG_1_14_OZ = "CM17P"
    MUG_2_10_OZ = "CM19/CM21M"
    MUG_2_14_OZ = "CM19P/CM21L"
    TRAVEL_MUG_12_OZ = "TM19"
    TUMBLER_16_OZ = "CM21XL"
    UNKNOWN_DEVICE = "Unknown"
Attributes
CUP_6_OZ class-attribute instance-attribute
CUP_6_OZ = 'CM21S'
MUG_1_10_OZ class-attribute instance-attribute
MUG_1_10_OZ = 'CM17'
MUG_1_14_OZ class-attribute instance-attribute
MUG_1_14_OZ = 'CM17P'
MUG_2_10_OZ class-attribute instance-attribute
MUG_2_10_OZ = 'CM19/CM21M'
MUG_2_14_OZ class-attribute instance-attribute
MUG_2_14_OZ = 'CM19P/CM21L'
TRAVEL_MUG_12_OZ class-attribute instance-attribute
TRAVEL_MUG_12_OZ = 'TM19'
TUMBLER_16_OZ class-attribute instance-attribute
TUMBLER_16_OZ = 'CM21XL'
UNKNOWN_DEVICE class-attribute instance-attribute
UNKNOWN_DEVICE = 'Unknown'

DeviceType

Bases: str, Enum

Base device types.

Source code in ember_mug/consts.py
19
20
21
22
23
24
25
class DeviceType(str, Enum):
    """Base device types."""

    CUP = "cup"
    MUG = "mug"
    TRAVEL_MUG = "travel_mug"
    TUMBLER = "tumbler"
Attributes
CUP class-attribute instance-attribute
CUP = 'cup'
MUG class-attribute instance-attribute
MUG = 'mug'
TRAVEL_MUG class-attribute instance-attribute
TRAVEL_MUG = 'travel_mug'
TUMBLER class-attribute instance-attribute
TUMBLER = 'tumbler'

LiquidState

Bases: IntEnum

Constants for liquid state codes.

Source code in ember_mug/consts.py
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
class LiquidState(IntEnum):
    """Constants for liquid state codes."""

    STANDBY = 0
    EMPTY = 1
    FILLING = 2
    COLD_NO_TEMP_CONTROL = 3
    COOLING = 4
    HEATING = 5
    TARGET_TEMPERATURE = 6
    WARM_NO_TEMP_CONTROL = 7

    @cached_property
    def label(self) -> str:
        """Get label for current state."""
        return LIQUID_STATE_LABELS[self.value]

    def __str__(self) -> str:
        """Return label for display."""
        return self.label
Attributes
COLD_NO_TEMP_CONTROL class-attribute instance-attribute
COLD_NO_TEMP_CONTROL = 3
COOLING class-attribute instance-attribute
COOLING = 4
EMPTY class-attribute instance-attribute
EMPTY = 1
FILLING class-attribute instance-attribute
FILLING = 2
HEATING class-attribute instance-attribute
HEATING = 5
STANDBY class-attribute instance-attribute
STANDBY = 0
TARGET_TEMPERATURE class-attribute instance-attribute
TARGET_TEMPERATURE = 6
WARM_NO_TEMP_CONTROL class-attribute instance-attribute
WARM_NO_TEMP_CONTROL = 7
label cached property
label: str

Get label for current state.

MinMaxTemp

Bases: NamedTuple

Helper for MinMaxTemp.

Source code in ember_mug/consts.py
75
76
77
78
79
class MinMaxTemp(NamedTuple):
    """Helper for MinMaxTemp."""

    min_temp: float
    max_temp: float
Attributes
max_temp instance-attribute
max_temp: float
min_temp instance-attribute
min_temp: float

MugCharacteristic

Bases: IntEnum

Characteristic IDs for the Mug.

Source code in ember_mug/consts.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class MugCharacteristic(IntEnum):
    """Characteristic IDs for the Mug."""

    # Name of mug in byte string (Read/Write)
    MUG_NAME = 1
    # Current Mug Temp (Read)
    CURRENT_TEMPERATURE = 2
    # Target Mug Temp (Read/Write)
    TARGET_TEMPERATURE = 3
    # Unit (0 -> Celsius, 1 -> Fahrenheit) (Read/Write)
    TEMPERATURE_UNIT = 4
    # Level (Between 0 -> 30 ?) 30 100% ?
    LIQUID_LEVEL = 5
    # Current date and time zone? (Read/Write)
    DATE_TIME_AND_ZONE = 6
    # Battery Info (Read)
    BATTERY = 7
    # Integer representing what it is doing with the liquid (Read)
    LIQUID_STATE = 8
    # Volume - I think for the thermos
    VOLUME = 9
    # Last location - (Write)
    LAST_LOCATION = 10
    # Unsure what it does
    UUID_ACCELERATION = 11
    # Firmware info (Read)
    FIRMWARE = 12
    # [Unique ID]-[serial number] (Read)
    MUG_ID = 13
    # DSK - Unique ID used for auth in app (Read)
    DSK = 14
    # UDSK - Used for auth in app (Read/Write)
    UDSK = 15
    # int/temp lock - Address (Read/Write)
    CONTROL_REGISTER_ADDRESS = 16
    # Battery charge info (Read/Write)
    CONTROL_REGISTER_DATA = 17
    # To watch for changes from mug (Notify/Read)
    PUSH_EVENT = 18
    # To gather bytes from mug for stats (Notify)
    STATISTICS = 19
    # RGBA Colour of LED (Read/Write)
    LED = 20
    # Service
    STANDARD_SERVICE = 13858
    TRAVEL_MUG_SERVICE = 13857
    TRAVEL_MUG_SERVICE_OTHER = 8609

    @cached_property
    def uuid(self) -> UUID:
        """Convert the ID to a full UUID and cache."""
        return UUID(UUID_TEMPLATE.format(self.value))

    def __str__(self) -> str:
        """Convert UUID to string value."""
        return str(self.uuid)
Attributes
BATTERY class-attribute instance-attribute
BATTERY = 7
CONTROL_REGISTER_ADDRESS class-attribute instance-attribute
CONTROL_REGISTER_ADDRESS = 16
CONTROL_REGISTER_DATA class-attribute instance-attribute
CONTROL_REGISTER_DATA = 17
CURRENT_TEMPERATURE class-attribute instance-attribute
CURRENT_TEMPERATURE = 2
DATE_TIME_AND_ZONE class-attribute instance-attribute
DATE_TIME_AND_ZONE = 6
DSK class-attribute instance-attribute
DSK = 14
FIRMWARE class-attribute instance-attribute
FIRMWARE = 12
LAST_LOCATION class-attribute instance-attribute
LAST_LOCATION = 10
LED class-attribute instance-attribute
LED = 20
LIQUID_LEVEL class-attribute instance-attribute
LIQUID_LEVEL = 5
LIQUID_STATE class-attribute instance-attribute
LIQUID_STATE = 8
MUG_ID class-attribute instance-attribute
MUG_ID = 13
MUG_NAME class-attribute instance-attribute
MUG_NAME = 1
PUSH_EVENT class-attribute instance-attribute
PUSH_EVENT = 18
STANDARD_SERVICE class-attribute instance-attribute
STANDARD_SERVICE = 13858
STATISTICS class-attribute instance-attribute
STATISTICS = 19
TARGET_TEMPERATURE class-attribute instance-attribute
TARGET_TEMPERATURE = 3
TEMPERATURE_UNIT class-attribute instance-attribute
TEMPERATURE_UNIT = 4
TRAVEL_MUG_SERVICE class-attribute instance-attribute
TRAVEL_MUG_SERVICE = 13857
TRAVEL_MUG_SERVICE_OTHER class-attribute instance-attribute
TRAVEL_MUG_SERVICE_OTHER = 8609
UDSK class-attribute instance-attribute
UDSK = 15
UUID_ACCELERATION class-attribute instance-attribute
UUID_ACCELERATION = 11
VOLUME class-attribute instance-attribute
VOLUME = 9
uuid cached property
uuid: UUID

Convert the ID to a full UUID and cache.

PushEvent

Bases: IntEnum

IDs for Push Events.

Source code in ember_mug/consts.py
198
199
200
201
202
203
204
205
206
207
208
209
class PushEvent(IntEnum):
    """IDs for Push Events."""

    BATTERY_CHANGED = 1
    CHARGER_CONNECTED = 2
    CHARGER_DISCONNECTED = 3
    TARGET_TEMPERATURE_CHANGED = 4
    DRINK_TEMPERATURE_CHANGED = 5
    AUTH_INFO_NOT_FOUND = 6
    LIQUID_LEVEL_CHANGED = 7
    LIQUID_STATE_CHANGED = 8
    BATTERY_VOLTAGE_STATE_CHANGED = 9
Attributes
AUTH_INFO_NOT_FOUND class-attribute instance-attribute
AUTH_INFO_NOT_FOUND = 6
BATTERY_CHANGED class-attribute instance-attribute
BATTERY_CHANGED = 1
BATTERY_VOLTAGE_STATE_CHANGED class-attribute instance-attribute
BATTERY_VOLTAGE_STATE_CHANGED = 9
CHARGER_CONNECTED class-attribute instance-attribute
CHARGER_CONNECTED = 2
CHARGER_DISCONNECTED class-attribute instance-attribute
CHARGER_DISCONNECTED = 3
DRINK_TEMPERATURE_CHANGED class-attribute instance-attribute
DRINK_TEMPERATURE_CHANGED = 5
LIQUID_LEVEL_CHANGED class-attribute instance-attribute
LIQUID_LEVEL_CHANGED = 7
LIQUID_STATE_CHANGED class-attribute instance-attribute
LIQUID_STATE_CHANGED = 8
TARGET_TEMPERATURE_CHANGED class-attribute instance-attribute
TARGET_TEMPERATURE_CHANGED = 4

TemperatureUnit

Bases: str, Enum

Temperature Units.

Source code in ember_mug/consts.py
68
69
70
71
72
class TemperatureUnit(str, Enum):
    """Temperature Units."""

    CELSIUS: Literal["°C"] = "°C"
    FAHRENHEIT: Literal["°F"] = "°F"
Attributes
CELSIUS class-attribute instance-attribute
CELSIUS: Literal['°C'] = '°C'
FAHRENHEIT class-attribute instance-attribute
FAHRENHEIT: Literal['°F'] = '°F'

VolumeLevel

Bases: str, Enum

Class to manage volume levels.

Source code in ember_mug/consts.py
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
class VolumeLevel(str, Enum):
    """Class to manage volume levels."""

    LOW = "low"
    MEDIUM = "medium"
    HIGH = "high"

    @classmethod
    def from_state(cls, state: int) -> VolumeLevel:
        """Build Volume level from int value."""
        return {0: cls.LOW, 1: cls.MEDIUM, 2: cls.HIGH}[state]

    @cached_property
    def state(self) -> int:
        """Get int value from value."""
        return {self.LOW: 0, self.MEDIUM: 1, self.HIGH: 2}[self]
Attributes
HIGH class-attribute instance-attribute
HIGH = 'high'
LOW class-attribute instance-attribute
LOW = 'low'
MEDIUM class-attribute instance-attribute
MEDIUM = 'medium'
state cached property
state: int

Get int value from value.

Functions
from_state classmethod
from_state(state: int) -> VolumeLevel

Build Volume level from int value.

Source code in ember_mug/consts.py
186
187
188
189
@classmethod
def from_state(cls, state: int) -> VolumeLevel:
    """Build Volume level from int value."""
    return {0: cls.LOW, 1: cls.MEDIUM, 2: cls.HIGH}[state]