Using OpenHabian on RPi4
Hello there, I have setup an ESP32 to publish Humidity Values as percentage values via MQTT. The values look absolutely fine, getting displayed as 59.00 in MQTT Explorer. BUT…
In Openhab, the value is read as 0.59%. With a lot of zeros behind it.
How does this happen, and how do I fix it?
Thankfull for any advice!
Using OpenHabian on RPi4
You’ve linked your plain number MQTT channel to a Number:Dimensionless Item type?
Either use a plain Number type Item, or use a transformation to add string " %" to your received numeric value.
Thanks for your answer,
The Item is a Point-Number, however, how would I achieve such a transformation?
I added the % on the ESP and tried some different formats, but with 5900%, openhab reads null values for the items.
What does openhab expect to correctly read this into an item?
I tried Number and Number:Dimensionless types, but it really does not change anything.
Okay, what is the MQTT payload are you sending? What channel type have you chosen in your MQTT binding setup?
Right now I am sending strings (char arrays) looking like 59.00%, temperature just 23.00 or something like that.
However, I just updated to 3.1, and I am not getting anything except null.
Would be great to add some kind of error message instead of just displaying null if something does not work…
I tried the percentage type, but this did not work correctly, so I changed it back to number, which worked fine until the update…
Okay. Let us know when you’re ready to share some detail of the mystery set up.
I will share what I know:
Number Item and MQTT Thing chanel type, MQTT Data delivered by ESP32 programmed using PubSub library. Everything shows up in MQTT Explorer just fine.
Running Openhabian on a Raspi 4, latest stable.
I hope you don’t mean something I have chosen when I first installed the binding, because I would not remember anymore.
I litterally just create the thing, enter the topic in the chanel configuration as the state topic and link a newly created number item.
Thats all I have to share.
Okay, now I looked into the logs, and it seems like somehow there is a leading space, and it tells me, that this incoming payload is not supported by number type
This guy had the same problem:
You will need to fix the code on the ESP32 to publish numbers without leading spaces.
actually solved it. Didn’t work with the leading whitespace. Might be something to be fixed on the binding level
No, some people might want a leading space. If you want to manipulate incoming data, the binding provides you with transformation capabilities.
What I was after was detail, like your channel configuration. We cannot see how you pluck this value out of your “character array”.