OpenHAB 2.4 + Tasmota (MQTT + JSON) on RF Bridge and PIR Motion Sensor

  • Platform information:
    • Hardware: armv7(32bit)/1GB/120GB
    • OS: Raspbian 9 (stretch)
    • Java Runtime Environment: zulu-embedded-8-armhf
    • openHAB version: 2.4.0-1
  • Issue of the topic: How to convert tasmota MQTT JSON response into OpenHAB 2.4.x Item
  • Please post configurations (if applicable): house.items
String esp_8285_PIR_1 "Living Room Sensor" <motion> (Test_Group) {channel="mqtt:topic:5a2dc578:Channel_RFBridge_1_Item1"}



The value of “Data” is the unique identifier of the PIR that I would like to link to.


Text item=esp_8285_PIR_1 label="Living Room Sensor" icon="motion"

PaperUI -> Things -> MQTT Client (Generic MQTT) -> Channel:

Configured as String

Log Viewer (frontail):

2019-05-12 13:13:36.612 [vent.ItemStateChangedEvent] - esp_8285_PIR_1 changed from NULL to {"RfReceived":{"Sync":12420,"Low":430,"High":1250,"Data":"EC4B2E","RfKey":"None"}}

I’m trying to get Item (esp_8285_PIR_1) to display motion detected information in openhab basicui. But so far I’m not getting anything as I am not familiar with JSON and a complete beginner in OpenHAB. I have managed to successfully bind other MQTT clients to OpenHAB, but this is the first time I had to work with JSON. From what I gather, I will need a JSONPATH or some kind of parser, but I don’t understand the syntax because all the examples that I find online, seems to use the broker syntax and not the channel syntax from PaperUI.

My guess is, that if it starts working, the next step would be to create a rule, to make the detection last only for 10 seconds and clear, but I’m not there yet.

Any help would be appreciated.

So, the message you posted gets published when the device sees motion and only in motion? All other sensor readings and device info gets published to some other topic? There is nothing about that message that indicates it’s a motion detection event so does that mean the whole message means motion was detected?

hello, yes the topic is setup in PaperUI, in Generic MQTT Thing


value of Data contains the unique identifier, e.g. EC4B2E


I receive this message, when there is motion, there is no other message that says it stopped. It is a once off message, per motion detected cycle. Would I need to use a mapping, or a JSONPATH transformation? I saw this was an option to install under PaperUI -> Add-ons -> Transformations.

I only have one PIR sensor so I cannot compare with another, but from what I have read online with YouTube videos indicating that I should search for the Data, apparently door sensors have more information, but I don’t have any right now. The ones from iTead Sonoff, only sends Door Open message. Other 433MHz sensors might also send door closed, and battery status.

Do different sensors report to different topics it do all the PIRs (when you expand) publish to the same topic?

There is a dozen ways to handle suffer like this. Choosing the best one depends on such details.

My guess would be that the topic will be the same for all, coming from this single tasmota device. If I was to add another PIR sensor, door sensor, or a button to this RF bridge. Well, I do not add anything to tasmota. The device is listening on RF 433MHz for any device, and I want to filter for messages that are relevant to me. Each sensor device will have a different value in Data, to identify it.

I think I am trying to achieve something similar to this post. :slightly_smiling_face:

Ok, so what I would do is use a REGEX like I documented in MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters.

The difference will be instead of chaining this to another transform you will just set up the regec to match or not.

Then use the ON command field (I’m on my phone and can’t look up the right name) to send ON when ever any message is received.

The REGEX should filter out those messages that don’t apply to the device. The ON command will set the Switch Item lined to the Channel to get an ON command when ever a message that passes the regec is received.

1 Like

Now for the question, how do I add this REGEX?

So if I understand correctly, there are two ways of using JSONPATH, one would be through PaperUI:


String esp_8285_PIR_1 "Living Room Sensor [JSONPATH($.RfReceived.Data):%s]" <motion> (Test_Ryan) {channel="mqtt:topic:5a2dc578:Channel_RFBridge_1_Item1"}

So, the next step would be, to create a rule and then post to another item? Where I would then use esp_8285_PIR_1 as a mechanism to narrow down to the ID. So I need a String item place holder that will be showed in BasicUI?

Is my understanding correct?

Currently in the BasicUI I will see:

If I was to setup another PIR, then the code will keep updating. My understanding is, that I can use mappings, but that only works on a switch or selection:

Is the only way now forward to create a rule, which I haven’t done yet and publish to another string Item?

I don’t think you actually read the tutorial I linked to in post 6. It shows that it hasn’t been clicked on.

You don’t need JSONPATH at all. You don’t care about any individual piece of data in the message beyond whether or not it contians “EC4B2E”.

Please at least review the tutorial I posted and then come back with questions if you still have some.

Hello, and thank you for taking the time to respond. To be honest, I didn’t understand your tutorial at all. I’m an absolute beginner, I have no knowledge of JSON, or REGEX or OpenHAB 1.x or OpenHAB 2.x or even MQTT. All of this is new to me. I honestly don’t know how to translate what you mentioned in the tutorial into what I need and want.

I’m just trying to figure out and build on top of what I already know, based on this tutorial.

  1. In the “Incoming value transformation” put REGEX:.*(EC4B2E).*
  2. In “Custom On/Open value” put EC4B2E
  3. Click “Show More” and enable “Is Command”

Of course now that I’ve told you exactly what to do you still have no idea why and likely little idea how to apply this to some other problem.

It’s better to struggle and come out actually understanding.

1 Like

Thank you, now I understand better.

This is my rule that I created, based on the JSONPATH approach. Which shows DETECT in the Basic UI and removes the value after 5 seconds. This JASONPATH syntax example. I got from here.

rule "esp8285 Sensor Processing"
    Item esp_8285_PIR_1 received update // Need received update if Data has not change but button still pressed
    if (esp_8285_PIR_1.state == "EC4B2E")

Which required me to have an additional item to display in the BasicUI

String my_Display                     "[%s]"                  <motion>      (Test_Group)

With your approach, I take it that I don’t need this place holder item, which I called my_Display. I can do everything directly to esp_8285_PIR_1. Thank you for showing me another way of doing it. I have not considered and understood the full context until you spoon fed me. :slightly_smiling_face:

Now it makes sense. Much appreciated.