Disclaimer

Please, proceed carefully following the tips published in this blog, specially when Main Power is involved. I'm not responsible for any damages caused by what is written in this blog.
Thank you
Showing posts with label smadds. Show all posts
Showing posts with label smadds. Show all posts

Sunday, 8 October 2017

Home Automation System - Checking TASMOTA firmware updates with OpenHAB v.2





A little post about managing notifications about new TASMOTA firmware versions for SONOFF devices on OpenHAB v.2

As we already know reading the official TASMOTA documentation (https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#firmware-binary-sources), @smadds user manages a public MQTT broker "sonoff.maddox.co.uk:1883", where he publishes the last version number of the TASMOTA firmware using topic sonoff-version.

So, in my setup, I just added an "item" linked to this value, through MQTT and then published it on my sitemap.

First thing to do was create a new MQTT connection (called sonoffmaddox-mqtt) to the @smadds broker, appending the following lines to the /etc/openhab2/services/mqtt.cfg file

sonoffmaddox-mqtt.url=tcp://sonoff.maddox.co.uk:1883
sonoffmaddox-mqtt.clientId=
sonoffmaddox-mqtt.user=
sonoffmaddox-mqtt.pwd=
sonoffmaddox-mqtt.qos=0
sonoffmaddox-mqtt.retain=true

Then I created a new file called general.itemsin the /etc/openhab2/items folder, in which I wrote down the following line:

String      SonoffTasmotaVersion      "SONOFF Tasmota Version [%s]"     <settings>
{mqtt="<[sonoffmaddox-mqtt:sonoff-version:state:default]"}


My item is called SonoffTasmotaVersion, its type is "String" and it is linked to the mqtt connection called sonoffmaddox-mqtt, topic sonoff-version. In this way, this item will be updated everytime someone will publish new messages on topic sonoff-version.


Last step: I added my new item to the sitemap, just to keep tracking of the last TASMOTA version.
So, I edited the /etc/openhab2/sitemaps/test.sitemap file, inserting, on the top, the item just created inside a frame called "general":

Frame label="General" {
    Text item=SonoffTasmotaVersion
}

Here is the result:



To be more useful, I created a new OpenHAB rule just to be notified every time the TASMOTA version will be updated.

So, I created the /etc/openhab2/rules/checks.rules file, and wrote down the following lines:

rule "tasmota version check"
when
Item SonoffTasmotaVersion changed
then

logInfo("rules", "New Tasmota Version " + SonoffTasmotaVersion.state)

sendNotification([user_to_be_notified], "New Tasmota Version " + SonoffTasmotaVersion.state)

end

The sendNotification function sends a notification to the specified user; this notification reaches the mobile devices where the OpenHAB App is installed and linked to the OpenHAB cloud (MyOpenHAB). Its configuration is very simple, just following the official guide: http://docs.openhab.org/addons/io/openhabcloud/readme.html

Now I have to wait for the next TASMOTA update just to check that all is working as expected.

Wednesday, 30 August 2017

Home Automation System - SONOFF Tasmota firmware upgrade using OTA




It's been a while since the first TASMOTA firmware upload and several updates have already come out.

Let's see the TASMOTA releases page

https://github.com/arendst/Sonoff-Tasmota/releases

You can see that the latest version is 5.6.1 and I uploaded on my SONOFF 5.3.0 version, as you can see on the "information" page on the web console of the SONOFF


So, it's time to perform an upgrade.

Don't worry, I don't need to open,it, unplug from the main power, solder serial contacts and connect it to the PC...after the first installation of TASMOTA, I'm able to upgrade the firmware on the fly, using OTA (Over The Air)procedure; I have to tell it where it can download the new firmware and the game is over. Very comfortable functionality!!!

So, I followed the official wiki:

https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#upgrading-via-ota

I chose the automatic download choice, so I have no need to download the new firmware and upload it to the device. I must only put the firmware url in a property of the SONOFF and start upgrade it. All these operations can be done directly from the console or through MQTT messages.

There is only one thing to check: the firmware size, because you can go out of memory if it's too big. There is a workaround for this: you can upload a minimal firmware and then the complete one.

Just a couple of notes:

- sometimes this procedure can go wrong...it seems that on some TASMOTA versions there is a bug with OTA (but I'm not sure about this). I tried 3 times to get it works.

- after upgrade SONOFF, it reboots with "access point" mode (I don't know if this is right or wrong...) and so I linked my PC to its wifi network, go into the web console (url 10.0.0.1) and just reboot it again



A special note here: subscribing to the topic sonoff-version on a public MQTT broker sonoff.maddox.co.uk:1883 you can get a message with the TASMOTA latest version (thanks to  @smadds)

Here is it, using mqtt-spy


Here is a video about my upgrade procedure: