Hi guys,
Thanks for looking at this post as I know there are 100’s of similar posts.
So I have set up OH2, MQTT, and the ESP device. I have followed almost every tutorial out there (this is my third day trying to figure it out).
MQTT talks to the ESP perfect via MQTT.fx and I can change the state of my LED with no issus.
My RaspberryPi IP is 192.168.1.44
Also do you normally have to reboot after changes made to any file?
So here is my code, please point out if anything is missing or I have made a stupid error!!
/etc/openhab2/services/mqtt.cfg:
mqtt:broker.url=tcp://192.168.1.44:1883
#mqtt:broker.clientId=openhabian
#mqtt:broker.user=
#mqtt:broker.pwd=
#mqtt:broker.qos=1
#mqtt:broker.retain=true
#mqtt:broker.async=false
I have commented out the rest apart from URL as I saw that in a tutorial.
.
/var/log/mosquitto/mosquitto.log:
1508572673: Client openhabian disconnected.
1508572673: New client connected from 192.168.1.44 as openhabian (c1, k60).
1508572683: New connection from 192.168.1.44 on port 1883.
1508572683: Client openhabian already connected, closing old connection.
1508572683: Client openhabian disconnected.
1508572683: New client connected from 192.168.1.44 as openhabian (c1, k60).
1508572693: New connection from 192.168.1.44 on port 1883.
.
/etc/mosquitto/mosquitto.conf:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
.
/etc/openhab2/items/home.items:
As you will notice im using MK Smart House as my guide line.
Switch MKSprinklerSystemZone1 "Sprinklers Zone 1" <water> {mqtt=">[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:ON:Z1ON],>[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:OFF:Z1OFF]"}
Switch MKSprinklerSystemZone2 "Sprinklers Zone 2" <water> {mqtt=">[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:ON:Z2ON],>[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:OFF:Z2OFF]"}
Switch MKSprinklerSystemZone3 "Sprinklers Zone 3" <water> {mqtt=">[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:ON:Z3ON],>[broker:MK-SmartHouse/utilities/MK-SprinklerSystem1:command:OFF:Z3OFF]"}
.
/etc/openhab2/sitemaps/home.sitemap:
...
Frame label="Outside"
{
Switch item=MKSprinklerSystemZone1
Switch item=MKSprinklerSystemZone2
Switch item=MKSprinklerSystemZone3
Switch item=SprinklerCycle
Switch item=SprinklerSystemSchedule
}
...
And this is the status of the MQTT:
â mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled)
Active: active (running) since Sat 2017-10-21 15:20:02 AWST; 40min ago
Docs: man:mosquitto(8)
https://mosquitto.org/
Main PID: 438 (mosquitto)
CGroup: /system.slice/mosquitto.service
ââ438 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf