Publish mqtt message

Hello,
when I open/close my window my zwave device gives me a feedback about the opening status of the window.

here is my z wave device:

Switch Z_way_switch_DoorWindowSensor14 "Balkontür [MAP(windowdoorcontact.map):%s]" <door> (group_house_doorwindow){ channel="zway:zwayDevice:smarthome:14:sensorBinary-ZWayVDev_zway_14-0-113-6-Door-A" }

and

if i open it I want to publish this message through mqtt broker

topic:
statusdisplay/status/window/schlafzimmer

message:
open

if i close I want to publish this message through mqtt broker

topic:
statusdisplay/status/window/schlafzimmer

message:
close

how do i do this??

Thanks

I would expect you would use a couple of rules. Have you tried that?

Not yet…i thought about the easiest solution

You did #8, please look at #9 & #10

An alternative is create an MQTT thing and assign a command channel to your existing Item (as well as your zwave) with a follow profile.

1 Like
Bridge mqtt:broker:mosquitto "MQTT Broker: Mosquitto" [ host="xxxxx", port=1883, clientID="openHAB2", secure="false"]
Thing mqtt:topic:statusdisplay (mqtt:broker:mosquitto) {
    Type string : schlafzimmer "schlafzimmer" [ stateTopic="statusdisplay/status/window/schlafzimme"]
}

i started with this but how do i send a message now???

Have a look here:
https://www.eclipse.org/smarthome/documentation/development/bindings/profiles.html#followprofile
So you need to create an Item for your mqtt thing and make it follow according to the link above. You than have to Change the topic you want to publish to to a command topic in your thing definition.
Best regards Johannes

If you want to send a message out over MQTT, you want command topic not state topic.

After you’ve fixed that channel, you can link it to your Item as a second channel, but qualify it with the ‘follow’ profile.
That will make the channel see any Item updates as simulated commands and send to MQTT

1 Like

My configuration looks like

Bridge mqtt:broker:mosquitto "MQTT Broker: Mosquitto" [ host="xxxxx", port=1883, clientID="openHAB2", secure="false"]
Thing mqtt:topic:statusdisplay (mqtt:broker:mosquitto) {
    Type string : schlafzimmer "schlafzimmer" [ commandTopic="statusdisplay/status/window/schlafzimmer"]
}


Switch test "test" <switch>  [ "Switchable" ] {channel="mqtt:topic:statusdisplay:schlafzimmer" [profile="follow", profile-parameterID="Z_way_switch_DoorWindowSensor14"]} 

but no message is published?? How to I say it should publish “open” “close” when the switch is switched to “on” off" ??

Do you see Z_way_switch_DoorWindowSensor14 changing in your events.log? What to?

You’ve linked a string type mqtt channel to a switch type Item, I don’t know if anything works with that.
If you use a switch channel and want to convert ON/OFF to something else, you could use transformationPatternOut :but I think you need to be on bonding 2.5M1 for that.

the switch alone is working

Type switch : schlafzimmer "schlafzimmer" [ commandTopic="statusdisplay/status/window/schlafzimmer", on="open", off="close"]

Switch testmqqtswitch "test" <switch>  {channel="mqtt:topic:statusdisplay:schlafzimmer" [profile="follow", profile-parameterID="Z_way_switch_DoorWindowSensor14"]} 

Switch Z_way_switch_DoorWindowSensor14 "Balkontür [MAP(windowdoorcontact.map):%s]" <door> (group_house_doorwindow){ channel="zway:zwayDevice:smarthome:14:sensorBinary-ZWayVDev_zway_14-0-113-6-Door-A" }

But the mqtt switch is not following the Z_way_switch_DoorWindowSensor14 switch. need i do this by rule???

event.log

2019-08-09 21:21:19.152 [vent.ItemStateChangedEvent] - Z_way_switch_DoorWindowSensor14 changed from OFF to ON

I’d do it this way, put the channel-follow directly on the source Item

Switch Z_way_switch_DoorWindowSensor14 "Balkontür [MAP(windowdoorcontact.map):%s]" <door> (group_house_doorwindow){ channel="zway:zwayDevice:smarthome:14:sensorBinary-ZWayVDev_zway_14-0-113-6-Door-A" , channel="mqtt:topic:statusdisplay:schlafzimmer" [profile="follow"] }
1 Like