I’ve done a fresh install of OH3.2 and now trying to replicate some basic functionality I have working in a OH2.5 setup using MQTTV1.
I’m using Control Tasmota flashed devices via MQTT as a guide.
This is my 2.5 mqtt.items file entry which both controls the light on/off and can get its state both from the ‘stat’ and ‘tele’
Well if the JSONPATH is not active, and I presume the incoming MQTT message payload here is JSON, then a complete message text in JSON format is not going to fit the ON or OFF states required by a Switch type Item.
You can always make another temporary channel of type string with similar parameters, and link it to a String type Item to see what is received.
Hey @Ianc99 Welcome to the joys of out of date information.
It can be super frustrating because many people can change a little thing and can be difficult to diagnose. I have trust issues with data and want to see exactly what is going on and roughly follow a tutorial.
Is the version of tasmota you installed the same as the one for the tutorial?
Educated Guess change state to
stateTopic="stat/STUDY_T1SON_85/POWER1",
download http://mqtt-explorer.com/ it will greatly help you to see the messages being sent from client
You don’t need JSON transformation for power1 on off
James,
I’m with you on the trust issues which is why I was already snooping on the actual MQTT messages. It’s deffo just POWER and also the OH2.5 server with the mqtt.items file is still working (I’m using it to toggle the light on and off to test the new server)
This “old” Server is running a mqtt broker as well?
Regarding the need for a JSONPATH transformation, take a look onto theconsole of your tasmota device. You will when a message containing the state I sent ( tele or stat) and which of both does need a transformation.
I have OH3.1 working with MQTT/Tasmota. Maybe this will help.
In my .things file
Bridge mqtt:broker:MqttBroker [
host="192.168.0.5",
port="1883",
secure=false,
username="MqttUserid", password="********",
clientID="OpenHab"]
Thing topic ChristmasTreeThingId "ChristmasTree" {
Channels:
Type switch : power "Power" [stateTopic="ChristmasTree/stat/POWER", commandTopic="ChristmasTree/cmnd/POWER"]
Type string : sleepmode "Sleep Mode" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.SleepMode"]
Type number : sleep "sleep" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Sleep"]
Type number : loadavg "Load Average" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.LoadAvg"]
Type number : wifiap "WiFi" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Wifi.AP"]
Type string : wifissid "SSID" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Wifi.SSId"]
Type string : wifibssid "BSSID" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Wifi.BSSId"]
Type number : wifichannel "Channel" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Wifi.Channel"]
Type number : wifirssi "RSSI" [stateTopic="ChristmasTree/tele/STATE",transformationPattern="JSONPATH:$.Wifi.RSSI"]
}
.items file:
Switch ChristmasTree "ChristmasTree [%s]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:power"}
String ChristmasTreeSleepMode "ChristmasTree Sleep Mode [%s]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:sleepmode"}
Number ChristmasTreeSleep "ChristmasTree Sleep [%d]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:sleep"}
Number ChristmasTreeLoadAvg "ChristmasTree Load Average [%d]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:loadavg"}
Number ChristmasTreeWifiAP "ChristmasTree AP [%d]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:wifiap"}
String ChristmasTreeWifiSSID "ChristmasTree SSID [%s]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:wifissid"}
String ChristmasTreeWifiBSSID "ChristmasTree BSSID [%s]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:wifibssid"}
Number ChristmasTreeWifiChannel "ChristmasTree Channel [%d]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:wifichannel"}
Number ChristmasTreeWifiRssi "ChristmasTree RSSI [%d]" {channel="mqtt:topic:MqttBroker:ChristmasTreeThingId:wifirssi"}
.sitemap
Switch item=ChristmasTree label="Christmas Tree [%s]"
I understand I need to use transformationPattern for this but can I do it byadding a second stateTopic line to the channel or do I create another channel for the Thing?
If I need a second channel, do I just put the two channels in the item something like this?
What topics you’ll choose to listen to might depend on when they are sent. Usually for Tasmota, one is a response to commands and the other a periodic report. There’s no cost in having a receive channel for both, each linked to one Item.
@rossko57 Monitoring the “tele” and “stat” does have overlap but they address different scenarios for my setup. “stat” give immediate feedback when a device turns on or off. “tele” deals with those times when OB may have missed a stat msg (usually because its temorarily offline).
I have the telemetry interval set to 30 seconds on all my Tasmota devices so my OH states always reflect reality within about a minute of reboots etc.
Does that sound like a reasonable approach or am I missing a more straightforward approach?