Close

OpenHab Configuration

A project log for Home automation: thermostat with ESP8266 & OpenHab

A project about Home Automation. I want to replace my old thermostat with an IoT ESP8266 + OLED 128x64 Screen + OpenHab + MQTT + Micropython

jorgeJorge 08/03/2016 at 22:440 Comments

Once you have your openhab installed, you will need to use the MQTT Binding addon in order to use MQTT with openhab.

In your openhab configuration file (probably "openhab_default.cfg") you have to include the configuration of the MQTT browser. I've included:

mqtt:mosquitto.url=tcp://localhost:1883
mqtt:mosquitto.clientId=openhab
mqtt:mosquitto.qos=1
mqtt:mosquitto.retain=true
mqtt:mosquitto.async=false

I'm using message retain and qos=1 so everytime I read the MQTT from the ESP8266 there's always an ON or OFF message (that the esp8266 obeys).

In the items folder, in the config file, you can add something like this:

/* MQTT Sensors */
Number Temperature_GF_Living "Temperature [%.1f °C]" <temperature> (Temperature, GF_Living) {mqtt="<[mosquitto:/sensor1/tem:state:default]";}
Number Humidity_GF_Living "Humidity [%.1f %%]" <water> (Humidity, GF_Living) {mqtt="<[mosquitto:/sensor1/hum:state:default]";}
Switch Light_GF_Living "Led" (GF_Living, Lights) {mqtt=">[mosquitto:/sensor1/led:command:on:on],>[mosquitto:/sensor1/led:command:off:off]";}

Restart openhab and everything should work.

Discussions