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.12.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pyfelicita-0.1.12.tar.gz
Algorithm Hash digest
SHA256 372823cc095ae0ad29298abdc67583e0a870a92c11c23eeddc4136779ae42bc1
MD5 c1f4d3c026d47528b8dbe48577866538
BLAKE2b-256 e44bca86b9c567dde3df5c872ff9cbb1574c6fc68e56b225884b66e889898e12

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