- Platform information:
- Hardware: i3-3220/8gb RAM/500Gb HDD
- OS: Ubuntu 18.04.2 LTS
- Java Runtime Environment: Java SE Runtime 1.8.0.121-b13
- openHAB version: openHAB 2.4.0 Release Build
- Issue of the topic:
Cannot get MQTT status information from one particular sensor.
I have many items that I have converted from the old binding to the new binding, however this is one that I can’t seem to do in the new binding. I am not sure why this one just won’t work.
I have a simple MQTT weatherstation updating to Weather Underground, and it also publishes data to the topic ‘weatherstation’.
The data is presented in the following json:
{"TempC":"23.37","DewPoint":"15.74","Humidity":"62.20","Pressure":"1016.00","Battery":"3.14"}
In the old MQTT binding, I would read this into OpenHAB using the following item configuration:
String WUSensor "[%s]" {mqtt="<[mc:weatherstation:state:default]"}
DateTime WUSensor_LastUpdate "WU Tx Update [%1$ta %1$tR]" <clock>
Number WUBattery_Status "WUnderground Tx: [%.2f V]" (wusensor) {mqtt="<[mc:weatherstation:state:JSONPATH($.Battery)]"}
Number WUHumidity "Humidity: [%.2f%%]" (wusensor) {mqtt="<[mc:weatherstation:state:JSONPATH($.Humidity)]"}
Number WUPressure "Pressure: [%.2f]" (wusensor) {mqtt="<[mc:weatherstation:state:JSONPATH($.Pressure)]"}
Number WUTemperature "Temperature: [%.2f°C]" (wusensor) [ "CurrentTemperature" ] {mqtt="<[mc:weatherstation:state:JSONPATH($.TempC)]"}
I’ve since tried to convert it to the newer MQTT binding, and it does not seem to be reading/updating the values in OpenHAB.
mqtt.fx shows the data is coming in, and I have this written to a separate database using Node-Red for logging/troubleshooting retrospectively.
There are no logs in the events.log or openhab.log to show that this is actually receiving the data which is weird.
I’ve posted below the information of the configuration - open to any help as I have spent a week trying to get this working and it just is baffling me why this doesn’t.
- Items configuration related to the issue
String WUSensor {channel="mqtt:topic:mc:WUndergroundSensor:rawdata"}
Number WUBattery_Status "WUnderground Tx: [%.2f V]" (wusensor) {channel="mqtt:topic:mc:WUndergroundSensor:batteryvoltage"}
Number WUHumidity "Humidity: [%.2f%%]" (wusensor) {channel="mqtt:topic:mc:WUndergroundSensor:humidity"}
Number WUPressure "Pressure: [%.2f]" (wusensor) {channel="mqtt:topic:mc:WUndergroundSensor:pressure"}
Number WUTemperature "Temperature: [%.2f°C]" (wusensor) [ "CurrentTemperature" ] {channel="mqtt:topic:mc:WUndergroundSensor:temp_c"}
- Sitemap configuration related to the issue
Text item=WUBattery_Status valuecolor=[WUSensor_LastUpdate>10="green",WUSensor_LastUpdate>15="orange", WUSensor_LastUpdate>20="red"]
Text item=WUSensor_LastUpdate
Text item=WUSensor
- Rules code related to the issue
// Creates an item that stores the last update time of this item
rule "Records last Wunderground Battery update time"
when
Item WUTemperature received update
then
postUpdate(WUSensor_LastUpdate, now.toString())
end
- Services configuration related to the issue
Bridge mqtt:broker:mc "Mosquitto" @ "MQTT"[ host="localhost", port="1883", secure=false , username="myusername", password="mypassword" ] {
Thing topic PIRHall "Hallway PIR" @ "MQTT" {
Channels:
Type contact : hall "Hallway PIR" [ stateTopic="stat/sensor/hall_pir" ]
}
Thing topic WUndergroundSensor "Weather Underground Sensor" @ "MQTT" {
Channels:
Type string : rawdata "Raw Data" [ statetopic="weatherstation"]
Type number : batteryvoltage "Battery Voltage" [ statetopic="weatherstation", transformationPattern="JSONPATH:$.Battery"]
Type number : humidity "Humidity" [ statetopic="weatherstation", transformationPattern="JSONPATH:$.Humidity"]
Type number : pressure "Air Pressure" [ statetopic="weatherstation", transformationPattern="JSONPATH:$.Pressure"]
Type number : temp_c "Temperature_C" [ statetopic="weatherstation", transformationPattern="JSONPATH:$.TempC"]
Type number : dewpoint "Dew Point" [ statetopic="weatherstation", transformationPattern="JSONPATH:$.DewPoint"]
}
}