# intertechno-cc1101-mqtt

MQTT client controlling [Intertechno Outlets](https://www.intertechno.at/)
via a [CC1101 Transceiver](https://www.ti.com/product/CC1101)

Compatible with [Home Assistant](https://www.home-assistant.io/)'s
[MQTT Switch](https://www.home-assistant.io/integrations/switch.mqtt/) platform.

## Requirements

* MQTT broker
* [Intertechno](https://www.intertechno.at/) smart outlet
* [CC1101 transceiver](https://www.ti.com/product/CC1101)
* Linux machine with CC1101 connected to SPI port
  ([wiring instructions](https://github.com/fphammerle/python-cc1101#wiring-raspberry-pi)
  for raspberry pi)

## Setup

```sh
$ pip3 install --user --upgrade git+https://git.hammerle.me/fphammerle/intertechno-cc1101-mqtt
```

On Raspbian / Raspberry Pi OS, dependencies can optionally be installed via:
```sh
$ sudo apt-get install --no-install-recommends python3-spidev python3-paho-mqtt
```

## Usage

```sh
$ intertechno-cc1101-mqtt --mqtt-host HOSTNAME_OR_IP_ADDRESS
```

Send `ON` or `OFF` to topic `intertechno-cc1101/[ADDRESS]/[BUTTON_INDEX]/set`.

```sh
$ mosquitto_pub -h MQTT_BROKER -t intertechno-cc1101/12345678/0/set -m ON
```

⚠️ Support for TLS is not implemented yet. Do not connect to brokers via unprotected networks (e.g., internet, wifi network).

## Docker 🐳

```sh
$ sudo docker build -t intertechno-cc1101-mqtt .
$ sudo docker run --name intertechno_cc1101_mqtt \
    --read-only --cap-drop ALL --security-opt no-new-privileges \
    --device /dev/spidev0.0 intertechno-cc1101-mqtt \
    intertechno-cc1101-mqtt --mqtt-host HOSTNAME_OR_IP_ADDRESS …
```

### Docker Compose 🐙

1. Clone this repository.
2. Adapt `command` in `docker-compose.yml`.
3. `sudo docker-compose up --build`