Once you've got the Tasmota firmware installed in your Sonoff POW and it's contactable on your network, you'll (probably) want to configure it to do something useful.
I installed Mosquitto on a Raspberry Pi (including the client package) and configured Tasmota to talk to it:
From the Configure MQTT menu, set:
The Sonoff will then start publishing messages to the MQTT server, which you can subscribe to and read from the Mosquitto-client:
mosquitto_sub -h mqtt.servername.or.address -t '#' -v
Will show all messages which get sent to the MQTT server, for any topic.
When you restart the Sonoff, it will publish some messages such as:
Home/SonoffTwo/tele/LWT Online Home/SonoffTwo/cmnd/POWER (null) Home/SonoffTwo/tele/INFO1 {"Module":"Sonoff Pow","Version":"5.12.0","FallbackTopic":"SonoffTwo","GroupTopic":"sonoffs"} Home/SonoffTwo/tele/INFO2 {"WebServerMode":"Admin","Hostname":"Sonoff-Two","IPAddress":"192.168.32.33"} Home/SonoffTwo/tele/INFO3 {"RestartReason":"Software/System restart"} homeassistant/switch/SonoffTwo/config (null) Home/SonoffTwo/stat/RESULT {"POWER":"ON"} Home/SonoffTwo/stat/POWER ON Home/SonoffTwo/tele/STATE {"Time":"2018-02-15T16:22:22","Uptime":"0T00:00:15","Vcc":3.247,"POWER":"ON","Wifi":{"AP":1,"SSId":"Wireless","RSSI":94,"APMac":"00:25:9C:83:7E:69"}} Home/SonoffTwo/tele/SENSOR {"Time":"2018-02-15T16:22:22","ENERGY":{"Total":0.000,"Yesterday":0.000,"Today":0.000,"Period":0,"Power":0,"Factor":0.00,"Voltage":216,"Current":0.000}}
The last two lines will then be repeated every five minutes with up to date values.
You can configure the Sonoff far more via MQTT than you can via the web interface. See these pages for more information:
Here are some particularly useful commands:
Change the measurement reporting interval from 5 minutes to 10 seconds (which is the minimum you can set):
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/cmnd/TelePeriod -m 10
Change the blue LED so that instead of simply being on all the time to indicate power is applied, flash when there is MQTT activity:
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/cmnd/LEDstate -m 6
Set the relay so that it is always on when the Sonoff is powered, and cannot be turned off by pressing the button:
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/cmnd/PowerOnState -m 4
Make the commands and responses a little more verbose - change "cmnd" to "command", change "tele" (which stands for telemetry) to "value", and change "stat" to "status":
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/cmnd/Prefix1 -m command $ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/command/Prefix2 -m status $ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/command/Prefix3 -m value
Note that:
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/cmnd/Backlog -m "Prefix1 command; Prefix2 status; Prefix3 value"
Set the voltage and power measurements to show one decimal place (default is none; one decimal place is all that's available):
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/command/VoltRes -m 1 $ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/command/WattRes -m 1
Set the timezone the Sonoff is being used in:
$ mosquitto_pub -h mqtt.servername.or.address -t Home/SonoffTwo/command/Timezone -m 1
Note that most of the above commands will also report back with the current setting if you use mosquitto_pub with the -n option instead of -m value.
There are also some very useful commands for calibrating your POW.
Go up
Return to main index.