Skip to main content

Python Library for Ember Mugs.

Project description

Python Ember Mug

pypi python Build Status codecov Project Maintenance Maintainer License pre-commit

Python Library for interacting with Ember Mugs, Cups and Travel Mugs via Bluetooth

Summary

This is an unofficial library to attempt to interact with Ember Mugs via Bluetooth. This was created for use with my Home Assistant integration, but could be useful separately and has a simple CLI interface too.

Device Tested
Mug
Mug 2
Cup
Travel Mug
Travel Mug 2

Features

  • Finding devices
  • Connecting to devices
  • Reading/Writing most values
  • Poll for changes

Attributes by device:

Attribute Mug Cup Travel Mug Description
Name R/W N/A R Name to give device
LED Colour R/W R/W N/A Colour of front LED
Current Temperature R R R Current temperature of the liquid in the mug
Target Temperature R/W R/W R/W Desired temperature for the liquid
Temperature Unit R/W R/W R/W Internal temperature unit for the app (C/F)
Liquid Level R R R Approximate level of the liquid in the device
Volume level N/A N/A R/W Volume of the button press beep
Battery Percent R R R Current battery level
On Charger R R R Device is on it's charger

*** Writing may only work if the devices has been set up in the app previously

Usage

Python

from ember_mug.scanner import find_mug, discover_mugs
from ember_mug.mug import EmberMug

# if first time with mug in pairing
mugs = await discover_mugs()
device = mugs[0]
# after paired you can simply use
device = await find_mug()
mug = EmberMug(device)
await mug.update_all()
print(mug.data.formatted)
await mug.disconnect()

# You can also use connection as a context manager
# if you want to ensure connection before starting and cleanup on exit
async with mug.connection():
    print('Connected.\nFetching Info')
    await mug.update_all()
    print(mug.data.formatted)

CLI

It can also be run via command line either directly with ember-mug --help or as a module with python -m ember_mug --help There are four options with different subsections. You can see them by specifying them before help. eg ember-mug poll --help

ember-mug discover  # Finds the mug in pairing mode for the first time
ember-mug poll  # fetches info and keeps listening for notifications
ember-mug get name target-temp  # Prints name and target temp of mug
ember-mug set --name "My mug" --target-temp 56.8  # Sets the name and target temp to specified values

Basic options:

Command Use
discover Find/List all detected unpaired devices in pairing mode
find Find one already paired devices
info Connect to one device and print its current state
poll Connect to one device and print its current state and keep watching for changes
get Get the value(s) of one or more attribute(s) by name
set Set one or more values on the device

CLI Example

Caveats

  • Since this api is not public, a lot of guesswork and reverse engineering is involved, so it's not perfect.
  • If the device has not been set up in the app since it was reset, writing is not allowed. I don't know what they set in the app, but it changes something, and it doesn't work without it.
  • Once that device has been set up in the app, you should ideally forget the device or at least turn off bluetooth whilst using it here, or you will probably get disconnected often
  • I haven't figured out some attributes like udsk, dsk, location and timezone, but they are not very useful anyway.

Troubleshooting

'Operation failed with ATT error: 0x0e' or another connection error

This seems to be caused by the bluetooth adaptor being in some sort of passive mode. I have not yet figured out how to wake it programmatically so sadly, you need to manually open bluetoothctl to do so. Please ensure the device is in pairing mode (ie the light is flashing blue or says "PAIR") and run the bluetoothctl command. You don't need to type anything. run it and wait until the mug connects.

Development

Install:

pip install hatch
# Use CLI interface
hatch run ember-mug --help
# Run Tests
hatch run test:cov
# View docs
hatch docs:serve
# Lint code
pre-commit run --all-files

Credits

This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.

Notice of Non-Affiliation and Disclaimer

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Ember.

The name Ember as well as related names, marks, emblems and images are registered trademarks of their respective owners.

Project details


Release history Release notifications | RSS feed

This version

0.8.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_ember_mug-0.8.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

python_ember_mug-0.8.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file python_ember_mug-0.8.0.tar.gz.

File metadata

  • Download URL: python_ember_mug-0.8.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for python_ember_mug-0.8.0.tar.gz
Algorithm Hash digest
SHA256 2f403f4059a60e27b0c1c763ec7cb7a5336dd26ca74a91080af8096481943389
MD5 f288e7e5c1ca568c40aedd57b83dd945
BLAKE2b-256 4f29d39ea5a95ad21e5301c1152a3e9441f941051299fd14d1578982f1ad36d6

See more details on using hashes here.

File details

Details for the file python_ember_mug-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_ember_mug-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61d2d8a4b4a8cca34600fa85ced48dfadaa98c5d6700a1a0846e89f5fcb8df6f
MD5 1e475e40f8d35acf7682cc73effd1719
BLAKE2b-256 66b8ab92a8819143e5da8849d428e93070fdff871ec9b245e09903e5f50aa96a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page