[SOLVED] Sonoff Tasmota firmware Version Check and Update

Hi Jürgen thanks for reply. Hope that shorttrip to Wangerooge was relaxing.
I don’t know too. Which Version you have installed ? (before and after Flash) English or German ?
What are your settings in the platform.io file for the first flash ?
Mine are:

[platformio]
src_dir = sonoff

; *** Uncomment one of the lines below to build/upload only one environment
;env_default = sonoff
;env_default = sonoff-minimal
;env_default = sonoff-classic
;env_default = sonoff-knx
;env_default = sonoff-allsensors
;env_default = sonoff-BG
;env_default = sonoff-BR
;env_default = sonoff-CN
;env_default = sonoff-CZ
env_default = sonoff-DE
;env_default = sonoff-ES
;env_default = sonoff-FR
;env_default = sonoff-GR
;env_default = sonoff-HU
;env_default = sonoff-IT
;env_default = sonoff-NL
;env_default = sonoff-PL
;env_default = sonoff-PT
;env_default = sonoff-RU
;env_default = sonoff-UK
;env_default = sonoff-TW

[common] ; ************************************************************
; *** Esp8266 core for Arduino version 2.3.0
platform = espressif8266@1.5.0
; *** Esp8266 core for Arduino version 2.4.0
;platform = espressif8266@1.6.0
; *** Esp8266 core for Arduino version 2.4.1
;platform = espressif8266@1.7.0
; *** Esp8266 core for Arduino version latest beta
;platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
; *** Esp8266 core for Arduino current version
;platform = espressif8266

and in user_config.h

// -- Master parameter control --------------------
#define CFG_HOLDER             4617              // [Reset 1] Change this value to load SECTION1 configuration parameters to flash

// -- Project -------------------------------------
#define PROJECT                "sonoff"          // PROJECT is used as the default topic delimiter
#define MODULE                 SONOFF_BASIC      // [Module] Select default model from sonoff_template.h (Should not be changed)

#define SAVE_DATA              1                 // [SaveData] Save changed parameters to Flash (0 = disable, 1 - 3600 seconds)
#define SAVE_STATE             1                 // [SetOption0] Save changed power state to Flash (0 = disable, 1 = enable)

// -- Wifi ----------------------------------------
#define WIFI_IP_ADDRESS        "0.0.0.0"         // [IpAddress1] Set to 0.0.0.0 for using DHCP or IP address
#define WIFI_GATEWAY           "192.168.2.254"   // [IpAddress2] If not using DHCP set Gateway IP address
#define WIFI_SUBNETMASK        "255.255.255.0"   // [IpAddress3] If not using DHCP set Network mask
#define WIFI_DNS               "192.168.2.27"    // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)

#define STA_SSID1              "MyNetworkName"                // [Ssid1] Wifi SSID
#define STA_PASS1              "MyWifiPassword"                // [Password1] Wifi password
#define STA_SSID2              ""                // [Ssid2] Optional alternate AP Wifi SSID
#define STA_PASS2              ""                // [Password2] Optional alternate AP Wifi password
#define WIFI_CONFIG_TOOL       WIFI_RETRY    // [WifiConfig] Default tool if wifi fails to connect
                                                 //   (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT)

// -- Syslog --------------------------------------
#define SYS_LOG_HOST           ""                // [LogHost] (Linux) syslog host
#define SYS_LOG_PORT           514               // [LogPort] default syslog UDP port
#define SYS_LOG_LEVEL          LOG_LEVEL_NONE    // [SysLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE)
#define SERIAL_LOG_LEVEL       LOG_LEVEL_INFO    // [SerialLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE)
#define WEB_LOG_LEVEL          LOG_LEVEL_INFO    // [WebLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE)

What is a long time for you when you say flashing and/or reconnecting ?

I’m using the german version. IMHO all the settings you posted will remain unchanged after a flash, I started with different versions (either flashed by me or shopped a flashed one [ sonoff RF] ).
The “long” time was >10 minutes. I investigated by looking onto the console of the device which showed numerous connection trials before it connected.
If I would have checked the Wifi strength (via the sonoff device page) I would have known that problem before starting. 38% isn’t that reliable!

As me. I’m using German Version too. I made another test via Rule
The Logger says:

