Hello fellow openHAB enthusiasts, I’m reaching out to seek some guidance on my MQTT setup. I’ve recently integrated a weather station that sends temperature data in Celsius via MQTT, and I’m trying to display this data with the correct units in my openHAB interface. While I’ve managed to get the basic setup working, I’m encountering some issues with unit conversion and formatting that I’d like to resolve.
First, let me walk you through my current configuration. In my mqtt.things file, I’ve defined a MQTT bridge and a thing for my weather station. The thing has a channel for the outdoor temperature, which is set to use the Celsius unit. Here’s the relevant snippet:
mqtt.things:
Bridge mqtt:broker:myAuthentificatedBroker “Mosquitto” [host=“192.168.xxx.xxx”, port=1883, secure=false, username=“test”, password=“testPW”, cliendID=“openHab”] {
Thing mqtt:topic:meineWetterstation:EmpfangeneWerte “WS2080_pywws” @ “Garten” {
Channels:
Type number : TemperaturAussen “Temperatur” [stateTopic=“weather/WS1080_pywws/temp_out_c”, unit=“°C” ]
}
}
In my mqtt.items file, I’ve defined three Number items to display the temperature in different units. The goal is to have one item display the temperature in Celsius, another in Fahrenheit, and a third with the default unit. Here’s how I’ve set them up:
mqtt.items:
Number outTemperaturDefault “Temperatur [%.1f %unit%]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}
Number outTemperaturCelsius “Temperatur [%.1f °C]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}
Number outTemperaturFarenheit “Temperatur [%.1f °F]” (gWetter) {channel=“mqtt:topic:meineWetterstation:EmpfangeneWerte:TemperaturAussen”}
Now, here’s where I’m running into issues. When I view outTemperaturCelsius and outTemperaturFarenheit in my sitemap, both items display the same temperature value, but outTemperaturFarenheit isn’t converting the temperature to Fahrenheit as I expected. Additionally, outTemperaturDefault isn’t showing any unit at all. This is perplexing because I thought defining the unit in the channel would handle the conversion automatically.
I suspect there might be a misunderstanding in how openHAB handles unit conversions and formatting. Perhaps I need to explicitly configure the conversion from Celsius to Fahrenheit rather than relying on openHAB to handle it automatically. I’ve also considered whether the issue might be with how the units are being displayed in the sitemap, but I’m not entirely sure.
I’d greatly appreciate any insights or suggestions on how to resolve these issues. Whether it’s adjusting the channel configuration, modifying the item definitions, or implementing a rule to handle the conversion manually, I’m open to any solution that allows me to display the temperature in the correct units. Thank you in advance for your help!
Best regards,
Gregor