Java Runtime Environment: openjdk version “11.0.13” 2021-10-19
openHAB version: openHAB 3.2.0
Issue of the topic: basic mqtt channel problem
Please post configurations (if applicable):
Items configuration related to the issue
Sitemap configuration related to the issue
Rules code related to the issue
Services configuration related to the issue
If logs where generated please post these here using code fences:
I’m trying to use Openhab3 to visualize some measurements. These measurements come via mqtt in two different formats:
Payload Type1
Topic is "xxx/c052719c-29a7-a6d4-bfe5-0b96027cfaec
payload is {“id”:c052719c-29a7-a6d4-bfe5-0b96027cfaec,“value”:3.45,“ts”:1643887734}
I created a mqtt binding and a channel, used a incoming transformation “JSONPATH:$.value” and everything works fine.
Payload type 2:
Topic is “xxx/01af17b2-a448-474c-787a-44014b091067/channel_1”,
Payload is “123.45”
I’m trying for hours to get this payload into Openhab3. I left everything on default, “Incoming Value Transformations” is left empty. The thing shows “online”, but no values are coming. What did I do wrong?
Try a brand new Channel, but use a String Channel, and link it to a String thing. Don’t add fancy units, or formatBeforePublish. See if that works first.
What have you linked your channel to, i.e. Item type?
Background - at OH3.1, units on incoming MQTT messages were not applied, the channel’s “unit” was only tacked on to outbound messages.
I know there was some interest in enhancing that so that “unit” got tacked on to incoming messages as well, but not sure if that got included in OH3.2
Thank you for your input. I created a new thing with a channel “channelTypeUID: mqtt:string” and that delivered the value from the mqtt message.
I don’t understand at this time why this value isn’t saved and I can’t see the graph over the time. I created a item type Number:Temperature for one of the sensors that send JSON messages and this gives me a diagram of the historic values.
Yes, the Number:Temperature item works fine. The MQTT message in JSON format gets decoded and the values charted. Now I’m trying to get the other kind of MQTT messages to work.
Can I set the loglever higher to see the workings of the MQTT message processing?
Update: Changed the (now working) item for the non-JSON message from “string” to “Number:Temperature”. Stopped working… don’t understand why. Obviously something like “22.33” as payload in the MQTT message is recognized as string, but not as number.