How do I connect Happy Bubbles via MQTT to OH2

  • Platform information:
    • Hardware: Rpi Zero W
    • OS: _openhabianpi latest
    • Java Runtime Environment: _openhabianpi
    • openHAB version: 2.2.0-1
  • mosquitto and all mqtt stuff installed and configured.

I am new to MQTT and I am struggling with the following task:

I want to create a precence detector that can identify different persons wearing a beacon and turn on different lights depending on the person that enters the room.
I have installed a happy bubbles beacon receiver. This rceiver detects the beacon I am wearing and sends a mqtt message to mosquitto. This is working - I checked it with MQTTfx. The name of my beacon is ‘Mike is here’ the name of the receiver is happy-bubbles-1
The topic and the message are as follows:

Topic: happy-bubbles/presence
Message: Mike is here is most likely in happy-bubbles-1 with average distance 0.471933

Now what I would like to do is trigger a switch when this message arrives. The distance will vary so it must not be considered. If it can be extracted than it might later be useful for extended logic. The switch should turn on a light. Thats it.

I started in my items file with this:

Switch GF_Boiler_Motion “Mike is here” (GF_Boiler, gMotion) {mqtt="<[mosquitto:happy-bubbles/presence:state"}

But then I have no clue how to transform that message into a switch. It is only neccessary to turn the switch on. The light should be turned on everytime the message is rceived. If I leave the room no more messages will arrive and I will use a timer to switch the light off.

From the docs:

Item myItem {mqtt="[::::<regex_filter>], [:::], …"}

So what you need is to connect to the given broker, subscribed to the given topic (which is what you have) and issue the command ON anytime you see a message that says “Mike is here…”. So based on the docs above your config should look like:

Switch MySwitch { mqtt="<[mosquitto:happy-bubbles/presence:command:ON:Mike is here.*happy-bubbles-1.*]" }

That will issue an ON command to MySwitch anytime a message matching the regular expression at the very end (i.e. “Mike is here.happy-bubbles-1.”) is published to happy-bubbles/presence on the mosquitto broker.