Homeassistant custom MQTT sensors easy import
Introduction:
To my current meter with MODBUS RS485 output into my Homeassistant
to be able to integrate, after some considerations,
Disable integration via MQTT.
The following short contribution
I exemplarily show how to use in Homeassistant MQTT sensors
can integrate. The Automatic Discovery function of Homeassistant
I do not use it yet, a corresponding contribution will be
I'll be back.
Preparations
At first, it must of course be ensured that the data on the MQTT Brokers are available, so it was first checked that the ESP8266 is connected to my home broker.
In Homeassistant, the MQTT Addon must also be installed and be configured. Since I do not abuse this blog as a waste mine I don't want to explain how this addon will be installed here as this is explained by Google
– In principle, the Homeassistant Doku explains the fun very well. https://www.home-assistant.io/integrations/mqtt/
Customize the config.yaml
Once Homeassistant and Broker are ready, we can get to the Config file and edit the config.yaml.
If not yet we add the point “sensor” and then make the following:
sensor:
- platform: mqtt
name: "mainEnergyMeterTotalConsumptionForwardKwh" #Name im frontend
unique_id: sensor.mainenergymeter_total_forward_consumption_kwh_new #unique ID um Einstellungen im Frontend anpassen zu können.
state_topic: mainPowerMeter/forwardenergy/counted/total #Broker Path um die Daten zu Empfangen
unit_of_measurement: "kWh" #Zahleneinheit - in meinem Fall (Stromzaehler) kWh.
Finally, Homeassistant must be restarted (Developer Tools -> YAML -> Check Configuration -> (If Config correct) -> Restart
The sensor can then be found under Settings -> Devices -> Entities.
Back…