MQTT Sensoren in Home Assistant einbinden

MQTT – Sensor im YAML file

Um Sensordaten über MQTT in Home Assistant einlesen zu können, müssen wir das configuration.yaml file anpassen. Zu Beginn geben wir im YAML file den Broker an. Das kann die IP-Adresse oder der Hostname von deinem MQTT Broker sein. Optional kann ein port: 1883 (Standard) oder 8883 angegeben werden.

Einen Sensor Konfiguration können wir mit sensor: starten, als Platform verwenden wir MQTT. Wir können optional noch einen Namen für den Messwert vergeben. Mit icon: icon_name könnt ihr euch ein Icon aus einer sehr grossen Liste die unter https://materialdesignicons.com verfügbar ist aussuchen und den Icon-Namen hier eingeben. Wenn ein Sensor mehrere Werte senden kann, als Beispiel hier der BME280 Sensor, dann müssen wir unterschiedliche State_topics verwenden. Mit Unit_of_measurement: geben wir an, welche Einheit der Messwert hat, z. B. °C oder % für die relative Luftfeuchtigkeit.

Beispiele für Sensoren die Daten über MQTT senden, findet ihr in der Reihe, optimales Raumklima.

Beispielcode

In diesem Beispiel  binden wir zwei MQTT Sensoren in Homeassistant ein. Einmal den Si7021 und darunter unter Sensor 2 den BME280. Ihr müsst das jeweilige state_topic von eurem Sensor anpassen.

mqtt:
  broker: http://homeassistant.local
  
sensor:
 - platform: mqtt
   state_topic: esp01/temperature
   name: "Si7021 Temperature"
   unit_of_measurement: "°C"
 - platform: mqtt
   state_topic: esp01/humidity
   name: "Si7021 Luftfeuchtigkeit"
   icon: mdi:water-percent
   unit_of_measurement: "%"
   
sensor 2:
 - platform: mqtt
   state_topic: esp02/temperature
   name: "BME280 Temperature"
   unit_of_measurement: "°C"
 - platform: mqtt
   state_topic: esp02/humidity
   name: "BME280 Luftfeuchtigkeit"
   icon: mdi:water-percent
   unit_of_measurement: "%"
 - platform: mqtt
   state_topic: esp02/pressure
   name: "BME280 Luftdruck"
   unit_of_measurement: "hPa"

★☆★ Raumklima Sensoren ★☆★

►Si7021 Sensor:

* https://amzn.to/3agAP5Y – 1 x GY-21 Si7021 Feuchtigkeit und Temperatur Sensor

* https://amzn.to/33RdK8Q – 5 x GY-21 Si7021 Feuchtigkeit und Temperatur Sensor

►DHT11/22 Sensor:

* https://amzn.to/2Qxykn5DHT22 mit Platine und Kabel

* https://amzn.to/2QQiggL – 5er Set, DHT22 mit Platine und Kabel

* https://amzn.to/3aausjW – 3er Set, DHT11 mit Platine und Kabel

* https://amzn.to/3bhaELT – 5er Set, DHT11 mit Platine und Kabel

* https://amzn.to/3bXICGC – AM2303 mit Kabel

►MCP9808 Sensor:

* https://amzn.to/2YkWwNz – 1 x MCP9808 Hochgenauer Temperatur Sensor

* https://amzn.to/3aFehvU – 5 x MCP9808 Hochgenauer Temperatur Sensor

►BME280 Sensor:

* https://amzn.to/3bh2fIs – BME280

* https://amzn.to/2UoqCgw3er Set, BME280.

* https://amzn.to/2J5pnNU5er Set, BME280

* https://amzn.to/3hxcjR0 – 1 x GY-BME280 – SPI und I2C

★☆★ Microcontroller ★☆★

►Node-MCU ESP8266 Board:

https://amzn.to/2U7Urmn – NodeMCU ESP8266 ESP-12F

https://amzn.to/2J5wLJ3 – 3er Set, ESP8266 ESP-12F

https://amzn.to/3belvGd – 5er Set, ESP8266 ESP-12F

►ESP32 und ESP32 Node-MCU Boards:

https://amzn.to/3erQVKq – ESP32 Node-MCU Board

https://amzn.to/2Om89OW – 3er Set ESP32 Node-MCU Board

https://amzn.to/3erIkaS – 5er Set ESP32 Node-MCU Board

https://amzn.to/2Ct9H7c – 4 Stück ESP32 Module

Jumper Wire:

* https://amzn.to/2WxKwIl Female to Female F2F 40 STK. je 20 cm

* https://amzn.to/2xeKb2V – Set 3 x 40 STK. je 20 cm M2M/ F2M / F2F

►Breadboard:

* https://amzn.to/2QQ7JSL – Breadboard Steckbrett mit 830 Kontakten

USB Kabel:

* https://amzn.to/2y01THNUSB A auf Micro USB  Kabel 0.5m

* https://amzn.to/2xkgqgQ – USB auf Mini USB Kabel 0.5m

* https://amzn.to/2QBxCp7 – USB A zu USB B Kabel 0.5m

Netzteile:

* https://amzn.to/3beWY3V – 2er-Pack USB Ladegerät 5V/2A

* https://amzn.to/398WzP9 – Raspberry Pi 4 Netzteil, USB-C, 5.1V, 3A

* https://amzn.to/2wsS8Bh  – HomeSpot Netzteil 3A/5V inkl. 1,5M Micro USB Kabe

 

Alle Links mit “*” sind Amazon Affiliate Links. Ich bekomme bei einer Bestellung einen kleinen Teil vom Umsatz, ohne das euch dafür Mehrkosten entstehen.

Source Code für die Sensoren

Zum den Videos

★☆★ Wenn ihr den Kanal unterstützen wollt über ★☆★

oder über

Twint Spenden Code