hass_mqtt_device
is a C++ library designed to simplify creating a device and connecting it to a Home Assistant MQTT server.
There are a number of functions and device types available. See the examples for more info on how to use the library.
- A modern C++ compiler with C++17 support.
- CMake version 3.10 or higher for building the project.
- Mosquitto MQTT broker development package
- Spdlog
sudo apt update
sudo apt install cmake libspdlog-dev nlohmann-json3-dev git libmosquittopp-dev
Also you need wiring-pi for raspberry pi setups:
wget https://github.com/WiringPi/WiringPi/releases/download/3.4/wiringpi_3.4_arm64.deb
sudo dpkg -i wiringpi_3.4_arm64.deb
rm wiringpi_3.4_arm64.deb
- gTest
- Clone the repository:
git clone https://github.com/KodeZ/hass_mqtt_device.git
- Navigate to the project directory and create a build directory:
cd hass_mqtt_device
- Configure and build the project:
make
- (Optional) Install the library to your system:
sudo make install
There are a few devices defined for comfort. See the devices folder. It is rather easy to make your own devices by inheriting from DeviceBase, then add functions from the functions folder, or create your own functions from FunctionBase.
In the examples folder there are a few examples on how the library can be used.
If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.
See the LICENSE file, but in short it is MIT.