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
IoT - smartHome (181 posts)
08/10/2017
Home Automation System - Checking TASMOTA firmware updates with OpenHAB v.2
by Marco Lamanna
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.clientId=
sonoffmaddox-mqtt.user=
sonoffmaddox-mqtt.pwd=
sonoffmaddox-mqtt.qos=0
sonoffmaddox-mqtt.retain=true
Then I created a new file called general.items, in 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":
Text item=SonoffTasmotaVersion
}
Here is the result:
So, I created the /etc/openhab2/rules/checks.rules file, and wrote down the following lines:
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.