[SOLVED] MQTT Tasmota Maintenance Actions - get current Tasmota GitHub Release

  • Platform information:
    • openHAB version: docker openhab:3.2.0
  • Issue of the topic: How can I get the current Tasmota release from Github
  • Please post configurations (if applicable):
    • In the tasmota documentation is described how you can get the most recent Tasmota release name to make it easy to check if your tasmota version is outdated: openHAB - Tasmota
    • Items configuration related to the issue (copied fro reference from tasmota documentation:
      String Tasmota_Current_FW_Available "Current Release [%s]" {http="<[tasmotaRelease:10000:JSONPATH($[0].name)]"}
      
    • Services configuration related to the issue
      • addons.cfg
        package = standard
        binding = mqtt,http
        transformation = jsonpath,map,javascript
        
      • http.cfg
        # Tasmota Release Version (cached twice a day)
        tasmotaRelease.url=https://api.github.com/repos/arendst/Tasmota/tags
        #tasmotaRelease.updateInterval=43200000
        tasmotaRelease.updateInterval=60000 # refresh every minute
        
  • If logs where generated please post these here using code fences:
    2022-02-06 11:39:20.578 [WARN ] [ty.util.ssl.SslContextFactory.config] - Trusting all certificates configured for Client@4e027fba[provider=null,keyStore=null,trustStore=null]
    2022-02-06 11:39:20.580 [WARN ] [ty.util.ssl.SslContextFactory.config] - No Client EndPointIdentificationAlgorithm configured for Client@4e027fba[provider=null,keyStore=null,trustStore=null]
    

The rules described in the tasmota documentation seem to be working. I can query the installed firmware version and trigger a restart. I did not test the upgrade button yet, because I have already installed the most recent firmware version.

Any idea what I am doing wrong?

That’s very old syntax for version 1.x of HTTP binding. Simply will never work under OH3.2

You’ll have to work out similar enquiry using HTTP things/channels, or a rule using HTTP Actions.

My HTTP-Thing for the Tasmota Version looks like:

UID: http:url:TasmotaVersion
label: Tasmota Version
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.github.com/repos/arendst/Tasmota/tags
  delay: 0
  stateMethod: GET
  refresh: 2000
  commandMethod: GET
  contentType: application/json
  timeout: 5000
  bufferSize: 2048
channels:
  - id: Version
    channelTypeUID: http:string
    label: Version
    description: ""
    configuration:
      stateTransformation: JSONPATH:$[0].name

The working javascript- rule for the tasmota actions looks like:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
logger.info("Sonoff Maintenance on all devices: {}", command);
var device_id = "Tasmota";
var actionsBroker = actions.get("mqtt", "mqtt:broker:opuspi4MQTTBroker");
var mycommand=command.toString();
switch (command.toString()) {
    case "restart": {
        //actionsBroker.publishMQTT( "cmnd/" + device_id + "/WebColor", "0")
        actionsBroker.publishMQTT("cmnd/" + device_id + "/restart", "1");
        break;
    }
  case "queryFW": {
        logger.info ("query Firmware");    
        actionsBroker.publishMQTT("cmnd/" + device_id + "/status", "2");
        break;
    }
    case "upgrade": {
        actionsBroker.publishMQTT("cmnd/" + device_id + "/otaurl", "http://ota.tasmota.com/tasmota/release/tasmota-DE.bin");
        actionsBroker.publishMQTT("cmnd/" + device_id + "/upgrade", "1"); 
        break;
    }
    default: {
        //logger.info ("default case");
    }
}
events.postUpdate('Tasmota_Action', NULL);

All my devices listen to the ‘Tasmota’ topic.

then the matching item would look like this?

String    Tasmota_Current_FW_Available    "Current Release [%s]"    {channel="http:url:TasmotaVersion:Version"}

I created a test.things with your http binding definition:

UID: http:url:TasmotaVersion
label: Tasmota Version
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.github.com/repos/arendst/Tasmota/tags
  delay: 0
  stateMethod: GET
  refresh: 2000
  commandMethod: GET
  contentType: application/json
  timeout: 5000
  bufferSize: 2048
channels:
  - id: Version
    channelTypeUID: http:string
    label: Version
    description: ""
    configuration:
      stateTransformation: JSONPATH:$[0].name

but openhab complains with this error message:

2022-02-06 14:44:05.520 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test.things' has errors, therefore ignoring it: [2,16]: missing ':' at 'Version'
[6,20]: extraneous input 'false' expecting RULE_ID
[10,3]: extraneous input 'refresh' expecting ':'
[12,3]: extraneous input 'contentType' expecting ':'
[12,27]: missing EOF at '/'

That was not xxx.things file format that you were shown, it’s the ‘code’ display of a GUI entered Thing. These aren’t compatible.

1 Like

I think I found a good solution which is less verbose and working for me.
@opus and @rossko57 thanks for pointing me in the right direction.

Here is my tasmota_maintenance.items:

String    Tasmota_Current_FW_Available    "Current Release [%s]"    {channel="http:url:TasmotaVersion:Version"}

Here is my tasmota_maintenance.things:


Thing http:url:TasmotaVersion [
	baseURL="https://api.github.com/repos/arendst/Tasmota/tags",
	refresh=86400] { // refresh once a day
		Channels:
			Type string : Version "Version" [ stateTransformation="JSONPATH:$[0].name" ]
}

The rules from the tasmota documentation seem to be working fine. I will stick to them for the moment instead of using @opus javascript.

Will you inform the author of this outdated tutorial that you found?

Do you know if I need to create a pull request on github for this or do I need to mention this in the tasmota forum?

Creating a pull request should be the (overall) way with the least work.

done: https://github.com/tasmota/docs/pull/926

Did you just copy these both files?
I checked if all bindings and transformations are installed - but the item with the Firmware String stays “NULL”. Any idea?

yes, those two files.

You could decrease refresh to 30.
Then it will refresh every 30 seconds.

Maybe this helps while playing around with it

Thank you - of course, i did this and restarted OH … hmmm … Did you do anything in the GUI or is file http.cfg important?

If you’d show us your actual config of Things and Items we could help ( copy&paste the YAML code). Otherwise we can only assume what you have done and why your item stays with “NULL”.

there is no change in http.cfg to get this working

this is the thing file:

Thing http:url:TasmotaVersion [
    baseURL="https://api.github.com/repos/arendst/Tasmota/tags",
    refresh=86400] { // refresh once a day 86400
        Channels:
            Type string : Version "Version" [ stateTransformation="JSONPATH:$[0].name" ]
}

and the item:

String    Tasmota_Current_FW_Available    "Current Release [%s]"    {channel="http:url:TasmotaVersion:Version"}

I can’t spot a difference to the solution above … (JSONPathtransformation is working, http binding is reinstalled!)

Did you check for any errors in opemhab.log?
How does your sitemap look like?

Does your xxx.things file load? (note, things with s) See your openhab.log for a message.

Does the Thing appear in the MainUI list, what does that have to say about it?

log file says: “refreshed and loaded”. No errors, not even a hint what is wrong.
I cleaned the cache of openhab, restarted OH, even renamed the string item “firmware”. Item still contains “Null”.

Even the jsonpath transformation is correct: “$[0].name” result in the correct firmware. (Checked within https://jsonpath.com/). Could it be, that OH 2.5.12 has a problem with the expression “$[0].name”?

.things file syntax. LOOONG Time ago :wink: I had to dig deep!

Shouldn’t it read:

transformationPattern= "JSONPATH:$[0].name"
1 Like