Skip to main content

Python Library for Ember Mugs.

Project description

Python Ember Mug

pypi python Build Status codecov

Python Library for Ember Mugs

Summary

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

Note: I have only tested with my Ember Mug 2, but others should work. (Please let me know)

Features

  • Finding mugs
  • Connecting to Mugs
  • Reading Information (Colour, temp, liquid level, etc.)
  • Writing (Desired temp, colour, temperature unit)*
  • Polling for changes

*** Writing only works if the mug 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)
async with mug.connection() as con:
    print('Connected.\nFetching Info')
    await con.update_all()
    print(mug.formatted_data)

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 mugs in pairing mode
find Find one already paired mugs
info Connect to one mug and print its current state
poll Connect to one mug 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 mug

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 mug 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 mug 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,

Todo

  • Add cli interface for setting values
  • Test with other devices. Please let me know if you have tried it with others.

Credits

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

Project details


Release history Release notifications | RSS feed

This version

0.4.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.4.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

python_ember_mug-0.4.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_ember_mug-0.4.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for python_ember_mug-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7fdd3796fa4977cbe9a10c2210cd449df1de6346ccdd2804ce62fdb10fec02da
MD5 079c848075a2d670f5baf545dce6afd3
BLAKE2b-256 751aaef4b08b12dd399d3d49f046f07f45a826519765979897350bf3211b09c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_ember_mug-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f6485872f62baf717829219f5c037f1cfb6d7e810f1b32112bcbcbda8a710e5
MD5 2a982207c780ddaab2cbce9ce28ecd1f
BLAKE2b-256 f7859162b8c293382897fcaa1657a207971137ac1c1ff861a6382e5bc58ccc8e

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