Name | hubspace-async JSON |
Version |
0.4.1
JSON |
| download |
home_page | None |
Summary | Talk to the HubSpace API asynchronously |
upload_time | 2024-09-27 10:56:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | The MIT License (MIT) Copyright (c) 2024 Chris Dohmen 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. |
keywords |
hubspace
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
==============
hubspace-async
==============
Creates a session to HubSpace and handles authentication
This project was designed to asynchronously connect to the HubSpace API and
retrieve data. The implementation was based on
`jdeath/Hubspace-Homeassistant <https://github.com/jdeath/Hubspace-Homeassistant>`_
but converted to async and cleaned up.
Examples
========
These examples provide sample usage when running from the python
shell. If the code is running within an async loop, gathering the loop
and telling it to run is not required.
Gather all devices from the API
-------------------------------
.. code-block:: python
import logging
import hubspace_async
import asyncio
# TRACE messages in logs
hubspace_async.logger.setLevel(logging.HS_TRACE)
hubspace_async.logger.addHandler(logging.StreamHandler())
try:
loop = asyncio.get_event_loop()
except RunTimeError:
loop = asyncio.new_event_loop()
username = "<username>"
password = "<password>
async def get_devices(username, password):
connection = hubspace_async.HubSpaceConnection(username, password)
return await connection.devices
loop.run_until_complete(get_devices(username, password))
A sample output would look like
.. code-block:: json
[{"id": "blah1"}, {"id": "blah2"}]
After running this code, the following attributes will be populated:
* homes: Dictionary of all homes from the API response
* rooms: Dictionary of all rooms from the API response
* devices: Dictionary of all devices from the API response
Updating a devices state
------------------------
In this example we will turn a light on. The request requires the use
of ``functionInstance`` for it to work. However some updates
may not require this field.
.. code-block:: python
from hubspace_async import connection, HubSpaceState
import asyncio
conn = connection.HubSpaceConnection("username", "password")
state = HubSpaceState(
functionClass="power",
functionInstance="light-power",
value="on",
)
child_id = "abc123"
loop.run_until_complete(conn.set_device_state(child_id, new_states))
CLI Commands
============
A CLI is provided for testing your credentials and connection to hubspace.
For all commands, click needs to be installed. The easiest way to install
click is by using the `cli` extras.
``pip install hubspace-async[cli]``
Testing Auth
------------
To test auth, run the following command:
``python -m hubspace_async.cli --username "<username>" --password "<password>" auth-flow``
If successful, the message "Token has been successfully generated" will be displayed.
Testing Connectivity
--------------------
To test connectivity, run the following command:
``python -m hubspace_async.cli --username "<username>" --password "<password>" auth-flow``
If successful, an account id with several hyphens will appear.
Raw data
{
"_id": null,
"home_page": null,
"name": "hubspace-async",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Chris Dohmen <chris.dohmen11@gmail.com>",
"keywords": "HubSpace",
"author": null,
"author_email": "Chris Dohmen <chris.dohmen11@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/6a/20/54ddb8c8a893a4215cf066e289fc1f274f94b14a1331d01cc6f741bd93c2/hubspace_async-0.4.1.tar.gz",
"platform": null,
"description": "==============\nhubspace-async\n==============\n\n\n Creates a session to HubSpace and handles authentication\n\n\nThis project was designed to asynchronously connect to the HubSpace API and\nretrieve data. The implementation was based on\n`jdeath/Hubspace-Homeassistant <https://github.com/jdeath/Hubspace-Homeassistant>`_\nbut converted to async and cleaned up.\n\nExamples\n========\nThese examples provide sample usage when running from the python\nshell. If the code is running within an async loop, gathering the loop\nand telling it to run is not required.\n\n\nGather all devices from the API\n-------------------------------\n\n.. code-block:: python\n\n import logging\n\n import hubspace_async\n import asyncio\n\n\n # TRACE messages in logs\n hubspace_async.logger.setLevel(logging.HS_TRACE)\n hubspace_async.logger.addHandler(logging.StreamHandler())\n\n try:\n loop = asyncio.get_event_loop()\n except RunTimeError:\n loop = asyncio.new_event_loop()\n\n username = \"<username>\"\n password = \"<password>\n\n async def get_devices(username, password):\n connection = hubspace_async.HubSpaceConnection(username, password)\n return await connection.devices\n\n\n\n loop.run_until_complete(get_devices(username, password))\n\nA sample output would look like\n\n.. code-block:: json\n\n [{\"id\": \"blah1\"}, {\"id\": \"blah2\"}]\n\nAfter running this code, the following attributes will be populated:\n\n * homes: Dictionary of all homes from the API response\n * rooms: Dictionary of all rooms from the API response\n * devices: Dictionary of all devices from the API response\n\n\nUpdating a devices state\n------------------------\nIn this example we will turn a light on. The request requires the use\nof ``functionInstance`` for it to work. However some updates\nmay not require this field.\n\n\n.. code-block:: python\n\n\n from hubspace_async import connection, HubSpaceState\n import asyncio\n\n\n conn = connection.HubSpaceConnection(\"username\", \"password\")\n state = HubSpaceState(\n functionClass=\"power\",\n functionInstance=\"light-power\",\n value=\"on\",\n )\n child_id = \"abc123\"\n loop.run_until_complete(conn.set_device_state(child_id, new_states))\n\n\nCLI Commands\n============\n\nA CLI is provided for testing your credentials and connection to hubspace.\nFor all commands, click needs to be installed. The easiest way to install\nclick is by using the `cli` extras.\n\n``pip install hubspace-async[cli]``\n\n\nTesting Auth\n------------\nTo test auth, run the following command:\n``python -m hubspace_async.cli --username \"<username>\" --password \"<password>\" auth-flow``\n\nIf successful, the message \"Token has been successfully generated\" will be displayed.\n\nTesting Connectivity\n--------------------\nTo test connectivity, run the following command:\n``python -m hubspace_async.cli --username \"<username>\" --password \"<password>\" auth-flow``\n\nIf successful, an account id with several hyphens will appear.\n",
"bugtrack_url": null,
"license": "The MIT License (MIT) Copyright (c) 2024 Chris Dohmen 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.",
"summary": "Talk to the HubSpace API asynchronously",
"version": "0.4.1",
"project_urls": {
"Changelog": "https://github.com/Expl0dingBanana/hubspace-async/CHANGELOG.md",
"Repository": "https://github.com/Expl0dingBanana/hubspace-async"
},
"split_keywords": [
"hubspace"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "18bdc9c5574d6bd8ad2ea0aa754b9aac00851fe961de2b2dfdace53e7fc62f05",
"md5": "cf67324d055e0f4fa116e52ee2604574",
"sha256": "90138147157d6b766c8ab75c9d05d5c15b82faf528bb782f0a9cb4e8c1ca069d"
},
"downloads": -1,
"filename": "hubspace_async-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cf67324d055e0f4fa116e52ee2604574",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 13866,
"upload_time": "2024-09-27T10:56:30",
"upload_time_iso_8601": "2024-09-27T10:56:30.246973Z",
"url": "https://files.pythonhosted.org/packages/18/bd/c9c5574d6bd8ad2ea0aa754b9aac00851fe961de2b2dfdace53e7fc62f05/hubspace_async-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6a2054ddb8c8a893a4215cf066e289fc1f274f94b14a1331d01cc6f741bd93c2",
"md5": "ec102ef84f3ad561b9674df215bee4d5",
"sha256": "37f38b691ae8200c48b9b9757dc069e55d24c1045b3cb4f5e24ad4f6bd744a59"
},
"downloads": -1,
"filename": "hubspace_async-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "ec102ef84f3ad561b9674df215bee4d5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 30415,
"upload_time": "2024-09-27T10:56:31",
"upload_time_iso_8601": "2024-09-27T10:56:31.256430Z",
"url": "https://files.pythonhosted.org/packages/6a/20/54ddb8c8a893a4215cf066e289fc1f274f94b14a1331d01cc6f741bd93c2/hubspace_async-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-27 10:56:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Expl0dingBanana",
"github_project": "hubspace-async",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "hubspace-async"
}