Skip to main content

Python client for DayBetter devices and services

Project description

DayBetter Services Python Client

PyPI Python Versions License

Asynchronous client library used by the Home Assistant DayBetter Services integration.
It handles authentication, device discovery, status polling, PID metadata and device control against the DayBetter cloud API.

Features

  • Fully async DayBetterClient with context-manager support
  • Automatic environment selection (test/prod) based on hass_code
  • Convenience helpers for common API endpoints (devices, statuses, MQTT config)
  • Sensor-focused workflow fetch_sensor_data() that merges devices, statuses and PID filters
  • Type hints + py.typed for first-class editor / mypy support
  • Published on PyPI for Home Assistant and other integrations

Installation

pip install daybetter-services-python

Quick Start

import asyncio
from daybetter_python import DayBetterClient

async def main() -> None:
    async with DayBetterClient(token="YOUR_TOKEN", hass_code="db-xxxx") as client:
        # Fetch merged sensor payloads (used by Home Assistant)
        sensors = await client.fetch_sensor_data()
        for item in sensors:
            print(item["deviceName"], item.get("temp"), item.get("humi"))

        # Control a device (brightness example)
        await client.control_device(
            device_name="device_001",
            action=True,
            brightness=180,
        )

if __name__ == "__main__":
    asyncio.run(main())

Home Assistant Integration

The official integration PR can be followed here: home-assistant/core#154677.
The integration imports this library and simply calls client.fetch_sensor_data() inside a data coordinator, so all business logic lives in this package.

See docs/homeassistant.md for:

  • Installation instructions (pip, custom component)
  • How to obtain the DayBetter token and hass_code
  • Sample configuration.yaml snippets
  • Known limitations and future roadmap

Development

git clone https://github.com/THDayBetter/daybetter-services-python.git
cd daybetter-services-python
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]

# Quality checks
flake8 daybetter_python
mypy daybetter_python
pytest

Pull requests are welcome! Please open an issue if you encounter problems with the DayBetter cloud API.

Release Process

  1. Update pyproject.toml and daybetter_python/__init__.py with the new version.
  2. Document changes in CHANGELOG.md.
  3. Build and upload:
    rm -rf dist build *.egg-info
    python -m build
    twine check dist/*
    twine upload dist/*
    
  4. Create a Git tag (e.g., git tag v1.0.7 && git push origin v1.0.7).

License

This project is licensed under the MIT License.

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

daybetter_services_python-1.0.9.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

daybetter_services_python-1.0.9-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file daybetter_services_python-1.0.9.tar.gz.

File metadata

File hashes

Hashes for daybetter_services_python-1.0.9.tar.gz
Algorithm Hash digest
SHA256 f5fd4effa851b9967933fb9f6383795f13991c48e7aaff48dc224bd2bce07c35
MD5 4f208382515b839012b8b2d341c246d8
BLAKE2b-256 6a68adaa7705c49074be1b53f0d9ccc3f9211370829a933882e4fcec10246151

See more details on using hashes here.

Provenance

The following attestation bundles were made for daybetter_services_python-1.0.9.tar.gz:

Publisher: publish-pypi.yml on THDayBetter/daybetter-services-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file daybetter_services_python-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for daybetter_services_python-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 40fe835aea8c559a931f00654bbde4a2193fe05f4e97ab5d98aafe9d8e927055
MD5 e05b2f98bc3aaba29e99776a9c7df4da
BLAKE2b-256 69efe2e38b99feb0d4de21eb57f268c22511de9e51e932f31f2ef9d9dcaab6e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for daybetter_services_python-1.0.9-py3-none-any.whl:

Publisher: publish-pypi.yml on THDayBetter/daybetter-services-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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