Openhab 4.3.2 with Tasmota 14.2.0 MQTT to use a DS18B20 sensor

I am trying to configure
Openhab 4.3.2 with Tasmota 14.2.0 MQTT to read a DS18B20 sensor on GPIO0

I have been struggling to get openhab to read the sensor data. the MQTT broker is running, and a thing has been added for the Tasmota (nodemcu). However I’m stuck. I’ve tried following the various how toos. All so far are for older versions of openhab or tasmota.

I see things about linking, and items, types, code, and all. At this point I’m stuck. Not all of the feilds like up in openhab to what are in the tutorials. I believe this is becuase of updated versions of openhab. I’m not sure what I am missing or needing to do to be able to read the temperature in C from the Tasmota to displaying that temperature in F in the openhab gui.

Any advice would be greatly appreciated.

–James

Forget about openHAB for the minute - do you have MQTT Explorer installed, can you connect it to this broker you have running, and using MQTT Explorer can you confirm the values you want are being sent from your Tasmota device to the MQTT broker?

Please share a screenshot so we can verify the full path(s) for the data you want to insert into openHAB.

Hi, we need more details, please show what you have in the Tasmota console.

Here’s how I configured this a couple of months ago. It has been working flawlessly since:
Let’s look at the Tasmota side first:

  1. wire the DS18B20 to the tasmota device as documented e.g. here: DS18x20 temperature sensor - Tasmota. The documentation claims you can connect multiple sensors to one pin and I can confirm this. On my device four DS18b20 are connected to the same pin.

  2. Configure the Tasmota device. Here is my hardware configuration:
    image

  3. At this point you should see the temperature on the Tasmota main screen.

  4. Go to Tasmota Web Interface → Configuration → MQTT and configure your MQTT broker. If your MQTT broker uses Username/password, enter them here and skip the next step

  5. If your MQTT does NOT use Username/password, go to Tasmota Console and enter the command backlog mqttuser 0; mqttpassword 0;. You should see a successful connection to your MQTT Broker in the console.

  6. In the Tasmota Web Interface go to “Console” and enter the command TelePeriod 10. You should now see output in the Tasmota Console containing text similar to this: MQT: tele/YourModuleName/SENSOR = {"Time":"2025-01-26T00:17:28","DS18B20-1":{"Id":"3C15E381206C","Temperature":49.4}... every 10 seconds!

  7. Adjust TelePeriod to whatever suits you best. Mine is set to 180 (seconds)

This should be all that is required to configure Tasmota to report DS18B20 temperature on MQTT every TelePeriod seconds.

Note that Tasmota will report temperature in °Celsius. Conversion to Fahrenheit will be handled by openHAB later. You could also change the Tasmota output instead, using the command SetOption8 1 in the Tasmota console, but I never tried that myself (what is this Fahrenheit thing, anyway? :slight_smile: )

On to the openHAB configuration:

openHAB uses THINGS to represent (or connect to) physical, well, things. Like your Tasmota device. See Concepts | openHAB.

You first need to create an MQTT thing. This requires having the MQTT Binding installed in openHAB (MainUI → Administration → Add-on Store). There is a good description here: Adding Things - Advanced | openHAB.

In your particular case, in openHAB MainUI go to Administration → Settings → Things and click the blue, round ‘+’ button in the lower right of the window. Select the MQTT Binding. If you have not configured a connection between openHAB and your MQTT broker yet you need to do so first. Follow the chapter “Create the Bridge Thing” here: Adding Things - Advanced | openHAB

If the bridge is configured correctly it should show up as “Online” in your “Things” list.

Add the Tasmota thing: “+” button on the “Things” page → MQTT Binding → “Generic MQTT Thing”. Pick your previously configured bridge and click “Create”.
The “Thing” exists now, and can listen to topics from MQTT, but we now need to tell it, which topics and which data from these topics (here: temperature values) should be used. Every required data point (i.e. every temperature value, in my case I have 4 sensors which send 4 temperature values) will be extracted by openHAB and will be sent over a “Channel” to the respective openHAB “item” (which we have not created yet; We’ll do so after a few steps).
So create a “Channel” as described in the documentation page. The channel configuration needs these parameters (check the “Show advanced” checkmark in the upper right to see all options):

  • MQTT state topic: tele/YourTasmotaName/SENSOR
  • Unit of Measurement: °C - Note: This is really important if you want openHAB to convert the value to °F later!
  • Incoming value transformations: JSONPATH:$.DS18B20-1.Temperature - Note: I’m not sure about the part “DS18B20-1”. If you have only one sensor connected Tasmota may send “DS18B20” here, instead. Verify this in the Tasmota console.
    The “incoming value transformation” is use the extract the value we are actually interested in (the temperature) from the long JSON string which Tasmota sends.

This completes your “Thing” configuration. You now have an openHAB “Thing” which will receive a temperature value from MQTT whenever it is updated from Tasmota and provide it in a “Channel” for you to use.

Finally, let’s create an “ITEM” to finally be able to actually use the temperature value in openHAB:

Still in the Thing configuration screen you should now see your channel. At the bottom there is a button “Add points to Model”. Click it and select your newly created channel. Fill out all the fields but pay special attention to “Unit”: Enter “°F” there and the item will always return the temperature in °F. The conversion from °C (which was the unit of the value provided to the Thing by Tasmota) to °F is handled by openHAB.
You should also configure “Semantic Class: Measurement” and “Semantic Property: Temperature” beside the mandatory other fields.

If you defined your Semantic Model | openHAB well after installing openHAB you can now go to your openHAB Dashboard, select the “Properties” tab, click on “Temperatures” and your temperature should be visible there. There is even a chart if you click the temperature item.

Done. Not exactly a one-step procedure, but that is mostly due to using an MQTT “Thing”: These are by design very generic and provide no info to allow openHAB to assist in configuring the “Thing”. But it’s not rocket science, either :slight_smile:

Everything else (using the temperature in a rule to automate things, creating a widget to show the temperature directly on the dashboard, …) is described in the documentation and in many posts here in the forum. Enjoy the openHAB experience :slight_smile:

2 Likes

To start, the broker is running on the Pi with openhab. I have attached the explorer screen shot. I’m not sure how to configure openhab or tasmota correctly to read the temperature. It is the ds1820 sensor, that is listed in the screen shot, just a single ds1820 at this moment.

Certainly, This is the console output of the tasmota.

Thank you for the instructions, I followed those, there were a couple of things I was still not sure about. I still ended up with “NULL” as the output. I’m not sure what I missed maybe. I see it “online” in openhab, however it still has null as the output.

The Tasmota part looks good according to console output. If the Thing is Online the issue is probably in the channel definition. Post the contents of the “Code” tab of the thing, let’s see if we can find something.

Certainly, this is one thing I was definitely not sure of the format. It doesn’t seem to make sense.

image

Thank you

Do you have any other devices set up in openHAB using MQTT? Can we see the code of your MQTT Broker Thing?

What do the openHAB logs say? I wonder if the Broker Thing might not be connecting to the broker.

Hmm. The code you posted looks identical to what is working in my installation, except for the quotes around the JSONPATH transformation. Just a wild guess, but can you try to remove the quotes around JSONPATH:$.DS18B20.Temperature and see if that changes something?

If this does not work you could try to unplug the Tasmota device from the power supply and check if the thing goes „Offline“ after a few minutes: this would be an indication whether your MQTT bridge thing works or not, as hafniumzinc suggested to check for

I did do this, it does show it go offline, and then go back online again when I plug it back in. I did see some errors in the log files. That are in response to hafniumzinc’s question. It seems maybe the naming is wrong? I’m not sure.

Unfortunately this is the first MQTT thing, I do not have anything else yet that is using and working with MQTT. But it does show accurately if it is online/offline. Below is the code for the MQTT bridge. And then snips from the error logs.

UID: mqtt:broker:2ce63c5d79
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
lwtQos: 0
publickeypin: true
keepAlive: 60
clientid: d880fab4-4ebd-4112-bd2b-90dcde648d61
hostnameValidated: false
secure: false
birthRetain: true
shutdownRetain: true
certificatepin: true
protocol: TCP
password: mqtt1234
qos: 0
reconnectTime: 60000
mqttVersion: V3
host: 192.168.1.138
lwtRetain: true
enableDiscovery: true
username: mqtt
channels:

  • id: ds1820
    channelTypeUID: mqtt:publishTrigger
    label: ds1820
    description: ds1820
    configuration:
    stateTopic: tele/ds1820/SENSOR

from events.log:

2025-02-04 07:14:08.161 [INFO ] [openhab.event.ChannelTriggeredEvent ] - mqtt:broker:2ce63c5d79:ds1820 triggered {“Time”:“2025-02-04T07:14:07”,“DS18B20”:{“Id”:“000006AF8EE9”,“Temperature”:24.6},“TempUnit”:“C”}
2025-02-04 07:14:18.109 [INFO ] [openhab.event.ChannelTriggeredEvent ] - mqtt:broker:2ce63c5d79:ds1820 triggered {“Time”:“2025-02-04T07:14:17”,“DS18B20”:{“Id”:“000006AF8EE9”,“Temperature”:24.6},“TempUnit”:“C”}

2025-02-04 07:04:40.940 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘mqtt:topic:500291DCD07D’ changed from ONLINE to OFFLINE
2025-02-04 07:04:40.984 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘mqtt:topic:500291DCD07D’ changed from OFFLINE to ONLINE

From openhab.log:

2025-02-04 07:15:48.118 [WARN ] [nelTransformation$TransformationStep] - Failed to use TransformationStep{serviceName=‘JSONPATH’, function=‘$tele.DS18B20.Temperature’}, service not found
2025-02-04 07:15:58.094 [WARN ] [nelTransformation$TransformationStep] - Failed to use TransformationStep{serviceName=‘JSONPATH’, function=‘$tele.DS18B20.Temperature’}, service not found
2025-02-04 07:16:02.173 [WARN ] [io.openhabcloud.internal.CloudClient] - Error connecting to the openHAB Cloud instance: not authorized. Reconnecting after 60000 ms.

Your logs show your problem: you need to install the JSONPATH Transformation Service