[SOLVED] Query firmware version from sonoff with mqtt

  • Platform information:

    • openHAB version: 2.4 as a Docker Container with mqtt
    • mqtt: binding version 2.4
  • Issue of the topic: I want the see the firmware version of my differents sonoffs s20 in the basic ui of openhab. At the moment i can only turn on/off my sonoffs, see the uptime and rssi value. In the console of my sonoff i can see that openhab send the command from my rule with mqtt. But the result is not visible in the basic ui. In my openhab logs i can not see any errors or hints for my problem.

  • Please post configurations (if applicable):

    • Items:
Switch Sonoff01_Switch "Lampe" <light> (gLicht) [ "Switchable" ] { channel="mqtt:topic:mosquitto:sonoff01:power" }       
Number Sonoff01_RSSI "RSSI [%d %%]" <qualityofservice> (gDebugSonoff01) { channel="mqtt:topic:mosquitto:sonoff01:rssi" }
String Sonoff01_Uptime "Aktiv seit: [%s]" <network> (gDebugSonoff01) {channel="mqtt:topic:mosquitto:sonoff01:UPTIME"}
String Sonoff01_Reachable "Status: [%s]" <network> (gDebugSonoff01) {channel="mqtt:topic:mosquitto:sonoff01:REACH"}
String Sonoff01_SW "FW Sonoff [%s]" <network> (gDebugSonoff01) {channel="mqtt:topic:sonoff01:version"}
  • things:
