2019-08-13 20:40:35.694 [vent.ItemStateChangedEvent] - MQTTTest changed from 100 to 42
2019-08-13 20:40:35.694 [vent.ItemStateChangedEvent] - MQTTTest changed from 100 to 42
But when changing one item through karaf console, it only changes the local instance, not the remote instance. I’ve also subscribed ‘#’ through mosquitto_sub but nothing arrives.
I simply wanna sent every state of my item from one OH Instance to another (one way).
Changing from state to command (which nomenclature is misleading to me) solves it.
But as @Seaside said it only works after restarting OH
Reading this, I guess you are on openHAB 2.4. It is a known issue of this MQTT Version, after a change of the related things file a restart is needed. This is solved in the current milestone version!
commandTopic doesn’t do that either. It sends each command out on MQTT. It does not send states.
For example, if you command a Dimmer ON, it will send ON to MQTT.
The Dimmer will probably change to state 100%.
That state change will not be sent.
I have some measurements like the ones from my smartmeter that I wan’t to sent from one OH instance to another. It works for me with an old OH2 instance together with MQTT1 binding. Now I wan’t to do the same thing with MQTT2 binding but it doesn’t seem to work.
No, you just need to be clear about what “this” is,
I would guess that what you want to do is copy state updates of your energy meter Item to MQTT ??
Okay, so first thing you need is to define an MQTT channel that will put things out over MQTT.
You’ve done that part, using commandTopic
Now, that works in the normal openHAB way and only sends commands out over MQTT., never state changes.
We need a tool to convert state changes into commands, so that we can use that channel. That tool is the follow profile. We can link a channel to an Item and the follow profile will listen for Item state changes, then send them to the channel as though they were commands.
Number .... { channel="usual:channel:for:updating:item", channel="mqtt:topic:mosquitto:energy:smart_meter_external_supply" [profile="follow"] }
I don’t know quite what happens with units involved though.
I agree with rossko57, the follow profile will be the closest to what you are used to. But there is another way if you have a lot of these Items. See Marketplace MQTT Event Bus. However, I’m not certain it works with 2.4, you may need to move to 2.5 M1 or M2.