Hi all
Just decided to move to OpenHAB 2 from an earlier version and have faced some slight issues with MQTT.
Previous version - all working fine.
OpenHAB 2 - only analogue sensor values are read. No digital values read nor messages sent.
Now running a Raspberry Pi with OpenHABianPi installed. Setup was fairly easy. MQTT binding installed, actions etc and then copied my items file across into the \OPENHABIANPI\openHAB-conf\items directory via the Samba service (using Windows to setup). I also moved my sitemap across into the relevant folder.
Surprised that I cannot edit MQTT settings within the PaperUI, I’ve edited the mqtt.cfg file and mqtt-eventbus.cfg files which were automatically created upon binding install. I’ve literally copied settings from the openhab.cfg file on the previous version.
I want to keep my Mosquitto MQTT broker on a separate Pi - in fact its my original that still has the previous version of OpenHAB running simultaneously until OpenHAB is working, so rather than localhost in the config files I’ve included the IP address and port. The two Pi’s are on my local network, with firewall exceptions for port 1883 etc. Using mqttlens I can see messages flying to/from devices/broker as normal.
mqtt.cfg file:
#
# 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
localbroker.url=tcp://172.16.1.230:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
localbroker.clientId=OpenHAB
# 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.
localbroker.qos=1
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
localbroker.retain=true
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
localbroker.async=true
# 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>
mqtt-eventbus.cfg
# Name of the broker as it is defined in the openhab.cfg. If this property is not available, no event bus MQTT binding will be created.
broker=localbroker
# When available, all status updates which occur on the openHAB event bus are published to the provided topic. The message content will
# be the status. The variable ${item} will be replaced during publishing with the item name for which the state was received.
statePublishTopic=openHAB/stateUpdates/${item}/state
# When available, all commands which occur on the openHAB event bus are published to the provided topic. The message content will be the
# command. The variable ${item} will be replaced during publishing with the item name for which the command was received.
commandPublishTopic=openHAB/commandUpdates/${item}/command
# When available, all status updates received on this topic will be posted to the openHAB event bus. The message content is assumed to be
# a string representation of the status. The topic should include the variable ${item} to indicate which part of the topic contains the
# item name which can be used for posting the received value to the event bus.
stateSubscribeTopic=Ourplace/${item}/state
# When available, all commands received on this topic will be posted to the openHAB event bus. The message content is assumed to be a
# string representation of the command. The topic should include the variable ${item} to indicate which part of the topic contains the
# item name which can be used for posting the received value to the event bus.
commandSubscribeTopic=Ourplace/${item}/command
Here are one of my digital and analog items:
Switch Light_GF_Dining_Stand "Stand Lamp" (GF_Dining, Lights_GF) {mqtt=">[localbroker:Ourplace/Kitchen/RF/=02:command:ON:default],>[localbroker:Ourplace/Kitchen/RF/=02:command:OFF:default]"}
Number Temperature_GF_Kitchen "Temperature [%.1f °C]" <temperature> (Temperature, GF_Kitchen, FTS1) {mqtt="<[localbroker:Ourplace/Kitchen/DHT22-1/T:state:default]"}
My analog sensor values such as temperature, humidity from devices are passing through my broker and being presented on the OpenHAB 2 GUI perfectly. I can edit the mqtt.cfg topics and intentionally make them invalid, proving loss of comms etc.
When I change state of an item on OpenHAB 1.x, I see the broker receive the message and I would expect the state of that item to then change in OpenHAB 2 GUI (as its reading the broker). This does not happen.
When I change the state of an item in OpenHAB 2 I would expect to see a message be presented at the broker. Instead, nothing appears.
I suspect there if the issue was just publishing, this may be easier to solve. The fact that OpenHAB 2 is not reading digital values but does read analog values causes me some concern.
Assistance resolving this would be fantastic.
Thank you.