Bridge mqtt:broker:mosquitto "Mosquitto" [ host="192.168.5.200", port=1883, secure=false, username="mqtt", password="XXXX", clientID="openHAB2" ]
{
    // Sonoff01
    Thing topic sonoff01 "Sonoff01" @ "Some Room" {
    Channels:
        Type switch : power "Power" [ stateTopic="tasmota/sonoff_55F735/stat/POWER", commandTopic="tasmota/sonoff_55F735/cmnd/POWER" ] 
        Type number : rssi "WiFi Signal Strength" [ stateTopic="tasmota/sonoff_55F735/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : UPTIME    "Uptime"        [stateTopic="tasmota/sonoff_55F735/tele/STATE", transformationPattern="JSONPATH:$.Uptime"]
        Type string : REACH     "Reachable"     [stateTopic="tasmota/sonoff_55F735/tele/LWT"]
        Type string : version   "Firmware Version"    [stateTopic="tasmota/sonoff_55F735/stat/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
    }
  • Sitemap configuration related to the issue:
Frame label="Debug"{
        Group item=gDebugSonoff01 icon="settings" 
    }
  • Rules code related to the issue:
rule "Sonoff Maintenance"
when
    Item Sonoff01_RSSI changed 
then
    // logInfo("sonoff.rules", "Sonoff Maintenance on all devices: " + receivedCommand)
    val mqttActions = getActions("mqtt","mqtt:broker:mosquitto") // change to your broker name!
    mqttActions.publishMQTT("tasmota/sonoff_55F735/cmnd/status","2")
end
1 Like

Did you restart OH after modifying your things file?

yes!

Ok,
Have you usedan MQTT tool like MQTTfx or MQTT-Explorer to check that the sonoff receives the command and replies with the correct payload?

You could also do that by monitoring the sonoff console.

Yes i checked this with MQTTfx and in the console from my sonoff. The reply is correct.

11:01:27 MQT: tasmota/sonoff_55F735/stat/STATUS2 = {"StatusFWR":{"Version":"6.4.1(sonoff)","BuildDateTime":"2019.01.06 18:49:01","Boot":31,"Core":"2_4_2","SDK":"2.2.1(cfd48f3)"}}

Does the item get updated with the correct value and it’s just a sitemap problem?

The item Sonoff01_SW did not get updatet. In the event log i only see this message:

2019-02-15 09:30:41.570 [.ItemChannelLinkAddedEvent] - Link 'Sonoff01_SW-mqtt:topic:sonoff01:version' has been added.

So what is the current value of Sonoff01_SW?

There is no value for the item. I checked this with the api from mapdb

{"name":"Sonoff01_SW","datapoints":"0","data":[]}

Use MQTTfx to send dummy payloads
Topic: tasmota/sonoff_55F735/stat/STATUS2
Payload:

{"StatusFWR":{"Version":"TESTING_00","BuildDateTime":"2019.01.06 18:49:01","Boot":31,"Core":"2_4_2","SDK":"2.2.1(cfd48f3)"}}

What do you see on the OH log?

Nothing :frowning:

2019-02-15 15:01:27.984 [vent.ItemStateChangedEvent] - Sonoff01_RSSI changed from 62 to 60
2019-02-15 15:01:33.288 [vent.ItemStateChangedEvent] - HS110_Power changed from 21.505 to 21.75
2019-02-15 15:01:33.289 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.14 to 0.141
2019-02-15 15:01:42.563 [vent.ItemStateChangedEvent] - SunElevation changed from 19.33241646107857 to 19.24292134498016
2019-02-15 15:02:03.394 [vent.ItemStateChangedEvent] - HS110_Power changed from 21.75 to 22.492
2019-02-15 15:02:03.394 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.141 to 0.144
2019-02-15 15:02:33.516 [vent.ItemStateChangedEvent] - HS110_Rssi changed from -36 to -37
2019-02-15 15:02:33.518 [vent.ItemStateChangedEvent] - HS110_Power changed from 22.492 to 20.626
2019-02-15 15:02:33.520 [vent.ItemStateChangedEvent] - HS110_EnergyUsage changed from 105.539 to 105.54
2019-02-15 15:02:33.520 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.144 to 0.136
2019-02-15 15:02:42.571 [vent.ItemStateChangedEvent] - SunElevation changed from 19.24292134498016 to 19.15288688059389
2019-02-15 15:02:44.229 [vent.ItemStateChangedEvent] - Sonoff04_RSSI changed from 80 to 84
2019-02-15 15:03:03.618 [vent.ItemStateChangedEvent] - HS110_Rssi changed from -37 to -36
2019-02-15 15:03:03.619 [vent.ItemStateChangedEvent] - HS110_Power changed from 20.626 to 21.174
2019-02-15 15:03:03.620 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.136 to 0.138
2019-02-15 15:03:17.597 [vent.ItemStateChangedEvent] - HS110_Rssi_02 changed from -58 to -57
2019-02-15 15:03:33.737 [vent.ItemStateChangedEvent] - HS110_Power changed from 21.174 to 20.484
2019-02-15 15:03:33.739 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.138 to 0.135
2019-02-15 15:03:42.565 [vent.ItemStateChangedEvent] - SunElevation changed from 19.15288688059389 to 19.062333570372918
2019-02-15 15:03:47.798 [vent.ItemStateChangedEvent] - HS110_Rssi_02 changed from -57 to -58
2019-02-15 15:04:03.909 [vent.ItemStateChangedEvent] - HS110_Power changed from 20.484 to 21.168
2019-02-15 15:04:03.912 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.135 to 0.139
2019-02-15 15:04:17.869 [vent.ItemStateChangedEvent] - HS110_Rssi_02 changed from -58 to -57
2019-02-15 15:04:33.999 [vent.ItemStateChangedEvent] - HS110_Power changed from 21.168 to 20.501
2019-02-15 15:04:34.000 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.139 to 0.135
2019-02-15 15:04:42.565 [vent.ItemStateChangedEvent] - SunElevation changed from 19.062333570372918 to 18.971248654846054
2019-02-15 15:05:04.102 [vent.ItemStateChangedEvent] - HS110_Power changed from 20.501 to 22.34
2019-02-15 15:05:04.103 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.135 to 0.144
2019-02-15 15:05:34.221 [vent.ItemStateChangedEvent] - HS110_Power changed from 22.34 to 20.277
2019-02-15 15:05:34.222 [vent.ItemStateChangedEvent] - HS110_Current changed from 0.144 to 0.135
2019-02-15 15:05:34.223 [vent.ItemStateChangedEvent] - HS110_EnergyUsage changed from 105.54 to 105.541

Okay in my openhab.log i see this:

2019-02-15 15:02:32.759 [ERROR] [ansport.mqtt.internal.ClientCallback] - MQTT message received. MqttMessageSubscriber#processMessage() implementation failure
java.lang.IllegalArgumentException: json string can not be null or empty
        at com.jayway.jsonpath.internal.Utils.notEmpty(Utils.java:386) ~[?:?]
        at com.jayway.jsonpath.internal.JsonContext.parse(JsonContext.java:81) ~[?:?]
        at com.jayway.jsonpath.JsonPath.read(JsonPath.java:502) ~[?:?]
        at org.eclipse.smarthome.transform.jsonpath.internal.JSonPathTransformationService.transform(JSonPathTransformationService.java:62) ~[?:?]
        at org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelStateTransformation.processValue(ChannelStateTransformation.java:81) ~[?:?]
        at org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState.processMessage(ChannelState.java:146) ~[?:?]
        at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[225:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
        at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:?]
        at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [225:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [221:org.eclipse.paho.client.mqttv3:1.2.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [221:org.eclipse.paho.client.mqttv3:1.2.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [221:org.eclipse.paho.client.mqttv3:1.2.0]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

I don’t know, it should work…
Try:
Remove the transformationPattern

Then try changing the topic to Testing and send a payload with MQTTfx
Then add a transformation and send a JSON

I use exactly the same in my set-up, only difference is that I use the PaperUI to setup my things.
Textual things are too prone to errors in my opinion. Even though your looks ok.

two more restarts but without any solution. But i did not get the above error anymore. Anybody else has a hint?
@vzorglub which tosmota firmware do you have? Maybe its a firmware bug?

I had 6.4.1 but reverted to 6.4.0
It’s not the tasmota, that’s working, we established that
Try creating an mqtt Generic thing in paperUI with one text channel for the firmware

I tried to create an generic thing in papier ui but i always get the “ERROR: 409-”. Here are my settings:

Create a new thing with a new name. You were trying to add a channel to an existing textual thing, hence the error

Looks like your missing “mosquitto” in the channel between topic and sonoff01. You have it in all the other channels.

String Sonoff01_SW "FW Sonoff [%s]" <network> (gDebugSonoff01) {channel="mqtt:topic:sonoff01:version"}

Should be

String Sonoff01_SW "FW Sonoff [%s]" <network> (gDebugSonoff01) {channel="mqtt:topic:mosquitto:sonoff01:version"}
1 Like

Well, thank you. Sometimes it’s right under your nose.
The easiest way is to copy and paste the channel names from the PaperUI.

Yeah thanks! That was the problem.