async-somecomfort


Nameasync-somecomfort JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/yourusername/async-somecomfort
SummaryPython client for interacting with Honeywell Total Connect Comfort (TCC) API
upload_time2024-10-09 01:27:58
maintainerNone
docs_urlNone
authorYour Name
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# SomeComfort API Client

This module provides a Python client for interacting with Honeywell's Total Connect Comfort (TCC) API. It allows you to log in to the Honeywell TCC portal, retrieve and update thermostat data, and manage thermostat settings.

Based on the work kk7ds: https://github.com/kk7ds/somecomfort

## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
  - [Session Management](#session-management)
  - [Fetching Locations](#fetching-locations)
  - [Fetching Thermostat Data](#fetching-thermostat-data)
  - [Setting Thermostat Settings](#setting-thermostat-settings)
- [Exception Handling](#exception-handling)
- [Contributing](#contributing)
- [License](#license)

## Features
- Log in to the Honeywell TCC portal and manage session cookies
- Retrieve thermostat data and associated devices
- Update thermostat settings (system mode, temperature setpoints, etc.)
- Handle session timeouts and automatic re-login
- Handle API rate limits

## Installation

You can install the module by cloning the repository and installing the necessary dependencies.

```bash
git clone https://github.com/your-repo/somecomfort-client
cd somecomfort-client
pip install -r requirements.txt
Usage
Session Management
The Session class manages login, cookies, and communication with the Honeywell TCC API. You can use it as a context manager to ensure that resources are properly managed.
python
from somecomfort import Session

async with Session('your_username', 'your_password') as session:
    # Now you are logged in, and can make API requests
    locations = await session.get_locations()
    print(locations)
Fetching Locations
You can fetch the list of locations (and associated thermostats) for the current account using the get_locations() method.
python
locations = await session.get_locations()
print(f"Fetched {len(locations)} locations.")
Fetching Thermostat Data
To retrieve data for a specific thermostat, use the get_thermostat_data() method by passing the thermostat ID.
python
thermostat_id = '123456'
thermostat_data = await session.get_thermostat_data(thermostat_id)
print(thermostat_data)
Setting Thermostat Settings
You can update the thermostat's settings (such as system mode, heat or cool setpoints) using the set_thermostat_settings() method.
python
settings = {
    'SystemSwitch': 1,  # 1 = Heat, 2 = Cool, 3 = Off, etc.
    'HeatSetpoint': 70,
    'CoolSetpoint': 75
}
await session.set_thermostat_settings('123456', settings)
Exception Handling
This module defines several custom exceptions to handle specific error conditions:
•	AuthError: Raised for authentication failures.
•	APIError: Raised when there are issues communicating with the API.
•	SessionTimedOut: Raised when the session has expired and needs to be refreshed.
•	APIRateLimited: Raised when the API rate limit is exceeded.
Example:
python
try:
    locations = await session.get_locations()
except AuthError:
    print("Login failed! Check your credentials.")
except APIError as e:
    print(f"API error: {str(e)}")
Contributing
Contributions are welcome! If you'd like to contribute, please fork the repository, create a feature branch, and submit a pull request.
1.	Fork the repo
2.	Create a feature branch (git checkout -b feature/your-feature)
3.	Commit your changes (git commit -am 'Add new feature')
4.	Push to the branch (git push origin feature/your-feature)
5.	Create a pull request
Please ensure that your code passes all linting and tests before submitting a PR.
License
This project is licensed under the MIT License. See the LICENSE file for more details.

API Documentation
This section provides an overview of the key classes and methods in this module. Detailed docstrings are available within the code for each class and method.
Session Class
The Session class is responsible for managing the connection to the Honeywell TCC API, logging in, handling cookies, and fetching/updating thermostat data.
Methods
•	__aenter__() and __aexit__(): These asynchronous methods enable context management, ensuring the session is properly opened and closed.
•	login(): Logs in to the Honeywell TCC portal.
•	keepalive(): Ensures the session remains active by refreshing it.
•	get_locations(): Fetches a list of locations associated with the user account.
•	get_thermostat_data(thermostat_id): Fetches data for a specific thermostat.
•	set_thermostat_settings(thermostat_id, settings): Updates the settings of a thermostat.
•	close(): Closes the session and releases resources.
Example Usage:
python
async with Session('username', 'password') as session:
    locations = await session.get_locations()
    print(locations)
Device Class
The Device class represents individual thermostat devices within a location. It allows you to retrieve device status and update configurations.
Methods
•	refresh(): Refreshes the device data.
•	set_fan_mode(): Sets the fan mode (auto, on, circulate).
•	set_system_mode(): Sets the system mode (heat, cool, off).
•	set_setpoint_cool(temp): Sets the cool setpoint temperature.
•	set_setpoint_heat(temp): Sets the heat setpoint temperature.
Example:
python
device = await session.get_device('123456')
await device.set_setpoint_cool(75)
await device.set_system_mode('cool')

Exception Handling in Detail
This module contains custom exceptions that are used throughout the codebase. Each of these exceptions inherits from SomeComfortError, the base exception class.
Exceptions
•	SomeComfortError: The base exception class for all exceptions in this module.
•	AuthError: Raised when authentication fails (e.g., incorrect username/password).
•	APIError: Raised when the API returns an unexpected response or an error status.
•	SessionTimedOut: Raised when the session has timed out and must be renewed.
•	APIRateLimited: Raised when the API rate limit has been exceeded.

License
MIT License. See LICENSE for more information.


### How to Use:
- **README.md**: This entire file content can be saved as `README.md` and placed in the root directory of your project repository.
- **Additional Files**:
  - **LICENSE**: Ensure you have a `LICENSE` file that corresponds to the MIT License if you're using that.
  - **Detailed Documentation**: You can further elaborate on each class and method in a separate API documentation if needed (e.g., using Sphinx for Python docs).

Let me know if you need further adjustments or more sections added!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yourusername/async-somecomfort",
    "name": "async-somecomfort",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "your.email@example.com",
    "download_url": "https://files.pythonhosted.org/packages/08/08/5e2dccc5af525d373c18297f8001db8760335e634ce8b5bb142b88b6d433/async_somecomfort-1.0.0.tar.gz",
    "platform": null,
    "description": "\r\n# SomeComfort API Client\r\n\r\nThis module provides a Python client for interacting with Honeywell's Total Connect Comfort (TCC) API. It allows you to log in to the Honeywell TCC portal, retrieve and update thermostat data, and manage thermostat settings.\r\n\r\nBased on the work kk7ds: https://github.com/kk7ds/somecomfort\r\n\r\n## Table of Contents\r\n- [Features](#features)\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Session Management](#session-management)\r\n  - [Fetching Locations](#fetching-locations)\r\n  - [Fetching Thermostat Data](#fetching-thermostat-data)\r\n  - [Setting Thermostat Settings](#setting-thermostat-settings)\r\n- [Exception Handling](#exception-handling)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n## Features\r\n- Log in to the Honeywell TCC portal and manage session cookies\r\n- Retrieve thermostat data and associated devices\r\n- Update thermostat settings (system mode, temperature setpoints, etc.)\r\n- Handle session timeouts and automatic re-login\r\n- Handle API rate limits\r\n\r\n## Installation\r\n\r\nYou can install the module by cloning the repository and installing the necessary dependencies.\r\n\r\n```bash\r\ngit clone https://github.com/your-repo/somecomfort-client\r\ncd somecomfort-client\r\npip install -r requirements.txt\r\nUsage\r\nSession Management\r\nThe Session class manages login, cookies, and communication with the Honeywell TCC API. You can use it as a context manager to ensure that resources are properly managed.\r\npython\r\nfrom somecomfort import Session\r\n\r\nasync with Session('your_username', 'your_password') as session:\r\n    # Now you are logged in, and can make API requests\r\n    locations = await session.get_locations()\r\n    print(locations)\r\nFetching Locations\r\nYou can fetch the list of locations (and associated thermostats) for the current account using the get_locations() method.\r\npython\r\nlocations = await session.get_locations()\r\nprint(f\"Fetched {len(locations)} locations.\")\r\nFetching Thermostat Data\r\nTo retrieve data for a specific thermostat, use the get_thermostat_data() method by passing the thermostat ID.\r\npython\r\nthermostat_id = '123456'\r\nthermostat_data = await session.get_thermostat_data(thermostat_id)\r\nprint(thermostat_data)\r\nSetting Thermostat Settings\r\nYou can update the thermostat's settings (such as system mode, heat or cool setpoints) using the set_thermostat_settings() method.\r\npython\r\nsettings = {\r\n    'SystemSwitch': 1,  # 1 = Heat, 2 = Cool, 3 = Off, etc.\r\n    'HeatSetpoint': 70,\r\n    'CoolSetpoint': 75\r\n}\r\nawait session.set_thermostat_settings('123456', settings)\r\nException Handling\r\nThis module defines several custom exceptions to handle specific error conditions:\r\n\u00e2\u20ac\u00a2\tAuthError: Raised for authentication failures.\r\n\u00e2\u20ac\u00a2\tAPIError: Raised when there are issues communicating with the API.\r\n\u00e2\u20ac\u00a2\tSessionTimedOut: Raised when the session has expired and needs to be refreshed.\r\n\u00e2\u20ac\u00a2\tAPIRateLimited: Raised when the API rate limit is exceeded.\r\nExample:\r\npython\r\ntry:\r\n    locations = await session.get_locations()\r\nexcept AuthError:\r\n    print(\"Login failed! Check your credentials.\")\r\nexcept APIError as e:\r\n    print(f\"API error: {str(e)}\")\r\nContributing\r\nContributions are welcome! If you'd like to contribute, please fork the repository, create a feature branch, and submit a pull request.\r\n1.\tFork the repo\r\n2.\tCreate a feature branch (git checkout -b feature/your-feature)\r\n3.\tCommit your changes (git commit -am 'Add new feature')\r\n4.\tPush to the branch (git push origin feature/your-feature)\r\n5.\tCreate a pull request\r\nPlease ensure that your code passes all linting and tests before submitting a PR.\r\nLicense\r\nThis project is licensed under the MIT License. See the LICENSE file for more details.\r\n\r\nAPI Documentation\r\nThis section provides an overview of the key classes and methods in this module. Detailed docstrings are available within the code for each class and method.\r\nSession Class\r\nThe Session class is responsible for managing the connection to the Honeywell TCC API, logging in, handling cookies, and fetching/updating thermostat data.\r\nMethods\r\n\u00e2\u20ac\u00a2\t__aenter__() and __aexit__(): These asynchronous methods enable context management, ensuring the session is properly opened and closed.\r\n\u00e2\u20ac\u00a2\tlogin(): Logs in to the Honeywell TCC portal.\r\n\u00e2\u20ac\u00a2\tkeepalive(): Ensures the session remains active by refreshing it.\r\n\u00e2\u20ac\u00a2\tget_locations(): Fetches a list of locations associated with the user account.\r\n\u00e2\u20ac\u00a2\tget_thermostat_data(thermostat_id): Fetches data for a specific thermostat.\r\n\u00e2\u20ac\u00a2\tset_thermostat_settings(thermostat_id, settings): Updates the settings of a thermostat.\r\n\u00e2\u20ac\u00a2\tclose(): Closes the session and releases resources.\r\nExample Usage:\r\npython\r\nasync with Session('username', 'password') as session:\r\n    locations = await session.get_locations()\r\n    print(locations)\r\nDevice Class\r\nThe Device class represents individual thermostat devices within a location. It allows you to retrieve device status and update configurations.\r\nMethods\r\n\u00e2\u20ac\u00a2\trefresh(): Refreshes the device data.\r\n\u00e2\u20ac\u00a2\tset_fan_mode(): Sets the fan mode (auto, on, circulate).\r\n\u00e2\u20ac\u00a2\tset_system_mode(): Sets the system mode (heat, cool, off).\r\n\u00e2\u20ac\u00a2\tset_setpoint_cool(temp): Sets the cool setpoint temperature.\r\n\u00e2\u20ac\u00a2\tset_setpoint_heat(temp): Sets the heat setpoint temperature.\r\nExample:\r\npython\r\ndevice = await session.get_device('123456')\r\nawait device.set_setpoint_cool(75)\r\nawait device.set_system_mode('cool')\r\n\r\nException Handling in Detail\r\nThis module contains custom exceptions that are used throughout the codebase. Each of these exceptions inherits from SomeComfortError, the base exception class.\r\nExceptions\r\n\u00e2\u20ac\u00a2\tSomeComfortError: The base exception class for all exceptions in this module.\r\n\u00e2\u20ac\u00a2\tAuthError: Raised when authentication fails (e.g., incorrect username/password).\r\n\u00e2\u20ac\u00a2\tAPIError: Raised when the API returns an unexpected response or an error status.\r\n\u00e2\u20ac\u00a2\tSessionTimedOut: Raised when the session has timed out and must be renewed.\r\n\u00e2\u20ac\u00a2\tAPIRateLimited: Raised when the API rate limit has been exceeded.\r\n\r\nLicense\r\nMIT License. See LICENSE for more information.\r\n\r\n\r\n### How to Use:\r\n- **README.md**: This entire file content can be saved as `README.md` and placed in the root directory of your project repository.\r\n- **Additional Files**:\r\n  - **LICENSE**: Ensure you have a `LICENSE` file that corresponds to the MIT License if you're using that.\r\n  - **Detailed Documentation**: You can further elaborate on each class and method in a separate API documentation if needed (e.g., using Sphinx for Python docs).\r\n\r\nLet me know if you need further adjustments or more sections added!\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for interacting with Honeywell Total Connect Comfort (TCC) API",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/async-somecomfort"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ccfcbf4e917240598705b059f25ea8216bd3ec73d881ab7da4d23ea032b837f",
                "md5": "ed05ed85402ec997db4f264585b5a27d",
                "sha256": "a19146b9064b093fb518aaaa254cb82868bfd00235a5d22b49bfd83426bba011"
            },
            "downloads": -1,
            "filename": "async_somecomfort-1.0.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ed05ed85402ec997db4f264585b5a27d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 30568,
            "upload_time": "2024-10-09T01:27:56",
            "upload_time_iso_8601": "2024-10-09T01:27:56.837408Z",
            "url": "https://files.pythonhosted.org/packages/2c/cf/cbf4e917240598705b059f25ea8216bd3ec73d881ab7da4d23ea032b837f/async_somecomfort-1.0.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08085e2dccc5af525d373c18297f8001db8760335e634ce8b5bb142b88b6d433",
                "md5": "7eda80d0a9faf3e13d24dffd0df0590d",
                "sha256": "0825880921fa857f29d7606c52d3f055440db16d40232995c72b5ec71c475a3c"
            },
            "downloads": -1,
            "filename": "async_somecomfort-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7eda80d0a9faf3e13d24dffd0df0590d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 28771,
            "upload_time": "2024-10-09T01:27:58",
            "upload_time_iso_8601": "2024-10-09T01:27:58.664378Z",
            "url": "https://files.pythonhosted.org/packages/08/08/5e2dccc5af525d373c18297f8001db8760335e634ce8b5bb142b88b6d433/async_somecomfort-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 01:27:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "async-somecomfort",
    "github_not_found": true,
    "lcname": "async-somecomfort"
}
        
Elapsed time: 0.75812s