python-bsblan


Namepython-bsblan JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/liudger/python-bsblan
SummaryAsynchronous Python client for BSBLAN API
upload_time2024-11-01 19:35:24
maintainerWillem-Jan van Rootselaar
docs_urlNone
authorWillem-Jan van Rootselaar
requires_python<4.0,>=3.11
licenseMIT
keywords bsblan thermostat client api async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python: BSBLan API Client

[![GitHub Release][releases-shield]][releases]
[![Python Versions][python-versions-shield]][pypi]
![Project Stage][project-stage-shield]
![Project Maintenance][maintenance-shield]
[![License][license-shield]](.github/LICENSE.md)

[![Build Status][build-shield]][build]
[![Code Coverage][codecov-shield]][codecov]
[![Quality Gate Status][sonarcloud-shield]][sonarcloud]

[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]

Asynchronous Python client for BSBLan.

## About

This package allows you to control and monitor an BSBLan device
programmatically. It is mainly created to allow third-party programs to automate
the behavior of [BSBLan][bsblanmodule].

## Installation

```bash
pip install python-bsblan
```

## Usage

```python
# pylint: disable=W0621
"""Asynchronous Python client for BSBLan."""

import asyncio
import os

from bsblan import BSBLAN, BSBLANConfig, Device, Info, Sensor, State, StaticState


async def print_state(state: State) -> None:
    """Print the current state of the BSBLan device."""
    print(f"HVAC Action: {state.hvac_action.desc}")
    print(f"HVAC Mode: {state.hvac_mode.desc}")
    print(f"Current Temperature: {state.current_temperature.value}")


async def print_sensor(sensor: Sensor) -> None:
    """Print sensor information from the BSBLan device."""
    print(f"Outside Temperature: {sensor.outside_temperature.value}")


async def print_device_info(device: Device, info: Info) -> None:
    """Print device and general information."""
    print(f"Device Name: {device.name}")
    print(f"Version: {device.version}")
    print(f"Device Identification: {info.device_identification.value}")


async def print_static_state(static_state: StaticState) -> None:
    """Print static state information."""
    print(f"Min Temperature: {static_state.min_temp.value}")
    print(f"Max Temperature: {static_state.max_temp.value}")


async def main() -> None:
    """Show example on controlling your BSBLan device.

    Options:
    - passkey (http://url/"passkey"/) if your device is setup for passkey authentication
    - username and password if your device is setup for username/password authentication

    """
    # Create a configuration object
    config = BSBLANConfig(
        host="10.0.2.60",
        passkey=None,
        username=os.getenv("USERNAME"),  # Compliant
        password=os.getenv("PASSWORD"),  # Compliant
    )

    # Initialize BSBLAN with the configuration object
    async with BSBLAN(config) as bsblan:
        # Get and print state
        state: State = await bsblan.state()
        await print_state(state)

        # Set thermostat temperature
        print("\nSetting temperature to 18°C")
        await bsblan.thermostat(target_temperature="18")

        # Set HVAC mode
        print("Setting HVAC mode to heat")
        await bsblan.thermostat(hvac_mode="heat")

        # Get and print sensor information
        sensor: Sensor = await bsblan.sensor()
        await print_sensor(sensor)

        # Get and print device and general info
        device: Device = await bsblan.device()
        info: Info = await bsblan.info()
        await print_device_info(device, info)

        # Get and print static state
        static_state: StaticState = await bsblan.static_values()
        await print_static_state(static_state)


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

## Changelog & Releases

This repository keeps a change log using [GitHub's releases][releases]
functionality. The format of the log is based on
[Keep a Changelog][keepchangelog].

Releases are based on [Semantic Versioning][semver], and use the format
of `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented
based on the following:

- `MAJOR`: Incompatible or major changes.
- `MINOR`: Backwards-compatible new features and enhancements.
- `PATCH`: Backwards-compatible bugfixes and package updates.

## Contributing

This is an active open-source project. We are always open to people who want to
use the code or contribute to it.

We've set up a separate document for our
[contribution guidelines](CONTRIBUTING.md).

Thank you for being involved! :heart_eyes:

## Setting up development environment

