Metadata-Version: 2.1
Name: mqtt-rest
Version: 0.4.1
Summary: A REST API for MQTT Client Management
Home-page: https://github.com/rahulsrma26/mqtt-rest
License: MIT
Keywords: MQTT,REST,API
Author: Rahul Sharma
Author-email: rahulsrma26@gmail.com
Maintainer: Rahul Sharma
Maintainer-email: rahulsrma26@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: Framework :: FastAPI
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Home Automation
Requires-Dist: fastapi (>=0.115.0,<0.116.0)
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
Requires-Dist: paho-mqtt (>=2.1.0,<3.0.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Requires-Dist: uvicorn (>=0.31.0,<0.32.0)
Project-URL: Repository, https://github.com/rahulsrma26/mqtt-rest
Description-Content-Type: text/markdown

[![build](https://github.com/rahulsrma26/mqtt-rest/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/rahulsrma26/mqtt-rest/actions/workflows/build.yml)

# MQTT-REST

MQTT-REST is a project that bridges MQTT and RESTful APIs, allowing seamless communication between IoT devices using MQTT and web services using REST.

It's useful if you want to monitor arbritary stuff from a machine in Home-assistant without writing custom integration.

## Installation

```sh
pip install mqtt-rest
```

## Running

```sh
mqtt-rest.run
```

## Docker

Dockerhub repository for [mqtt-rest](https://hub.docker.com/r/welcometors/mqtt-rest).

```sh
docker pull welcometors/mqtt-rest:latest
```

```sh
docker run --env-file vars.env -p 9000:9000 welcometors/mqtt-rest:latest
```

where `.env` file can provide a convenient way to change environment variables:

```env
BROKER_IP=<mqtt-broker-ip>
BROKER_PORT=<mqtt-broker-port>  # defaults to 1883
MQTT_USER=<mqtt-user-name>
MQTT_PASS=<mqtt-password>
SERVER_LOG_LEVEL=info  # uvicorn log level
MQTT_LOG=False  # enable's logging by mqtt client
```

## Development

```sh
git clone https://github.com/rahulsrma26/mqtt-rest
cd mqtt-rest
poetry shell
poetry install
poetry run python -m mqtt_rest.run
```

If you dont want poetry to managing virtual environment then dont need to run `poetry run` or `poetry shell`. In that case one can directly run `python -m mqtt_rest.run`.

Visit `/docs` endpoint to access API docs via SwaggerUI.

### Testing

```sh
poetry run pytest
```

### Linting

```sh
poetry run ruff check
```

## Contributing

Install pre-commit

```sh
poetry run pre-commit install
```

Check if everything runs:

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

Note: The process may occasionally fail due to caching issues with PyPI. If this happens, please clear the cache before trying again.

```sh
poetry cache clear PyPI --all
```

