Added instructions for getting the Hassio MQTT broker online with a simple sensor

master
androiddrew 7 years ago
parent fc2d84dcd8
commit 824cd6eabf

@ -57,4 +57,42 @@ ampy -p /dev/tty.SLAB_USBtoUART -b 115200 ls
## MQTT on Hassio
PLACEHOLDER
Assuming you have [Hassio installed](https://www.home-assistant.io/getting-started/) (on a raspberry Pi3 for example). You will find the [official MQTT broker](https://www.home-assistant.io/docs/mqtt/broker/) documentation lacking in that small amount of detail that will get you up and running. This section is supposed to help take you that final mile.
### The MQTT Broker
Let's start assuming you are going to use the downloadable [MQTT broker](https://www.home-assistant.io/addons/mosquitto/) from the add-on store. You will also want to have the [configurator package](https://www.home-assistant.io/addons/configurator) installed too. Open up the configurator web-gui and find your `/config/configuration.yaml` file and addc the following entry at the bottom of the file:
```yaml
#MQTT Setup
mqtt:
broker: 0.0.0.0
port: 1883
```
This will ensure that your broker properly configured. Now just make sure that you set the `Start on boot` to True in the addon details and restart your home-assistant.
### An MQTT Sensor
Once again you may be a little confused by the official documentation for setting up an [MQTT sensor](https://www.home-assistant.io/components/sensor.mqtt/). Assuming you are using the sample photoresitor light sensor that is included in this repo. Go back to your `/config/configuration.yaml` and this entry:
```yaml
#MQTT Light Sensor
sensor office_light:
- platform: mqtt
name: "Office Light"
unit_of_measurement: "No."
# Note your esp8266 will have a different MAC id. You can find the sensor's full topic path in the logs of the MQTT add-on
state_topic: "light/esp8266_aa00f800"
# Our json is a simple single value extracted with this jinja2 template
# More templating info can be found here https://www.home-assistant.io/docs/configuration/templating/#processing-incoming-data
value_template: "{{value_json.payload}}"
# Material design icons https://cdn.materialdesignicons.com/2.3.54/
icon: mdi:lightbulb-on-outline
```
This should create an MQTT sensor that you will find on your Overview homepage after you restart the Hassio server.
### Testing your new topic
Let's assume you haven't built the ESP8266 sensor. You can still test your service through the Hassio Developer tools at `http://hassio:8123/dev-service`. Select `mqtt.publish` as just craft a simple payload. Once you call the service you should see the result in the Sensor's component on your Overview
Loading…
Cancel
Save