Sonoff Tasmota latest firmware sensor?

@DavidFW1960 I tried to follow this through tot he conclusion but I couldn’t work out what the final answer was to doing this in hassio?

Also, and yes I know generally always keep up with the latest firmware, but is there benefit to upgrading all my sonoffs? I understand that from now on they all have to be physically re-flashed. Or am I wrong about that too?

Thanks

The answer is here:

is there benefit to upgrading all my sonoffs?
I think it’s a good practice to do so…

I understand that from now on they all have to be physically re-flashed. >>Or am I wrong about that too?

You’re wrong about that. Once you have Tasmota on them you can flash the latest over the air. I started with 5.12 and flashed 5.14 OTA. Only thing is you need to do it in 2 steps as the firmware is too large to fit in one hit so you flash with 5.14 minimal and then flash with 5.14 Reason is the 5.14 is larger in size than 1/2 the available ram on the Sonoff so it can’t hold both firmwares simultaneously so flashing the minimal firmware frees up enough space for the full version.

One challenge is keeping track of which firmware each device has installed etc and then update individual device configurations etc. Has anyone started tracking their sonoff device firmware and OTA upgrades within HA ?

@DavidFW1960 Thanks - I saw that answer but the following comments confused me into thinking you had found a better one!!

Thanks again for the other answers too.

Do a search for TasmoAdmin

Well kinda…

I’m using a script instead of having the command in configuration.yaml. So in my config yaml I have this:

# Sonoff Firmware Version
  - platform: command_line
    name: Sonoff Firmware Version
    command: /config/versionsonoffhtml.sh
    scan_interval: 21600

And the versionsonoffhtml.sh looks like this:

#!/bin/bash
curl -s https://github.com/arendst/Sonoff-Tasmota/releases/latest | cut -d\" -f2 | rev | cut -d/ -f1 | rev 2>/config/versionsonoffhtml.err

Which works fine.

I originally wanted to use the MQTT command but in the process of that I discovered that when Home Assistant runs a command from configuration.yaml, it runs it in the host container and the host does not have the mosquitto_sub installed hence the error. When you run it from ssh, that home assistant container DOES have the mosquitto_sub so it works. So the only way is to use the HTML way as above.

I also discovered that yaml strips that / off the HTML command and you’ll see that if you run the command @VDRainer gave me from ssh it will give you an error about the cut command not allowing 2 characters but when it was run from the yaml file it worked.

Anyway it was an interesting exercise and I learnt a lot which is 90% of my objective.

I only have 2 Sonoff devices so keeping track of them and their firmware version isn’t really an issue for me but if I had a lot I can see I’d use a spreadsheet or something like that and tick them off as I update them. I pretty much like to keep everything up-to-date as I’m less prone to get caught by breaking changes and if something breaks you can always roll back pretty easily.

Whilst this is a great idea and I’m going to do it just because, have you seen this sonWEB it will do what you want as an add on with UI for managing your sonoff devices aswell as OTA firmware.

Thanks! Never seen that one before. I’ll take a look.

They have changed the URL now slightly.

Correct code will now be

  - platform: command_line
    name: "Latest Tasmota"
    command: "curl -s https://github.com/arendst/Tasmota/releases/latest | cut -d'\"' -f2 | rev | cut -d'/' -f1 | rev"
    scan_interval: 600

Seems that something changed in the URL now again.
It redirects in the browser.

Any suggestion on how to fix this sensor? :slight_smile:

Still seems unchanged to me.

Strange, for me the sensor became empty since this morning. Was working fine more then a year. No errors at all, it is just empty.

Have you tried visiting the URL in a browser. Still good here

I’m seeing the same - no errors, just an empty sensor. I’m also seeing the same thing with a similar sensor I’ve set up for the latest Valetudo version on GitHub.

It seems the ‘latest’ link no longer loads a redirect message, but just an empty page, before redirecting. Running the curl command from a command line without the -s (silent) parameter, and without the ‘cut’ filter, now just produces an empty response. From memory, it used to show the redirect message.

The link itself obviously still redirects correctly in a web browser, but that’s not really the point surely? From my understanding, curl doesn’t redirect by default, and so just stays on the page with the redirect message, which is what we want - not the page it ends up on - so we can extract the latest version from the message using ‘cut’.

I wonder if you’re not seeing this yet due to some caching going on somewhere?

A bit of googling around produced this, which works from the command line:

curl -LsI -o /dev/null -w %{url_effective} https://github.com/arendst/Tasmota/releases/latest | rev | cut -d'/' -f1 | cut -d'v' -f1 | rev

Explanations as far as I can see:
-L - follows the redirect
-I - only downloads the headers of the destination page, not the body - seems to cut down the text that the command returns
-s - curl works silently
-o - output → /dev/null - output result to null
-w - return the final url (which we need to work the cut magic on)

Because we are dealing with the url now, there’s no need to handle quotation marks or escape them, so we can drop the first cut action from the previous version.

Will see if this gets the sensor back up and running and report back.

EDIT: yep, seems to work fine for both the Tasmota and Valetudo sensors.

5 Likes

Solved the issue for me.
Thanks!

ok I worked it out. I am using the Github integration not curl. I have arendst/tasmota starred. It provides a sensor


and I use a template sensor to extract the tag

      tasmota_firmware_version_available:
        friendly_name: 'Tasmota Firmware Version Available'
        value_template: "{{ state_attr('sensor.arendst_tasmota_latest_release', 'tag') }}"

IF I visit Release Tasmota v13.4.0 Quinta · arendst/Tasmota · GitHub the url in the original sensor above I see this though:
image
so I don’t understand why the original isn’t still working.

Thanks a lot for this!

Working here as well with this example. Great find!

Did work for me untill HA update 2024.2.1.
Now the curl command stays active consuming lots of CPU.
Every 10 minutes the command will run again and it will start a new process consuming CPU.

Anyone having the same issue with this HA update?