This Python project is fully managed using the [Poetry][poetry] dependency manager. But also relies on the use of NodeJS for certain checks during development.

You need at least:

- Python 3.12+
- [Poetry][poetry-install]
- NodeJS 16+ (including NPM)

To install all packages, including all development requirements:

```bash
npm install
poetry install
```

As this repository uses the [pre-commit][pre-commit] framework, all changes
are linted and tested with each commit. You can run all checks and tests
manually, using the following command:

```bash
poetry run pre-commit run --all-files
```

To run just the Python tests:

```bash
poetry run pytest
```

## Authors & contributors

The template is from the repository 'elgato' by [Franck Nijhof][frenck].
The setup of this repository is by [Willem-Jan van Rootselaar][liudger].

For a full list of all authors and contributors,
check [the contributor's page][contributors].

## License

MIT License

Copyright (c) 2023-2024 WJ van Rootselaar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[bsblanmodule]: https://github.com/fredlcore/bsb_lan
[build-shield]: https://github.com/liudger/python-bsblan/actions/workflows/tests.yaml/badge.svg
[build]: https://github.com/liudger/python-bsblan/actions
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
[buymeacoffee]: https://www.buymeacoffee.com/liudger
[codecov-shield]: https://codecov.io/gh/liudger/python-bsblan/branch/Dev/graph/badge.svg?token=ypos87GGxv
[codecov]: https://codecov.io/gh/liudger/python-bsblan
[contributors]: https://github.com/liudger/python-bsblan/graphs/contributors
[frenck]: https://github.com/frenck
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
[license-shield]: https://img.shields.io/badge/license-MIT-blue.svg
[liudger]: https://github.com/liudger
[maintenance-shield]: https://img.shields.io/maintenance/yes/2024.svg
[poetry]: https://python-poetry.org
[poetry-install]: https://python-poetry.org/docs/#installation
[pre-commit]: https://pre-commit.com/
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[pypi]: https://pypi.org/project/python-bsblan/
[python-versions-shield]: https://img.shields.io/pypi/pyversions/python-bsblan
[releases-shield]: https://img.shields.io/github/v/release/liudger/python-bsblan.svg
[releases]: https://github.com/liudger/python-bsblan/releases
[semver]: http://semver.org/spec/v2.0.0.html
[sonarcloud-shield]: https://sonarcloud.io/api/project_badges/measure?project=liudger_python-bsblan&metric=alert_status
[sonarcloud]: https://sonarcloud.io/summary/new_code?id=liudger_python-bsblan


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/liudger/python-bsblan",
    "name": "python-bsblan",
    "maintainer": "Willem-Jan van Rootselaar",
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": "liudgervr@gmail.com",
    "keywords": "bsblan, thermostat, client, api, async",
    "author": "Willem-Jan van Rootselaar",
    "author_email": "liudgervr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/34/4b/7da570332abb7f0bd4e017e08796cdb67dde6e9dcde2c3a2a2b44870a4be/python_bsblan-1.2.1.tar.gz",
    "platform": null,
    "description": "# Python: BSBLan API Client\n\n[![GitHub Release][releases-shield]][releases]\n[![Python Versions][python-versions-shield]][pypi]\n![Project Stage][project-stage-shield]\n![Project Maintenance][maintenance-shield]\n[![License][license-shield]](.github/LICENSE.md)\n\n[![Build Status][build-shield]][build]\n[![Code Coverage][codecov-shield]][codecov]\n[![Quality Gate Status][sonarcloud-shield]][sonarcloud]\n\n[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]\n\nAsynchronous Python client for BSBLan.\n\n## About\n\nThis package allows you to control and monitor an BSBLan device\nprogrammatically. It is mainly created to allow third-party programs to automate\nthe behavior of [BSBLan][bsblanmodule].\n\n## Installation\n\n```bash\npip install python-bsblan\n```\n\n## Usage\n\n```python\n# pylint: disable=W0621\n\"\"\"Asynchronous Python client for BSBLan.\"\"\"\n\nimport asyncio\nimport os\n\nfrom bsblan import BSBLAN, BSBLANConfig, Device, Info, Sensor, State, StaticState\n\n\nasync def print_state(state: State) -> None:\n    \"\"\"Print the current state of the BSBLan device.\"\"\"\n    print(f\"HVAC Action: {state.hvac_action.desc}\")\n    print(f\"HVAC Mode: {state.hvac_mode.desc}\")\n    print(f\"Current Temperature: {state.current_temperature.value}\")\n\n\nasync def print_sensor(sensor: Sensor) -> None:\n    \"\"\"Print sensor information from the BSBLan device.\"\"\"\n    print(f\"Outside Temperature: {sensor.outside_temperature.value}\")\n\n\nasync def print_device_info(device: Device, info: Info) -> None:\n    \"\"\"Print device and general information.\"\"\"\n    print(f\"Device Name: {device.name}\")\n    print(f\"Version: {device.version}\")\n    print(f\"Device Identification: {info.device_identification.value}\")\n\n\nasync def print_static_state(static_state: StaticState) -> None:\n    \"\"\"Print static state information.\"\"\"\n    print(f\"Min Temperature: {static_state.min_temp.value}\")\n    print(f\"Max Temperature: {static_state.max_temp.value}\")\n\n\nasync def main() -> None:\n    \"\"\"Show example on controlling your BSBLan device.\n\n    Options:\n    - passkey (http://url/\"passkey\"/) if your device is setup for passkey authentication\n    - username and password if your device is setup for username/password authentication\n\n    \"\"\"\n    # Create a configuration object\n    config = BSBLANConfig(\n        host=\"10.0.2.60\",\n        passkey=None,\n        username=os.getenv(\"USERNAME\"),  # Compliant\n        password=os.getenv(\"PASSWORD\"),  # Compliant\n    )\n\n    # Initialize BSBLAN with the configuration object\n    async with BSBLAN(config) as bsblan:\n        # Get and print state\n        state: State = await bsblan.state()\n        await print_state(state)\n\n        # Set thermostat temperature\n        print(\"\\nSetting temperature to 18\u00b0C\")\n        await bsblan.thermostat(target_temperature=\"18\")\n\n        # Set HVAC mode\n        print(\"Setting HVAC mode to heat\")\n        await bsblan.thermostat(hvac_mode=\"heat\")\n\n        # Get and print sensor information\n        sensor: Sensor = await bsblan.sensor()\n        await print_sensor(sensor)\n\n        # Get and print device and general info\n        device: Device = await bsblan.device()\n        info: Info = await bsblan.info()\n        await print_device_info(device, info)\n\n        # Get and print static state\n        static_state: StaticState = await bsblan.static_values()\n        await print_static_state(static_state)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Changelog & Releases\n\nThis repository keeps a change log using [GitHub's releases][releases]\nfunctionality. The format of the log is based on\n[Keep a Changelog][keepchangelog].\n\nReleases are based on [Semantic Versioning][semver], and use the format\nof `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented\nbased on the following:\n\n- `MAJOR`: Incompatible or major changes.\n- `MINOR`: Backwards-compatible new features and enhancements.\n- `PATCH`: Backwards-compatible bugfixes and package updates.\n\n## Contributing\n\nThis is an active open-source project. We are always open to people who want to\nuse the code or contribute to it.\n\nWe've set up a separate document for our\n[contribution guidelines](CONTRIBUTING.md).\n\nThank you for being involved! :heart_eyes:\n\n## Setting up development environment\n\nThis Python project is fully managed using the [Poetry][poetry] dependency manager. But also relies on the use of NodeJS for certain checks during development.\n\nYou need at least:\n\n- Python 3.12+\n- [Poetry][poetry-install]\n- NodeJS 16+ (including NPM)\n\nTo install all packages, including all development requirements:\n\n```bash\nnpm install\npoetry install\n```\n\nAs this repository uses the [pre-commit][pre-commit] framework, all changes\nare linted and tested with each commit. You can run all checks and tests\nmanually, using the following command:\n\n```bash\npoetry run pre-commit run --all-files\n```\n\nTo run just the Python tests:\n\n```bash\npoetry run pytest\n```\n\n## Authors & contributors\n\nThe template is from the repository 'elgato' by [Franck Nijhof][frenck].\nThe setup of this repository is by [Willem-Jan van Rootselaar][liudger].\n\nFor a full list of all authors and contributors,\ncheck [the contributor's page][contributors].\n\n## License\n\nMIT License\n\nCopyright (c) 2023-2024 WJ van Rootselaar\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n[bsblanmodule]: https://github.com/fredlcore/bsb_lan\n[build-shield]: https://github.com/liudger/python-bsblan/actions/workflows/tests.yaml/badge.svg\n[build]: https://github.com/liudger/python-bsblan/actions\n[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg\n[buymeacoffee]: https://www.buymeacoffee.com/liudger\n[codecov-shield]: https://codecov.io/gh/liudger/python-bsblan/branch/Dev/graph/badge.svg?token=ypos87GGxv\n[codecov]: https://codecov.io/gh/liudger/python-bsblan\n[contributors]: https://github.com/liudger/python-bsblan/graphs/contributors\n[frenck]: https://github.com/frenck\n[keepchangelog]: http://keepachangelog.com/en/1.0.0/\n[license-shield]: https://img.shields.io/badge/license-MIT-blue.svg\n[liudger]: https://github.com/liudger\n[maintenance-shield]: https://img.shields.io/maintenance/yes/2024.svg\n[poetry]: https://python-poetry.org\n[poetry-install]: https://python-poetry.org/docs/#installation\n[pre-commit]: https://pre-commit.com/\n[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg\n[pypi]: https://pypi.org/project/python-bsblan/\n[python-versions-shield]: https://img.shields.io/pypi/pyversions/python-bsblan\n[releases-shield]: https://img.shields.io/github/v/release/liudger/python-bsblan.svg\n[releases]: https://github.com/liudger/python-bsblan/releases\n[semver]: http://semver.org/spec/v2.0.0.html\n[sonarcloud-shield]: https://sonarcloud.io/api/project_badges/measure?project=liudger_python-bsblan&metric=alert_status\n[sonarcloud]: https://sonarcloud.io/summary/new_code?id=liudger_python-bsblan\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Asynchronous Python client for BSBLAN API",
    "version": "1.2.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/liudger/python-bsblan/issues",
        "Changelog": "https://github.com/liudger/python-bsblan/releases",
        "Documentation": "https://github.com/liudger/python-bsblan",
        "Homepage": "https://github.com/liudger/python-bsblan",
        "Repository": "https://github.com/liudger/python-bsblan"
    },
    "split_keywords": [
        "bsblan",
        " thermostat",
        " client",
        " api",
        " async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d586d27c26f583b2c884eea162d84dbc929490c17e9f4540b6070afffdd5cb1",
                "md5": "2fdf495b6612c4ce41ddcc9bd0957bd8",
                "sha256": "af76a7c7e8e88d689180e3ec5a8fcdfd7c6f99e6c586f411827a5d72898ecbff"
            },
            "downloads": -1,
            "filename": "python_bsblan-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fdf495b6612c4ce41ddcc9bd0957bd8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 14707,
            "upload_time": "2024-11-01T19:35:22",
            "upload_time_iso_8601": "2024-11-01T19:35:22.706449Z",
            "url": "https://files.pythonhosted.org/packages/5d/58/6d27c26f583b2c884eea162d84dbc929490c17e9f4540b6070afffdd5cb1/python_bsblan-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "344b7da570332abb7f0bd4e017e08796cdb67dde6e9dcde2c3a2a2b44870a4be",
                "md5": "75517951edd0ecc7cd423b4267ff509b",
                "sha256": "ddd9303233eee9229df7fc5bd2cd6bf534151d217f4cf51ca1bd0293da75a3c5"
            },
            "downloads": -1,
            "filename": "python_bsblan-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "75517951edd0ecc7cd423b4267ff509b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 16922,
            "upload_time": "2024-11-01T19:35:24",
            "upload_time_iso_8601": "2024-11-01T19:35:24.484182Z",
            "url": "https://files.pythonhosted.org/packages/34/4b/7da570332abb7f0bd4e017e08796cdb67dde6e9dcde2c3a2a2b44870a4be/python_bsblan-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-01 19:35:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "liudger",
    "github_project": "python-bsblan",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "python-bsblan"
}
        
Elapsed time: 1.05307s