Package: python-ember-mug
Python Ember MugPython Library for interacting with Ember Mugs, Cups and Travel Mugs via BluetoothDocumentation:https://sopelj.github.io/python-ember-mugGitHub:https://github.com/sopelj/python-ember-mugPyPI:https://pypi.org/project/python-ember-mug/SummaryThis is anunofficiallibrary to attempt to interact with Ember Mugs via Bluetooth.
This was created for use with myHome Assistant integration,
but could be useful separately and has a simple CLI interface too.All known Ember Mugs, Cups, Tumblers and Travel Mugs have been tested and seem to work well.
If I missed one, or you have new feature ideas or issues, pleasecreate an issue, if it isn't already there, and we'll figure it out.DeviceTestedMug✓Mug 2✓Cup✓Tumbler✓Travel Mug✓Travel Mug 2✓FeaturesFinding devicesConnecting to devicesReading/Writing most valuesPoll for changesAttributes by device:AttributeMugCupTumblerTravel MugDescriptionNameR/WN/AN/ARName to give deviceLED ColourR/WR/WR/WN/AColour of front LEDCurrent TemperatureRRRRCurrent temperature of the liquid in the mugTarget TemperatureR/WR/WR/WR/WDesired temperature for the liquidTemperature UnitR/WR/WR/WR/WInternal temperature unit for the app (C/F)Liquid LevelRRRRApproximate level of the liquid in the deviceVolume levelN/AN/AN/AR/WVolume of the button press beepBattery PercentRRRRCurrent battery levelOn ChargerRRRRDevice is on it's charger*** Writing may only work if the devices has been set up in the app previouslyUsagePythonfromember_mug.scannerimportfind_mug,discover_mugsfromember_mug.mugimportEmberMug# if first time with mug in pairingmugs=awaitdiscover_mugs()device=mugs[0]# after paired you can simply usedevice=awaitfind_mug()mug=EmberMug(device)awaitmug.update_all()print(mug.data.formatted)awaitmug.disconnect()# You can also use connection as a context manager# if you want to ensure connection before starting and cleanup on exitasyncwithmug.connection():print('Connected.\nFetching Info')awaitmug.update_all()print(mug.data.formatted)CLIIt can also be run via command line either directly withember-mug --helpor as a module withpython -m ember_mug --helpThere are four options with different subsections. You can see them by specifying them before help. egember-mug poll --helpember-mugdiscover# Finds the mug in pairing mode for the first timeember-mugpoll# fetches info and keeps listening for notificationsember-muggetnametarget-temp# Prints name and target temp of mugember-mugset--name"My mug"--target-temp56.8# Sets the name and target temp to specified valuesBasic options:CommandUsediscoverFind/List all detected unpaired devices in pairing modefindFindonealready paired devicesinfoConnect toonedevice and print its current statepollConnect toonedevice and print its current state and keep watching for changesgetGet the value(s) of one or more attribute(s) by namesetSet one or more values on the deviceCaveatsSince 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 oftenI haven't figured out some attributes like udsk, dsk, location and timezone, but they are not very useful anyway.TroubleshootingSystematic timeouts orle-connection-abort-by-localIf your mug gets stuck in a state where it refuses to connect, you get constant reconnects, timeouts, and/orle-connection-abort-by-localmessages in the debug logs, you may need to remove
your mug viabluetoothctl remove my-mac-addressand factory reset your device. It should reconnect correctly afterward.
You may also need to re-add it to the app in order to make it writable again as well.'Operation failed with ATT error: 0x0e' or another connection errorThis 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 openbluetoothctlto do so.
Please ensure the device is in pairing mode (ie the light is flashing blue or says "PAIR") and run thebluetoothctlcommand. You don't need to type anything. run it and wait until the mug connects.DevelopmentInstall:hatchpre-commitpipinstallhatch# Use CLI interfacehatchrunember-mug--help# Run Testshatchruntest:cov# View docshatchdocs:serve# Lint codepre-commitrun--all-filesCreditsThis package was created withCookiecutterand thewaynerv/cookiecutter-pypackageproject template.Notice of Non-Affiliation and DisclaimerThis 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.