Skip to main content

A Bluetooth scale integration for coffee machines

Project description

pyfelicita

Package for integrating a Felicita scale to your python project

Example code:

import asyncio
from pyfelicita import Felicita

async def main():
    addresses = await Felicita.find_felicita_devices()
    
    if not addresses:
        print("No devices found")
        return
        
    address = addresses[0]
    
    client = await Felicita.create(address)
        
    if not client:
        print("Failed to connect to the scale")
        return
    
    try:
        await client.set_weight_and_timer_mode()
        await asyncio.sleep(0.1)
        await client.tare()
        await asyncio.sleep(0.1)
        await client.reset_timer()
        await asyncio.sleep(0.1)
        await client.start_timer()
        
        while client.is_connected():
            await asyncio.sleep(0.1)
            print(
                f"Weight: {client.current_weight} {client.current_scale_unit}, "
                f"Battery: {client.current_battery_level:.2f}%"
            )
            
            if(client.is_timer_running):
                print(f"Time elapsed: {client.timer_time_elapsed}")
                
            if(client.current_weight > 69):
                await client.stop_timer()
                print("Criteria met, stopping program")
                break
                    
    finally:
        if client.is_connected():
            await client.disconnect()
        else:
            print("Scale stopped responding")

asyncio.run(main())

Project details


Download files

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

Source Distribution

pyfelicita-0.1.14.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfelicita-0.1.14-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfelicita-0.1.14.tar.gz.

File metadata

  • Download URL: pyfelicita-0.1.14.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.11

File hashes

Hashes for pyfelicita-0.1.14.tar.gz
Algorithm Hash digest
SHA256 2baa81343957d05a2a4c7ff81a19e521d127bf9c597be0d4cc59ecd03c8ffd1e
MD5 0f1823965a264a8012f25de8faac8af6
BLAKE2b-256 9d64b04a77d32dce6afae2a7a41c7b33fc7352c9f616d4aa9852701ebc5ba0d1

See more details on using hashes here.

File details

Details for the file pyfelicita-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: pyfelicita-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.11

File hashes

Hashes for pyfelicita-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 e39d5cf94ab2e46fdf80d3a7248cb12e317544d642978884cad8e9221457fee4
MD5 4c88e150ba3327400c32e06fc6af72d2
BLAKE2b-256 e95153d1dbd9ade8c265856c19f6d107e7a58560f788b6e25e15014af12268cd

See more details on using hashes here.

Supported by

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