Skip to content

Gateway connecting different Protocols and Devices via MQTT

Notifications You must be signed in to change notification settings

CubieMedia/mqtt-client

Repository files navigation

mqtt-client

Gateway connecting different Protocols and Devices via MQTT

This works perfectly together with Home Assistant and is an important part of the CubieMedia - System


It supports following modules:

  • Relayboards
    • ETH 008
    • one Gateway per Installation will control all Relayboards
  • Enocean (with the Enocean Pi Hat)
  • GPIO (normal GPIO Pins on Pi)
  • Sonar (Distance sensor with sound)
    • connect Sonar sensor to serial uart over GPIO's
  • Victron Energy MQTT Gateway
    • Cerbo GX
    • currently only one system per installation is supported
  • Balboa Spa Control
    • with connected BWA WiFi Module device will be auto discovered if gateway is in same network
    • control temperature, light and two pumps
    • explain AUTO mode (TODO)
  • MiFlora Flower Sensor
    • Read data from any MiFlora Sensor in reach
    • Gateway needs access to Bluetooth 4.1 Connection

Concept

MQTT-Client Concept


Installation

📝 IMPORTANT

The Services Enocean, GPIO and Sonar can NOT be used parallel on one device (because the GPIO Pins are needed for each service) All other services use other communication paths and can run on a single device.

If the services can not reach needed Hardware a log message will show this. This messages will also happen in development environment (e.g. PyCharm) on your PC / Laptop

Ubuntu Core

This Repository is made for the Snap Store from Canonical. Since i am only using Ubuntu Core in Development (not in Production) it is not tested very well and can have issues.

Please report them or send me a message.

  1. Install Ubuntu Core on your device
  2. Install the Snap on your device

snap install cubiemedia-mqtt-client [--devmode, --channel=latest/edge]

  1. Connect plugs if needed
  1. snap connect cubiemedia-mqtt-client:serial-port pi:bt-serial
  2. snap connect cubiemedia-mqtt-client:gpio-memory-control pi:gpio-memory-control
  3. snap connect cubiemedia-mqtt-client:system-observe (TODO seems to be not needed anymore, remove plug?)
  1. Enable Services or start the software manually
  1. sudo systemctl enable snap.cubiemedia-mqtt-client.[enocean,gpio,sonar,relay,victron,balboa,miflora] --now
  2. cubiemedia-mqtt-client [enocean,gpio,sonar,relay,victron,balboa,miflora] [--debug]
  1. Change default configuration
  1. TODO

PyCharm

  1. Clone the Repository

Git -> Clone... (with https://github.com/CubieMedia/mqtt-client as URL)

  1. Setup python venv and install dependencies (requirements.txt). PyCharm will help you with this.
  2. Create run configurations
  1. Right click on src/mqtt_client.py
  2. Select 'Modify Run Configuration...'
  3. Setup Service Run Configuration
  • Name: service name you want to start [EnOcean,GPIO,Sonar,Relay,Victron,Balboa,MiFlora]
  • Parameters: the service name, you can add --debug here for more log messages
  1. Setup WebTool Configuration (TODO)
  • Name: WebTool
  • script: ./venv/bin/flask
  • Parameters: run
  • Working Directory: root folder of the project
  • Environment Variables: FLASK_ENV=development;FLASK_RUN_PORT=8888;FLASK_RUN_HOST=0.0.0.0;FLASK_APP=./src/webtool/app.py
  1. Change default config file ('./src/config/mqtt.json')

The MQTT configuration contains connection data to your MQTT-Server and you need to change the parameters [host,username,password]

  1. Start the service and check log messages

Output will be found on console

Other Linux (e.g. Raspberry Pi)

  1. Get your System in a stable state, install git and clone this repository

sudo apt update; sudo apt -y upgrade; sudo apt -y install git; git clone https://github.com/CubieMedia/mqtt-client

  1. Install needed dependencies, create system services

sudo mqtt-client/usr/bin/cubiemedia-install-dependencies

  1. a. Run a simple test with a service (add parameter debug for more output)
  1. cd mqtt-client
  2. ./src/mqtt_client.py [enocean,gpio,sonar,relay,victron,balboa,miflora] [--debug]
  1. b. Enable the services you want (core and webtool are enabled by default)

sudo systemctl enable cubiemedia-[enocean,gpio,sonar,relay,victron] --now

  1. Check everything is running in your Browser (WebTool) or in logs
  1. http://[DEVICE_IP]:8888
  2. journalctl -u cubiemedia-[core,webtool,enocean,gpio,sonar,relay,victron] -f
  3. send a raw 'announce' payload via MQTT to topic 'cubiemedia/command'

Connection to Home Assistant

Devices are discovered automatically via the discovery prefix in the MQTT Configuration (default: homeassistant).

If auto discovery for MQTT is enable all connected devices will show up.


Help is appreciated! Contact me on Discord @Cubiemedia or via GitHub

About

Gateway connecting different Protocols and Devices via MQTT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published