rcaspar
(René)
June 8, 2025, 2:48pm
1
Hi all
I try to read values out of a mqtt device (generic mqtt thing) but only get NULL.
I installed the mqtt plugin to octoprint and configured it to send values to my mqtt server - so far so good. When I connect ro ma mqtt server with MQTT Explorer all vallues are shown as they should (eg. {“actual”: 26.16, “target”: 0.0, “_timestamp”: 1749393991})
If a create a thing in openhab 4.3.5 I can read the connected state as it should. so I think the integration seems to be ok. But if I try to read out any other values like the bed temperature, I get NULL only.
I use as topic “octoPrint/temperature/bed” but the I have to use “Incoming Value Transformations” as follow: “JSONPATH:$.actual”.
anyone any idea what I’m doing wrong?
Thanks
René
sihui
(SiHui)
June 8, 2025, 3:28pm
2
If you can see the correct bed temperature in MainUI and MQTT Explorer, I guess the items definition is wrong.
Here is my config for two of the Octoprint items to compare:
Thing:
UID: mqtt:topic:mosquitto:octoprint
label: MQTT Octoprint
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:mosquitto
channels:
...
- id: temperature-bed-actual
channelTypeUID: mqtt:number
label: temperature-bed-actual
description: ""
configuration:
stateTopic: octoPrint/temperature/bed
transformationPattern:
- JSONPATH:$.actual
- id: temperature-bed-target
channelTypeUID: mqtt:number
label: temperature-bed-target
description: ""
configuration:
stateTopic: octoPrint/temperature/bed
transformationPattern:
- JSONPATH:$.target
...
Items:
Number OctoPi_temp_bed_actual "Aktuelle Temperatur Bett [%.1f °C]" <temperature> { channel="mqtt:topic:mosquitto:octoprint:temperature-bed-actual" }
Number OctoPi_temp_bed_target "Gewünschte Temperatur Bett [%.1f °C]" <temperature> { channel="mqtt:topic:mosquitto:octoprint:temperature-bed-target" }
Make sure the Thing id matches the Channel definition.
rcaspar
(René)
June 8, 2025, 3:59pm
3
Here my configuration:
UID: mqtt:topic:78c1df2347:Printertest
label: Prusa Printer TEST
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:78c1df2347
location: TEST
channels:
- id: Connect
channelTypeUID: mqtt:switch
label: Connect
description: ""
configuration:
stateTopic: octoPrint/mqtt
- id: Timestamp
channelTypeUID: mqtt:number
label: Timestamp
description: ""
configuration:
stateTopic: octoPrint/temperature/bed
transformationPattern:
- JSONPATH:$._timestamp
- id: HotendTemperature
channelTypeUID: mqtt:number
label: Hotend Temperature
description: ""
configuration:
stateTopic: octoPrint/temperature/tool0
transformationPattern:
- JSONPATH:$.actual.
unit: °C
- id: BedTemperatur
channelTypeUID: mqtt:number
label: Bed Temperatur
description: ""
configuration:
stateTopic: octoPrint/temperature/bed
transformationPattern:
- JSONPATH:$.actual
It looks quite same, specially the configuration of the bed temperature. I can’t see any significant difference.
Where do I find the code of the item? If I loo to the code in “Edit item” it looks quite different:
label: Bed Temperatur
type: Number:Temperature
category: ""
groupNames:
- Prusa_Printer_TEST
tags:
- Point
sihui
(SiHui)
June 8, 2025, 5:09pm
4
You are using MainUI to create items, I am using *.items files to create them manually.
I don’t know anything about MainUI as I am using text based config for openHAB, sorry.
But if I take a look at the values coming from Octoprint, they don’t appear to have a unit:
2025-06-08 18:53:30.257 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'OctoPi_temp_bed_actual' changed from 34.61 to 21.84
So remove the unit and use a plain Number itemtype:
This worked for me:
label: Bed Temperatur test
type: Number
icon: ""
groupNames: []
tags: []
Hi,
Do you have install “JSONPATH transformation” ?
1 Like
rcaspar
(René)
June 8, 2025, 7:42pm
6
@Tschetan
You’re my hero…
I never read about this addOn while reading or looking to tutorials.
Yes this was the root cause - thanks a lot.
@sihui
It even works with the unit definition. Thanks as well for your hints
René
1 Like