Query:
2018-11-05 13:07:44.744 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance: basic_03 / queryFW / [basic_03]
2018-11-05 13:07:44.758 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance: queryFW / [basic_03] / Sonoff_Action (Type=StringItem, State=NULL, Label=Sonoff Action, Category=sonoff_basic, Groups=[Chart_Sys_Temp])
.........
Update:
2018-11-05 13:08:25.118 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance on all devices: upgrade
2018-11-05 13:08:25.154 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance: basic_03 / upgrade / [basic_03]
2018-11-05 13:08:25.176 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance: upgrade / [basic_03] / Sonoff_Action (Type=StringItem, State=NULL, Label=Sonoff Action, Category=sonoff_basic, Groups=[Chart_Sys_Temp])




and the Console says:

Query
-------  
13:07:44 MQT: stat/basic_03/STATUS2 = {"StatusFWR":{"Version":"5.14.0","BuildDateTime":"2018.05.17 01:51:20","Boot":6,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}

Update:
----------
13:08:25 MQT: stat/basic_03/RESULT = {"OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin"}
13:08:25 MQT: stat/basic_03/RESULT = {"Command":"Unknown"}

As you can see, when i make a Version-request it works and the signal strength is 100%. But the command seems to be unkown :thinking:?

This is the Rule-File:

// Work with a list of selected Sonoff modules

val sonoff_device_ids = newArrayList(
    "basic_03"
)

// OR
// Work with the grouptopic, addressing ALL modules at once
// val sonoff_device_ids = newArrayList("sonoffs")

rule "Sonoff Maintenance"
when
    Item Sonoff_Action received command
then 
    logInfo("sonoff.rules", "Sonoff Maintenance on all devices: " + receivedCommand)
    for (String device_id : sonoff_device_ids) {
        switch (receivedCommand) {
            case "restart" :
                //publish("peter", "cmnd/" + device_id + "/restart", "1")
                logInfo("sonoff.rules", "Sonoff Maintenance: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            case "queryFW" :{
                publish("peter", "cmnd/" + device_id + "/status", "2")
                logInfo("sonoff.rules", "Sonoff Maintenance: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            }
            case "upgrade" : {
                publish("peter", "cmnd/" + device_id + "/otaurl", "http://sonoff.maddox.co.uk/tasmota/sonoff.bin")
                publish("peter", "cmnd/" + device_id + "/upgrade ", "1")
                logInfo("sonoff.rules", "Sonoff Maintenance: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            }
        }
    }
    Sonoff_Action.postUpdate(NULL)
		logInfo("sonoff.rules", "Sonoff Maintenance: " + receivedCommand + " / " + sonoff_device_ids + " / " + Sonoff_Action)
end

Any idea ?

1 Like

No idea!
When updating I get those lines:

13:29:23 MQT: stat/sonoff_dual/RESULT = {“OtaUrl”:“http://sonoff.maddox.co.uk/tasmota/sonoff.bin”}
13:29:23 MQT: stat/sonoff_dual/RESULT = {“Upgrade”:“Version 6.3.0 from http://sonoff.maddox.co.uk/tasmota/sonoff.bin”}

I would also say the problem is on the sonoff side, you migth be better asking there.

Thanks a lot for your help and the spended time.
I found an error in my Rule it’s the Space "/upgrade ", after upgrade.

Regards
Peter

1 Like

I’m glad you found THAT one. Please mark this thread as resolved by selecting one reply as the solution (most probable your last one).

That’s it. After changing the Rule and a new trial it works and the basic was updated :joy:.
A last question:
Is this your adress: "/otaurl", "http://sonoff.maddox.co.uk/tasmota/sonoff.bin"
or have you used something like this: "/otaurl", "http://sonoff.maddox.co.uk/tasmota/sonoff-DE.bin"

I ask this because i have now an english version.

Copy-paste your url in browser. It exists and is the german bin file… that’s the one you should use if you want german

1 Like

Thanks’s for your info.
Peter

Frankly, I didn’t even notice that switch to english :blush:. I normaly don’t even look there!
Sorry for that

That’s it.

I Have take this one step further to only update sonoffs that are below the current firmware version. see code below

var firmware = transform(“REGEX”, “.*([0-9].[0-9].[0-9])”, Sonoff_Current_FW_Available.state.toString)

// Work with a list of selected Sonoff modules
val sonoff_device_ids = newArrayList(
//… add all your modules here!
“sonoff/fishtank”,
“sonoff/mbl”,
“sonoff/bedroom”,
“sonoff/livingroom”,
“sonoff/kitchen”,
“sonoff/kitchen_led”,
“sonoff/fan”,
“sonoff/sonoff1”,
“sonoff/sonoff2”,
“sonoff/rice_cooker”,
“sonoff/light1”,
“sonoff/light2”,
“sonoff/light3”,
“sonoff/light4”,
“sonoff/mb_bathroom”,
“sonoff/bathroom”,
“sonoff/hallway”,
“sonoff/RF_Brigde”,
“sonoff/RF_Bridge2”,
“sonoff/4chpro”,
“sonoff/sonoffsc”

)
// OR
// Work with the grouptopic, addressing ALL modules at once
//val sonoff_device_ids = newArrayList(“sonoffs”)

rule “Sonoff Maintenance”
when
Item Sonoff_Action received command
then
logInfo(“sonoff.rules”, "Sonoff Maintenance on all devices: " + receivedCommand + " to " + firmware)
for (String device_id : sonoff_device_ids) {
switch (receivedCommand) {
case “restart” :
publish(“mosquitto”, “cmnd/” + device_id + “/restart”, “1”)
case “queryFW” :
publish(“mosquitto”, “cmnd/” + device_id + “/status”, “2”)
case “upgrade” : {
publish(“mosquitto”, “cmnd/” + device_id + “/otaurl”, “http://sonoff.maddox.co.uk/tasmota/sonoff.bin”)
publish(“mosquitto”, “cmnd/” + device_id + “/upgrade”, “” + firmware)
}
case “timezone” :
publish(“mosquitto”, “cmnd/” + device_id + “/timezone”, “4”)
}
}
Sonoff_Action.postUpdate(NULL)
end

It has a validation error below does anyone now how to solve it

Validation issues found in configuration model ‘sonoff.rules’, using it anyway:

Cannot reference the field ‘Sonoff_Current_FW_Available’ before it is defined

Do you have created the Switch in your .items File ?

EDIT 1:
Found in Rule. Declare the Variable within the Rule after “then” . See below :wink:

rule "Sonoff Tasmota Version"
when
    Item Sonoff_Release_Refresh changed to ON or
    Channel 'astro:sun:local:noon#event' triggered START
then
var firmware = transform("REGEX", ".*([0-9].[0-9].[0-9])", Sonoff_Current_FW_Available.state.toString)
    logInfo("sonoff.rules", "Tasmota Release Refresh to Items: " )
    logInfo("sonoff.rules", "Tasmota Release Refresh to Items: " + firmware)
		
    for (String device_id : sonoff_device_ids) {
          publish("broker", "cmnd/" + device_id + "/status", "2")
          // logInfo("sonoff.rules", "Sonoff Maintenance: " + device_id)
    }

end

Does your example conform to mqtt 2.4 format?

No, the action publish(...) has changed: https://www.openhab.org/addons/bindings/mqtt.generic/#rule-actions

1 Like

Hi,
as Vincent posted this is a Rule using mqtt 1.x

Hi,
yesterday i installed me new Sonoff-S20 Wall-Plug. I flashed latest tasmota and used mqtt2 to integrate it into openhab.

It works. First i only got a few values, but afteri changed compatibility to WeMos inside Tasmota, there are some more.

But i still don´t get many values. For example this “Firmware Version”, explained in this thread.

Is there a list with all posible topics and the coresponding commands to get this values?

What i get is:
switch
state (on/off)
VCC
SSID
Wifi Channel
Uptime
Time
State Online/Offline

What i don´t get is:
Wifi AP
RSSI
Firmware Version

All other possible values which are not in my two lists, are not configured so far.

Here are my configs for firmware (not working):
things:

Type string : version "Software Version" [ 
            stateTopic="stat/sonoff-s20-1/STATE",
            transformationPattern="JSONPATH:$.StatusFWR.Version"
          ]

And the item:

String sonoff_s20_1_Version     "SPS01 Firmware" (gSonoffPowerSwitches_Basic)   { channel="mqtt:topic:MosquittoBroker:sonoff-s20-1:version" }

EDIT:

My biggest problem is: I don´t know, whre i can get the correct sytax for my topic inside the thing:

–> stat/sonoff-s20-1/STATE

sonoff-20-1 is my given name for the sonoff-device. But where do i get stat and STATE from? How can i see, which values are possible for STATE and which value is correct for the stat in the first place?

That question is more related to Tasmota, so a look into the Tasmota Wiki would help.

I already did this. This was my first step.

There is an example, but without uptime, time, rssi, firmware-version…
So i don´t know, what is possible with a sonoff s20…

I saw some posts, where firmware-version and rssi are working with a s20. I think i configured it all the way like in the other posts, but still some values are not displayed…

See my EDIT in the last post also. This is my (only) problem, i think.