pyhatchbabyrest-hass


Namepyhatchbabyrest-hass JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttps://github.com/ViViDboarder/pyhatchbabyrest
SummaryPython library to control Hatch Baby Rest devices
upload_time2024-01-05 23:48:06
maintainer
docs_urlNone
authorKevin O'Connor, ViViDboarder
requires_python>=3.5
license
keywords
VCS
bugtrack_url
requirements bleak pygatt
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hatch Baby Rest Python Bindings
This library will allow you to control a [Hatch Baby Rest device](https://www.hatchbaby.com/rest) (note, /not/ the Hatch Baby Rest+, which is Wi-Fi enabled) over [BLE](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy).

## Requirements
The pygatt backend was tested on a Raspberry Pi 3 Model B Rev 1.2, but should work on any Unix system that is compatible with the `GATTToolBackend` of [pygatt](https://github.com/peplin/pygatt).

The bleak (async) backend was tested on a 2019 MacBook Pro, but should work on any system that [bleak](https://github.com/hbldh/bleak) is compatible with.

## Installation
`pip install pyhatchbabyrest`

## Examples
### pygatt backend (synchronous)
```python3
In [1]: from pyhatchbabyrest import PyHatchBabyRest

In [2]: rest = PyHatchBabyRest()

In [3]: rest.power
Out[3]: False

In [4]: rest.power_on()

In [5]: rest.volume
Out[5]: 30

In [6]: rest.set_volume(10)

In [7]: rest.volume
Out[7]: 10

In [8]: rest.set_color(255, 0, 0)

In [9]: rest.color
Out[9]: (255, 0, 0)

In [10]: rest.set_brightness(100)

In [11]: rest.set_sound(PyHatchBabyRestSound.stream)

In [12]: rest.sound
Out[12]: <PyHatchBabyRestSound.stream: 2>

In [13]: rest.set_color(*PyHatchBabyRest.COLOR_GRADIENT)
    
In [14]: rest.connected
Out[14]: True

In [15]: rest.disconnect()

In [16]: rest.connected
Out[16]: False
```

### bleak backend (async and a little more portable)
```python3
In [1]: from pyhatchbabyrest import PyHatchBabyRestAsync

In [2]: rest = PyHatchBabyRestAsync()

In [3]: import asyncio

In [4]: loop = asyncio.get_event_loop()

In [5]: r = loop.run_until_complete

In [6]: r(rest.power_on())

In [7]: r(rest.set_volume(100))

In [8]: r(rest.set_volume(10))

In [9]: r(rest.power_off())

In [10]: rest.sound
Out[10]: <PyHatchBabyRestSound.noise: 3>
```

#### NOTE: Using PyHatchBabyRestAsync from async code
The constructor, by default, executes directly against the event loop. This doesn't work if it is executed within an already running coroutine. To construct the client, all async calls must be done outside of the constructor.

This has been all wrapped up in a function for ease of use.

```python3
import asyncio

from pyhatchbabyrest import connect_async


async def main():
    rest = await connect_async()
    await rest.power_on()


rest = asyncio.run(main())
```

## Credits
Huge thanks to @Marcus-L for their repo at [GitHub - Marcus-L/m4rcus.HatchBaby.Rest: Control Hatch Baby Rest devices using Bluetooth LE](https://github.com/Marcus-L/m4rcus.HatchBaby.Rest) which did all the hard work of finding the right characteristics, commands, etc.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ViViDboarder/pyhatchbabyrest",
    "name": "pyhatchbabyrest-hass",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "",
    "author": "Kevin O'Connor, ViViDboarder",
    "author_email": "kjoconnor@gmail.com, ViViDboarder@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/98/dd19e16fbdd6017917ed0284badb492c8606183e7fb30faadb1b151cd79e/pyhatchbabyrest-hass-2.3.0.tar.gz",
    "platform": null,
    "description": "# Hatch Baby Rest Python Bindings\nThis library will allow you to control a [Hatch Baby Rest device](https://www.hatchbaby.com/rest) (note, /not/ the Hatch Baby Rest+, which is Wi-Fi enabled) over [BLE](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy).\n\n## Requirements\nThe pygatt backend was tested on a Raspberry Pi 3 Model B Rev 1.2, but should work on any Unix system that is compatible with the `GATTToolBackend` of [pygatt](https://github.com/peplin/pygatt).\n\nThe bleak (async) backend was tested on a 2019 MacBook Pro, but should work on any system that [bleak](https://github.com/hbldh/bleak) is compatible with.\n\n## Installation\n`pip install pyhatchbabyrest`\n\n## Examples\n### pygatt backend (synchronous)\n```python3\nIn [1]: from pyhatchbabyrest import PyHatchBabyRest\n\nIn [2]: rest = PyHatchBabyRest()\n\nIn [3]: rest.power\nOut[3]: False\n\nIn [4]: rest.power_on()\n\nIn [5]: rest.volume\nOut[5]: 30\n\nIn [6]: rest.set_volume(10)\n\nIn [7]: rest.volume\nOut[7]: 10\n\nIn [8]: rest.set_color(255, 0, 0)\n\nIn [9]: rest.color\nOut[9]: (255, 0, 0)\n\nIn [10]: rest.set_brightness(100)\n\nIn [11]: rest.set_sound(PyHatchBabyRestSound.stream)\n\nIn [12]: rest.sound\nOut[12]: <PyHatchBabyRestSound.stream: 2>\n\nIn [13]: rest.set_color(*PyHatchBabyRest.COLOR_GRADIENT)\n    \nIn [14]: rest.connected\nOut[14]: True\n\nIn [15]: rest.disconnect()\n\nIn [16]: rest.connected\nOut[16]: False\n```\n\n### bleak backend (async and a little more portable)\n```python3\nIn [1]: from pyhatchbabyrest import PyHatchBabyRestAsync\n\nIn [2]: rest = PyHatchBabyRestAsync()\n\nIn [3]: import asyncio\n\nIn [4]: loop = asyncio.get_event_loop()\n\nIn [5]: r = loop.run_until_complete\n\nIn [6]: r(rest.power_on())\n\nIn [7]: r(rest.set_volume(100))\n\nIn [8]: r(rest.set_volume(10))\n\nIn [9]: r(rest.power_off())\n\nIn [10]: rest.sound\nOut[10]: <PyHatchBabyRestSound.noise: 3>\n```\n\n#### NOTE: Using PyHatchBabyRestAsync from async code\nThe constructor, by default, executes directly against the event loop. This doesn't work if it is executed within an already running coroutine. To construct the client, all async calls must be done outside of the constructor.\n\nThis has been all wrapped up in a function for ease of use.\n\n```python3\nimport asyncio\n\nfrom pyhatchbabyrest import connect_async\n\n\nasync def main():\n    rest = await connect_async()\n    await rest.power_on()\n\n\nrest = asyncio.run(main())\n```\n\n## Credits\nHuge thanks to @Marcus-L for their repo at [GitHub - Marcus-L/m4rcus.HatchBaby.Rest: Control Hatch Baby Rest devices using Bluetooth LE](https://github.com/Marcus-L/m4rcus.HatchBaby.Rest) which did all the hard work of finding the right characteristics, commands, etc.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python library to control Hatch Baby Rest devices",
    "version": "2.3.0",
    "project_urls": {
        "Homepage": "https://github.com/ViViDboarder/pyhatchbabyrest"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ab5d5fa1665632f2025ab4f1fd7e346c810e478e8da2a520e73f669127ca564",
                "md5": "7cb3da495423afa7d371b7ee2e377de0",
                "sha256": "6ad9df473640aaddb8c0f6aae460280e0b14e6729ce0697a7b8e12fb8ebba6b3"
            },
            "downloads": -1,
            "filename": "pyhatchbabyrest_hass-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7cb3da495423afa7d371b7ee2e377de0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 7275,
            "upload_time": "2024-01-05T23:48:04",
            "upload_time_iso_8601": "2024-01-05T23:48:04.579439Z",
            "url": "https://files.pythonhosted.org/packages/5a/b5/d5fa1665632f2025ab4f1fd7e346c810e478e8da2a520e73f669127ca564/pyhatchbabyrest_hass-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c98dd19e16fbdd6017917ed0284badb492c8606183e7fb30faadb1b151cd79e",
                "md5": "136d88137d5354387d477718d67dc7df",
                "sha256": "3ad985433c0bd214c4e55a52f0fd110d3650b27095045d64961409f52f725376"
            },
            "downloads": -1,
            "filename": "pyhatchbabyrest-hass-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "136d88137d5354387d477718d67dc7df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 5789,
            "upload_time": "2024-01-05T23:48:06",
            "upload_time_iso_8601": "2024-01-05T23:48:06.084078Z",
            "url": "https://files.pythonhosted.org/packages/4c/98/dd19e16fbdd6017917ed0284badb492c8606183e7fb30faadb1b151cd79e/pyhatchbabyrest-hass-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-05 23:48:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ViViDboarder",
    "github_project": "pyhatchbabyrest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "bleak",
            "specs": [
                [
                    "==",
                    "0.10.0"
                ]
            ]
        },
        {
            "name": "pygatt",
            "specs": [
                [
                    "==",
                    "4.0.5"
                ]
            ]
        }
    ],
    "lcname": "pyhatchbabyrest-hass"
}
        
Elapsed time: 0.29542s