i am a beginner in SmartHome.
i successfully flashed my Sonoff 10A with ESPEasy and want to control the device via openHAB.
this is my mqtt.cfg ( mqtt-binding is installed in openhab )
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.168.1.100:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>
# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
With MQTT.fx i can subscribe to the “SystemInfo/Uptime” on the ESPeasy - so the broker/settings should work.
( /Sonoff_1/uptime/Minutes )
how do i manage this thing to work in openhab ? i want to turn it on/off
In case of the Sonoff it’s a good idea to go with the Tasmota firmware. There is a whole thread on the Sonoff+Tasmota here in the forum.
You’ll also find a detailed description of how to connect modules to openHAB, with item examples and everything. I’d advice to safe you the trouble and switch right now.
Regarding your problem: first there shouldn’t be a starting slash in an mqtt topic. Seems however to be consistent between your configs. Next issue I’m seeing is that your broker is called “broker” but you are trying to talk to “mosquitto”. One other problem I’m seeing is, that you didn’t provide the login credentials in your mqtt.conf. Is the binding even connected?
Did you read the binding Readme carefully?
Thanks for your Answer Thom! - its a lot to learn for me atm with openhab, i tried the whole day to get this thing to work
i dont know if the binding is connected - where can i check this ?
i also dont believe that i have read the same “readme” that you are speaking about - could you pls share a link to it ?
this one ? http://docs.openhab.org/addons/bindings/mqtt1/readme.html
i tried to understand this, but its sometimes hard to follow, when you have never done this before
so how do i connect/check the mqtt-binding ?
Okay getting started is sometimes hard but the steps are actually straight forward. Let’s see…
Install and set up a broker. You’ve used the one provided through openHABian, perfect
Connect with a desktop client to the broker to see what’s going on. Seems like you are already doing so, perfect. (mqtt-spy is a better choice but mqtt.fx is okay)
Now get the openHAB binding connected (then tested)
Install the binding through Paper UI
Configure it via $OPENHAB_CONF/services/mqtt.conf (you’ve already done that but I believe you’ve missed the auth credentials? Should look similar to:
With this one in place you should be able to do a first tst. Use your mqtt.fx to publish the Message “ON” to Topic “testing/mqtt/topic”. Check the log once again!
you were honestly not the first one to have starting trouble with the MQTT Binding in the beginning of their openHAB adventure. I’ve taken what I’ve written above over into a Tutorial. Could you please check if anything is missing or not clear to a newcomer?
The first line defines the Item with all it’s details, the second defined the outbound MQTT topic, the third the inbound. Because you didn’t show all needed details I’m not sure if the topic for the latter is correct.
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.160.0.14:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#broker.clientId=openhabian
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
broker.user=openhabian
# Optional. Password to authenticate with the broker.
broker.pwd=password
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>