MQTT, follow profile and Number items

  • Platform information:
    • Hardware: MacBook / Raspberry Pi 4
    • OS: macOS 11, Debian 10.6
    • Java Runtime Environment: OpenJDK 8
    • openHAB version: 2.5.10
  • Issue of the topic: I’d like to forward updates of a Number item to an MQTT topic
  • Please post configurations (if applicable):

items

Number Buero_Temperature "Temperatur [%.2f °C]" <temperature> (Buero) {channel="mqtt:topic:panic:home_bus_knx_5_0:21", channel="mqtt:topic:panic:home_bus_can_node20:a10" [profile="follow"]}

things

Bridge mqtt:broker:panic [...] {
Thing topic home_bus_knx_5_0 "KNX" @ "Untergeschoss" {
Channels:
  Type number : 11 [stateTopic="home/bus/knx/5/0/11"]
  Type number : 21 [stateTopic="home/bus/knx/5/0/21"]
  // ...
}
Thing topic home_bus_can_node20 "CAN" @ "Node 20" {
Channels:
  Type number : a10 [stateTopic="home/can/node20/analog10", commandTopic="home/can/node20/analog10"]
  // ...
}
// ...
}

The read-only channel “home_bus_knx_5_0:21” works well, the Item’s state is updated according to the sensor’s changes.

I expected that the changes are forwarded to all channels with “follow” profile, but nothing happens on the
“home_bus_can_node20:a10” channel. I’ve also tried to set postCommand=true on this channel, but it makes no difference.

The problem is not on MQTT side, as publishing from a rule works.

What am I doing wrong?

The goal is to forward data from a KNX bus to a CAN bus (both via an MQTT for reasons).

Thanks for any help

Gerrit

This is working for me, with your configuration adjusted slightly because I configure my MQTT bridge separately to the MQTT things:

OH2 Things

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [
	host="192.168.1.92",
	secure=false,
	port=1883,
	clientID="OpenHAB2",
	username="",
	password=""
]
Thing mqtt:topic:home_bus_knx_5_0 "KNX" (mqtt:broker:MosquittoMqttBroker) @ "Untergeschoss" {
Channels:
  Type number : 11 [stateTopic="home/bus/knx/5/0/11"]
  Type number : 21 [stateTopic="home/bus/knx/5/0/21"]
}

Thing mqtt:topic:home_bus_can_node20 "CAN" (mqtt:broker:MosquittoMqttBroker) @ "Node 20" {
Channels:
  Type number : a10 [stateTopic="home/can/node20/analog10", commandTopic="home/can/node20/analog10"]
}

OH2 Items

Number Buero_Temperature "Temperatur [%.2f °C]" <temperature> (Buero) {channel="mqtt:topic:home_bus_knx_5_0:21", channel="mqtt:topic:home_bus_can_node20:a10" [profile="follow"]}

MQTT Explorer screenshot

After manually sending numbers to home/bus/knx/5/0/21

1 Like

Your current Buero_Temperature setup has the follow profile listening for state updates coming in on MQTT channel a10. The follow will transform that into a command to the linked Item. If the linked Item has any conventional non-follow links to bindings, the Item command wil be forwarded to the binding, MQTT channel home_bus_knx_5_0:21 in this case.

That means, the documentation here is wrong:
“any state that is sent to an Item will be forwarded from this Item to any linked Channel with the follow Profile”

It is actually not, the configuration works as expected after a restart.

Yes, it worked, after stopping and starting openHAB.
Yay, that’s cool and it reduces my rules a lot!

Thank you very much (it works with my original configuration as expected)

Ah, you may have fallen victim to the annoying bug where openHAB sometimes doesn’t properly register changes made to Things files. You can restart openHAB, or do this.

1 Like