# Home Assistant MQTT Things
[![PyPI version](https://badge.fury.io/py/hass-mqtt-things.svg)](https://pypi.org/project/hass-mqtt-things/)
Python library for rapid integration of Things with Home Assistant through MQTT.
## Demonstration
If you have a Home Assistant instance reachable, and have a MQTT in place
(with discovery activated), you can easily use this library and the provided
examples show you how to proceed.
### From the source code
A quick way of starting from scratch (by cloning this project and creating a
virtual environment) is shown below:
```bash
$ git clone https://github.com/alexbarcelo/hass-mqtt-things.git
Cloning into 'hass-mqtt-things'...
remote: Enumerating objects: (...)
(...)
$ cd hass-mqtt-things
$ python3 -m venv venv
$ source venv/bin/activate
(venv)$ pip install --upgrade pip
Collecting pip
(...)
Installing collected packages: pip
(...)
(venv)$ pip install -e .
Obtaining file:(...)
(...)
Successfully installed getmac-0.8.3 hass-mqtt-things-0.3.0 paho-mqtt-1.6.1
(venv)$ export MQTT_HOST="hassio.local"
(venv)$ export MQTT_USERNAME="user"
(venv)$ export MQTT_PASSWORD="password"
(venv)$ cd examples
(venv)$ ./interactive_switch.py
Entering an infinite loop, Ctrl+C multiple times to exit.
Connected with result code 0
Toggling state. Previous state: False
Toggling state. Next state: True
(... ad infinitum)
```
NOTE: I have put an explicit upgrade for the `pip` package because I am using the "new"
setup.cfg approach, which doesn't work with certain old versions.
You will need to change the `export` lines and adapt them to your MQTT setup
(set up your host, username and password information).
Once you have followed the above steps, a new _Awesomest Switch_ should have appeared
and it will toggle every 5 seconds.
### With PyPI packages
Assuming you are in a proper environment (e.g. a Python _virtual environment_)
you can easily install this package and try a demo from the `examples` folder:
```bash
$ pip install hass-mqtt-things
Collecting hass-mqtt-things
Downloading hass_mqtt_things-0.2.0-py3-none-any.whl (10 kB)
(...)
Successfully installed getmac-0.8.3 hass-mqtt-things-0.2.0 paho-mqtt-1.6.1
$ curl -O https://raw.githubusercontent.com/alexbarcelo/hass-mqtt-things/main/examples/interactive_switch.py
$ export MQTT_HOST="hassio.local"
$ export MQTT_USERNAME="user"
$ export MQTT_PASSWORD="password"
$ chmod +x interactive_switch.py
$ ./interactive_switch.py
Entering an infinite loop, Ctrl+C multiple times to exit.
Connected with result code 0
Toggling state. Previous state: False
Toggling state. Next state: True
(... ad infinitum)
```
You will need to change the `export` lines and adapt them to your MQTT setup
(set up your host, username and password information).
Once you have followed the above steps, a new _Awesomest Switch_ should have appeared
and it will toggle every 5 seconds.
### More examples
Check the [examples folder](examples). You will find some more examples there.
## Use cases
This library is aimed to Python developers that are using Home Assistant for their
home automation projects and wants to be more agile in their deployment. The foundation
for this project is the [MQTT Discovery](https://www.home-assistant.io/docs/mqtt/discovery/)
mechanism of Home Assistant.
Some use cases where this library can become handy:
- GPIO control for a Raspberry Pi.
- Monitor something on your desktop PC (temperature, mount points, whether a certain application is running...).
- Management of serial connections (for example: video projectors with serial input).
- Alarm control panels on a Raspberry Pi.
At this moment both the Switch and Light component are done. I plan to add all
devices that are supported by the MQTT Discovery mechanism, but my personal use
cases will drive the roadmap (unless there are Pull Requests or specific
petitions in this repository).
Raw data
{
"_id": null,
"home_page": "",
"name": "hass-mqtt-things",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "home automation,home-assistant,internet of things,iot,things",
"author": "",
"author_email": "Alex Barcelo <alex@betarho.net>",
"download_url": "https://files.pythonhosted.org/packages/2a/87/764567b357cc9926eec6110196690c4b5ed696b39619bbc3fb8a5ab36750/hass_mqtt_things-0.5.9.tar.gz",
"platform": null,
"description": "# Home Assistant MQTT Things\n\n[![PyPI version](https://badge.fury.io/py/hass-mqtt-things.svg)](https://pypi.org/project/hass-mqtt-things/)\n\nPython library for rapid integration of Things with Home Assistant through MQTT.\n\n## Demonstration\n\nIf you have a Home Assistant instance reachable, and have a MQTT in place\n(with discovery activated), you can easily use this library and the provided\nexamples show you how to proceed.\n\n### From the source code\n\nA quick way of starting from scratch (by cloning this project and creating a\nvirtual environment) is shown below:\n\n```bash\n$ git clone https://github.com/alexbarcelo/hass-mqtt-things.git\nCloning into 'hass-mqtt-things'...\nremote: Enumerating objects: (...)\n(...)\n$ cd hass-mqtt-things\n$ python3 -m venv venv\n$ source venv/bin/activate\n(venv)$ pip install --upgrade pip\nCollecting pip\n (...)\nInstalling collected packages: pip\n (...)\n(venv)$ pip install -e .\nObtaining file:(...)\n(...)\nSuccessfully installed getmac-0.8.3 hass-mqtt-things-0.3.0 paho-mqtt-1.6.1\n(venv)$ export MQTT_HOST=\"hassio.local\"\n(venv)$ export MQTT_USERNAME=\"user\"\n(venv)$ export MQTT_PASSWORD=\"password\"\n(venv)$ cd examples\n(venv)$ ./interactive_switch.py\nEntering an infinite loop, Ctrl+C multiple times to exit.\nConnected with result code 0\nToggling state. Previous state: False\nToggling state. Next state: True\n(... ad infinitum)\n```\n\nNOTE: I have put an explicit upgrade for the `pip` package because I am using the \"new\"\nsetup.cfg approach, which doesn't work with certain old versions.\n\nYou will need to change the `export` lines and adapt them to your MQTT setup\n(set up your host, username and password information).\n\nOnce you have followed the above steps, a new _Awesomest Switch_ should have appeared\nand it will toggle every 5 seconds.\n\n### With PyPI packages\n\nAssuming you are in a proper environment (e.g. a Python _virtual environment_)\nyou can easily install this package and try a demo from the `examples` folder:\n\n```bash\n$ pip install hass-mqtt-things\nCollecting hass-mqtt-things\n Downloading hass_mqtt_things-0.2.0-py3-none-any.whl (10 kB)\n(...)\nSuccessfully installed getmac-0.8.3 hass-mqtt-things-0.2.0 paho-mqtt-1.6.1\n$ curl -O https://raw.githubusercontent.com/alexbarcelo/hass-mqtt-things/main/examples/interactive_switch.py\n$ export MQTT_HOST=\"hassio.local\"\n$ export MQTT_USERNAME=\"user\"\n$ export MQTT_PASSWORD=\"password\"\n$ chmod +x interactive_switch.py\n$ ./interactive_switch.py\nEntering an infinite loop, Ctrl+C multiple times to exit.\nConnected with result code 0\nToggling state. Previous state: False\nToggling state. Next state: True\n(... ad infinitum)\n```\n\nYou will need to change the `export` lines and adapt them to your MQTT setup\n(set up your host, username and password information).\n\nOnce you have followed the above steps, a new _Awesomest Switch_ should have appeared\nand it will toggle every 5 seconds.\n\n### More examples\n\nCheck the [examples folder](examples). You will find some more examples there.\n\n## Use cases\n\nThis library is aimed to Python developers that are using Home Assistant for their\nhome automation projects and wants to be more agile in their deployment. The foundation\nfor this project is the [MQTT Discovery](https://www.home-assistant.io/docs/mqtt/discovery/)\nmechanism of Home Assistant.\n\nSome use cases where this library can become handy:\n\n- GPIO control for a Raspberry Pi.\n- Monitor something on your desktop PC (temperature, mount points, whether a certain application is running...).\n- Management of serial connections (for example: video projectors with serial input).\n- Alarm control panels on a Raspberry Pi.\n\nAt this moment both the Switch and Light component are done. I plan to add all\ndevices that are supported by the MQTT Discovery mechanism, but my personal use\ncases will drive the roadmap (unless there are Pull Requests or specific\npetitions in this repository).\n",
"bugtrack_url": null,
"license": "",
"summary": "Library for rapid development of things to be integrated with Home Assistant through MQTT",
"version": "0.5.9",
"project_urls": {
"Documentation": "https://github.com/alexbarcelo/hass-mqtt-things#readme",
"Issues": "https://github.com/alexbarcelo/hass-mqtt-things/issues",
"Source": "https://github.com/alexbarcelo/hass-mqtt-things"
},
"split_keywords": [
"home automation",
"home-assistant",
"internet of things",
"iot",
"things"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "510e808ef4701a9f55d92c2429d625aa2a156f1f8e9a64a4a606919e3038be61",
"md5": "3f281fa7c8b517d22e8af9ec14363ed5",
"sha256": "d3c0dbff849d09dff5c8c8b5f408863f64707b67e8586902e3951d65deae9f27"
},
"downloads": -1,
"filename": "hass_mqtt_things-0.5.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3f281fa7c8b517d22e8af9ec14363ed5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 17286,
"upload_time": "2023-08-29T15:44:56",
"upload_time_iso_8601": "2023-08-29T15:44:56.428101Z",
"url": "https://files.pythonhosted.org/packages/51/0e/808ef4701a9f55d92c2429d625aa2a156f1f8e9a64a4a606919e3038be61/hass_mqtt_things-0.5.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2a87764567b357cc9926eec6110196690c4b5ed696b39619bbc3fb8a5ab36750",
"md5": "5db3e7aa45092fbeac5ad4de4bd66af9",
"sha256": "8c4b27f4e8ac1857861085906fe5063cfc1f6b8cd58ca28e345558060621628b"
},
"downloads": -1,
"filename": "hass_mqtt_things-0.5.9.tar.gz",
"has_sig": false,
"md5_digest": "5db3e7aa45092fbeac5ad4de4bd66af9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 13405,
"upload_time": "2023-08-29T15:44:57",
"upload_time_iso_8601": "2023-08-29T15:44:57.835830Z",
"url": "https://files.pythonhosted.org/packages/2a/87/764567b357cc9926eec6110196690c4b5ed696b39619bbc3fb8a5ab36750/hass_mqtt_things-0.5.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-29 15:44:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alexbarcelo",
"github_project": "hass-mqtt-things#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hass-mqtt-things"
}