Arduino (using Arduino IDE or PlatformIO) and ESP-IDF (using Espressif IoT Development Framework or PlatformIO) compatible library for providing sensors and actuators to Home Assistant using MQTT.
Home Assistant has a well defined way of defining sensors and actuators using MQTT. This library register a device with one or mulitple sensors and provide a way to publish new values for them, as well as listen for commands from Home Assistant.
- Atmospheric Preassure (hPa)
- Binary Sensor / Boolean
- Brightness (%)
- Door (open/closed)
- Humidity (%)
- Json (raw "json"-sensor)
- Lock (locked/unlocked)
- Motion (detected/not detected)
- Number
- Sound (detected/not detected)
- String (raw "String"-sensor)
- Temperature (°C/°F)
- Voltage (mV/V)
- Weight (g/kg)
- Curtain (open/opening, close/closing, position)
- Event
- Light (brightness, rgb, effect)
- Select
- Switch (on/off)
Add the following to libs_deps
:
Johboh/HomeAssistantEntities@^7.0.7
You also need a MQTT library and a JSON library. See Dependencies section. Suggestion:
johboh/MQTTRemote@^4.0.4
bblanchon/ArduinoJson@^7.1.0
Search for HomeAssistantEntities
by johboh in the library manager. You also need a MQTT library and a JSON library. See Dependencies section. Suggestion: MQTTRemote
by johboh
and ArduinoJson
by bblanchon
.
In your existing idf_component.yml
or in a new idf_component.yml
next to your main component:
dependencies:
johboh/homeassistantentities:
version: ">=7.0.7"
You also need a MQTT library. See Dependencies section. Suggestion:
johboh/mqttrmote:
version: ">=4.0.5"
- ESP32 (tested with PlatformIO espressif32@6.4.0 / arduino-esp32@2.0.11 / ESP-IDF@4.4.6 / ESP-IDF@5.1.2 on ESP32-S2 and ESP32-C3)
- ESP8266 (tested with PlatformIO espressif8266@4.2.1 / ardunio-core@3.1.2)
Newer version most probably work too, but they have not been verified.
- For ESP-IDF: https://github.com/Johboh/nlohmann-json @^3.11.3, for Arduino: https://github.com/Johboh/nlohmann-json @^3.11.3 OR https://github.com/bblanchon/ArduinoJson@^7.1.0
- An MQTT implementation is required. There is a copy of IMQTTRemote in this library from Johboh/MQTTRemote. You can either add a dependency on MQTTRemote to get a fully working MQTT client (the examples are using this dependency), or you can implement/adapt/forward to your own MQTT implementation. This library only depend on the IMQTTRemote interface.
- Needs C++17 for
std::optional
.- For PlatformIO in
platformio.ini
:build_unflags=-std=gnu++11 # "Disable" C++11 build_flags=-std=gnu++17 # "Enable" C++17
- For PlatformIO in