Initial

arendst 2017-01-28 14:50:30 +01:00
parent b6571a3544
commit fe1048d7c3
15 changed files with 1149 additions and 1 deletions

53
Button-usage.md Normal file

@ -0,0 +1,53 @@
The button on sonoff provides the following features
### Version 2.0.3 and up:
- a short press toggles the relay either directly or by sending a MQTT message like ```cmnd/sonoff/1/light on```. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/LIGHT on```. If ```cmnd/sonoff/ButtonRetain on``` has been used the MQTT message will also contain the MQTT retain flag.
- two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/POWER on```. For Sonoff Dual this will switch relay 2.
- three short presses start Wifi smartconfig allowing for SSID and Password configuration using an Android mobile phone with the [ESP8266 SmartConfig](https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch) app. The MQTT server still needs to be configured in the ```user_config.h``` file. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- four short presses start Wifi manager providing an Access Point with IP address 192.168.4.1 and a web server allowing the configuration of both Wifi and MQTT parameters. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- five short presses start Wifi Protected Setup (WPS) allowing for SSID and Password configuration using the routers WPS button or webpage. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- six short presses will restart sonoff
- seven short presses start OTA download of firmware. The green LED is lit during the update
- pressing the button for over four seconds resets settings to defaults as defined in ```user_config.h``` and restarts the device
### Version 2.0.2 down to 2.0.0:
- a short press toggles the relay either directly or by sending a MQTT message like ```cmnd/sonoff/1/light 2```. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/LIGHT on```.
- two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/POWER on```. For Sonoff Dual this will switch relay 2.
- three short presses start Wifi smartconfig allowing for SSID and Password configuration using an Android mobile phone with the [ESP8266 SmartConfig](https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch) app. The MQTT server still needs to be configured in the ```user_config.h``` file. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- four short presses start Wifi manager providing an Access Point with IP address 192.168.4.1 and a web server allowing the configuration of both Wifi and MQTT parameters. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- five short presses start Wifi Protected Setup (WPS) allowing for SSID and Password configuration using the routers WPS button or webpage. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- six short presses will restart sonoff
- seven short presses start OTA download of firmware. The green LED is lit during the update
- pressing the button for over four seconds resets settings to defaults as defined in ```user_config.h``` and restarts the device
### Version 1.0.35 down to 1.0.32:
- a short press toggles the relay either directly or by sending a MQTT message like ```cmnd/sonoff/light 2```. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/LIGHT on```
- two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/POWER on```
- three short presses start Wifi smartconfig allowing for SSID and Password configuration using an Android mobile phone with the [ESP8266 SmartConfig](https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch) app. The MQTT server still needs to be configured in the ```user_config.h``` file. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- four short presses start Wifi manager providing an Access Point with IP address 192.168.4.1 and a web server allowing the configuration of both Wifi and MQTT parameters. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- five short presses start Wifi Protected Setup (WPS) allowing for SSID and Password configuration using the routers WPS button or webpage. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- six short presses will restart sonoff
- seven short presses start OTA download of firmware. The green LED is lit during the update
- pressing the button for over four seconds resets settings to defaults as defined in ```user_config.h``` and restarts the device
### Version 1.0.31 down to 1.0.22:
- a short press toggles the relay either directly or by sending a MQTT message like ```cmnd/sonoff/light 2```. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/LIGHT on```
- two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/POWER on```
- three short presses start Wifi smartconfig allowing for SSID and Password configuration using an Android mobile phone with the [ESP8266 SmartConfig](https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch) app. The MQTT server still needs to be configured in the ```user_config.h``` file. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- four short presses start Wifi manager providing an Access Point with IP address 192.168.4.1 and a web server allowing the configuration of both Wifi and MQTT parameters. The LED will blink during the config period. A single button press during this period will abort and restart sonoff.
- five short presses will restart sonoff
- six short presses start OTA download of firmware. The green LED is lit during the update
- pressing the button for over four seconds resets settings to defaults as defined in ```user_config.h``` and restarts the device
### Version 1.0.21 and down:
- a short press toggles the relay either by sending a MQTT message like ```cmnd/sonoff/light 2``` or directly. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/LIGHT on```
- two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like ```stat/sonoff/POWER on```
- three short presses start Wifi smartconfig which allows for SSID and Password configuration using an Android mobile phone with the [ESP8266 SmartConfig](https://play.google.com/store/apps/details?id=com.cmmakerclub.iot.esptouch) app. The green LED will blink during the smartconfig period for 1 minute. The MQTT server still needs to be configured in the ```user_config.h``` file
- four short presses start OTA download of firmware. The green LED is lit during the update
- five short presses will restart sonoff
- pressing the button for over four seconds resets settings to defaults as defined in ```user_config.h``` and restarts the device

480
Commands.md Normal file

@ -0,0 +1,480 @@
The firmware supports a **serial**, **MQTT** and **Web** Man Machine interface. The serial interface is set to 115200 bps except for Sonoff Dual where it is set to 19200 bps. The MQTT commands are constructed from MQTT Topic for ```cmnd/sonoff/<command>``` and MQTT Message for ```<parameter>``` and are NOT case sensitive.
Starting with version 2.0.0 UNTIL version 3.0.0 commands are allowed like ```cmnd/sonoff/1/<command>``` to address a specific relay where applicable.
Starting with version 3.0.0 commands are allowed like ```cmnd/sonoff/<command><relay>``` to address a specific relay where applicable.
Use [this link](https://docs.google.com/spreadsheets/d/1JZc5GuVlFEYafDTJu1cxwqsMlqyRxI81mXgOphHAScY/edit?usp=sharing) to show all commands in one document.
The following command tables are available:
- Main
- [Management](#management)
- [Wifi](#wifi)
- [MQTT](#mqtt)
- [Logging](#logging)
- [Sonoff Pow specific](#sonoff-pow)
- [Domoticz](#domoticz)
- [WS2812 led string](#ws2812-led-string)
- [Next Generation specific](#next-generation)
- [Optional](#optional)
### Main
Command | Version | Description
------- | ------- | -----------
BlinkCount | 3.1.6 | Show current BlinkCount
BlinkCount 0 | 3.1.6 | Blink many times before restoring power state
BlinkCount 1 .. 32000 | 3.1.6 | Set how many blinks before restoring power state
BlinkTime | 3.1.6 | Show current BlinkTime in 0.1 seconds
BlinkTime 2 .. 3600 | 3.1.6 | Set BlinkTime with 0.1 seconds increment
LedPower | 3.2.9 | Show current led power state as On or Off
LedPower off | 3.2.9 | Turn led AND LedState Off
LedPower on | 3.2.9 | Turn led On AND LedState Off
LedPower 0 | 3.2.9 | Turn led AND LedState Off
LedPower 1 | 3.2.9 | Turn led On AND LedState Off
LedState | 1.0.13 | Show current led state as 0 to 7
LedState off | 3.0.5 | Disable use of LED as much as possible
LedState on | 1.0.13 | Show power state on led
LedState 0 | 3.0.5 | Disable use of LED as much as possible
LedState 1 | 1.0.13 | Show power state on led
LedState 2 | 3.0.5 | Show MQTT subscriptions as a led blink
LedState 3 | 3.0.5 | Show power state and MQTT subscriptions as a led blink
LedState 4 | 3.0.5 | Show MQTT publications as a led blink
LedState 5 | 3.0.5 | Show power state and MQTT publications as a led blink
LedState 6 | 3.0.5 | Show all MQTT messages as a led blink
LedState 7 | 3.0.5 | Show power state and MQTT messages as a led blink
Light | | Show current power state as On or Off
Light on | | Turn power On
Light off | | Turn power Off
Light toggle | | Toggle power
Light blink | 3.1.6 | Blink power
Light blinkoff | 3.1.6 | Stop blinking power
Light 1 | | Turn power On
Light 0 | | Turn power Off
Light 2 | | Toggle power
Light 3 | 3.1.6 | Blink power
Light 4 | 3.1.6 | Stop blinking power
Light1 | 3.0.0 | (Dual/Dragon/4CH) Show current power state of relay1
Light1 on | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power On
Light1 off | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power Off
Light1 toggle | 3.0.0 | (Dual/Dragon/4CH) Toggle relay1 power
Light1 blink | 3.1.6 | (Dual/Dragon/4CH) Blink relay1 power
Light1 blinkoff | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay1 power
Light1 1 | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power On
Light1 0 | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power Off
Light1 2 | 3.0.0 | (Dual/Dragon/4CH) Toggle relay1 power
Light1 3 | 3.1.6 | (Dual/Dragon/4CH) Blink relay1 power
Light1 4 | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay1 power
Light2 | 3.0.0 | (Dual/Dragon/4CH) Show current power state of relay2
Light2 on | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power On
Light2 off | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power Off
Light2 toggle | 3.0.0 | (Dual/Dragon/4CH) Toggle relay2 power
Light2 blink | 3.1.6 | (Dual/Dragon/4CH) Blink relay2 power
Light2 blinkoff | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay2 power
Light2 1 | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power On
Light2 0 | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power Off
Light2 2 | 3.0.0 | (Dual/Dragon/4CH) Toggle relay2 power
Light2 3 | 3.1.6 | (Dual/Dragon/4CH) Blink relay2 power
Light2 4 | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay2 power
Light3 | 3.1.1 | (4CH) Show current power state of relay3
Light3 on | 3.1.1 | (4CH) Turn relay3 power On
Light3 off | 3.1.1 | (4CH) Turn relay3 power Off
Light3 toggle | 3.1.1 | (4CH) Toggle relay3 power
Light3 blink | 3.1.6 | (4CH) Blink relay3 power
Light3 blinkoff | 3.1.6 | (4CH) Stop blinking relay3 power
Light3 1 | 3.1.1 | (4CH) Turn relay3 power On
Light3 0 | 3.1.1 | (4CH) Turn relay3 power Off
Light3 2 | 3.1.1 | (4CH) Toggle relay3 power
Light3 3 | 3.1.6 | (4CH) Blink relay3 power
Light3 4 | 3.1.6 | (4CH) Stop blinking relay3 power
Light4 | 3.1.1 | (4CH) Show current power state of relay4
Light4 on | 3.1.1 | (4CH) Turn relay4 power On
Light4 off | 3.1.1 | (4CH) Turn relay4 power Off
Light4 toggle | 3.1.1 | (4CH) Toggle relay4 power
Light4 blink | 3.1.6 | (4CH) Blink relay4 power
Light4 blinkoff | 3.1.6 | (4CH) Stop blinking relay4 power
Light4 1 | 3.1.1 | (4CH) Turn relay4 power On
Light4 0 | 3.1.1 | (4CH) Turn relay4 power Off
Light4 2 | 3.1.1 | (4CH) Toggle relay4 power
Light4 3 | 3.1.6 | (4CH) Blink relay4 power
Light4 4 | 3.1.6 | (4CH) Stop blinking relay4 power
MessageFormat | 2.0.7 | (Until 4.0.0) Show current MQTT message format (0 = Legacy, 1 = JSON)
MessageFormat 0 | 2.0.7 | (Until 4.0.0) (default) Send legacy messages
MessageFormat 1 | 2.0.7 | (Until 4.0.0) Send JSON messages and Legacy power state message
Power | | Show current power state as On or Off
Power on | | Turn power On
Power off | | Turn power Off
Power toggle | | Toggle power
Power blink | 3.1.6 | Blink power
Power blinkoff | 3.1.6 | Stop blinking power
Power 1 | | Turn power On
Power 0 | | Turn power Off
Power 2 | | Toggle power
Power 3 | 3.1.6 | Blink power
Power 4 | 3.1.6 | Stop blinking power
Power1 | 3.0.0 | (Dual/Dragon/4CH) Show current power state of relay1
Power1 on | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power On
Power1 off | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power Off
Power1 toggle | 3.0.0 | (Dual/Dragon/4CH) Toggle relay1 power
Power1 blink | 3.1.6 | (Dual/Dragon/4CH) Blink relay1 power
Power1 blinkoff | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay1 power
Power1 1 | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power On
Power1 0 | 3.0.0 | (Dual/Dragon/4CH) Turn relay1 power Off
Power1 2 | 3.0.0 | (Dual/Dragon/4CH) Toggle relay1 power
Power1 3 | 3.1.6 | (Dual/Dragon/4CH) Blink relay1 power
Power1 4 | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay1 power
Power2 | 3.0.0 | (Dual/Dragon/4CH) Show current power state of relay2
Power2 on | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power On
Power2 off | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power Off
Power2 toggle | 3.0.0 | (Dual/Dragon/4CH) Toggle relay2 power
Power2 blink | 3.1.6 | (Dual/Dragon/4CH) Blink relay2 power
Power2 blinkoff | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay2 power
Power2 1 | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power On
Power2 0 | 3.0.0 | (Dual/Dragon/4CH) Turn relay2 power Off
Power2 2 | 3.0.0 | (Dual/Dragon/4CH) Toggle relay2 power
Power2 3 | 3.1.6 | (Dual/Dragon/4CH) Blink relay2 power
Power2 4 | 3.1.6 | (Dual/Dragon/4CH) Stop blinking relay2 power
Power3 | 3.1.1 | (4CH) Show current power state of relay3
Power3 on | 3.1.1 | (4CH) Turn relay3 power On
Power3 off | 3.1.1 | (4CH) Turn relay3 power Off
Power3 toggle | 3.1.1 | (4CH) Toggle relay3 power
Power3 blink | 3.1.6 | (4CH) Blink relay3 power
Power3 blinkoff | 3.1.6 | (4CH) Stop blinking relay3 power
Power3 1 | 3.1.1 | (4CH) Turn relay3 power On
Power3 0 | 3.1.1 | (4CH) Turn relay3 power Off
Power3 2 | 3.1.1 | (4CH) Toggle relay3 power
Power3 3 | 3.1.6 | (4CH) Blink relay3 power
Power3 4 | 3.1.6 | (4CH) Stop blinking relay3 power
Power4 | 3.1.1 | (4CH) Show current power state of relay4
Power4 on | 3.1.1 | (4CH) Turn relay4 power On
Power4 off | 3.1.1 | (4CH) Turn relay4 power Off
Power4 toggle | 3.1.1 | (4CH) Toggle relay4 power
Power4 blink | 3.1.6 | (4CH) Blink relay4 power
Power4 blinkoff | 3.1.6 | (4CH) Stop blinking relay4 power
Power4 1 | 3.1.1 | (4CH) Turn relay4 power On
Power4 0 | 3.1.1 | (4CH) Turn relay4 power Off
Power4 2 | 3.1.1 | (4CH) Toggle relay4 power
Power4 3 | 3.1.6 | (4CH) Blink relay4 power
Power4 4 | 3.1.6 | (4CH) Stop blinking relay4 power
PowerOnState | 3.1.1 | Show current relay power on state
PowerOnState 0 | 3.1.1 | Keep relay(s) off after power on
PowerOnState 1 | 3.1.1 | Turn relay(s) on after power on
PowerOnState 2 | 3.1.2 | Toggle relay(s) on from last saved
PowerOnState 3 | 3.1.2 | (default) Turn relay(s) on as last saved
PowerRetain | 3.0.0 | Show current MQTT power retain state
PowerRetain on | 3.0.0 | Enable MQTT power retain on status update
PowerRetain off | 3.0.0 | (default) Disable MQTT power retain on status update
PowerRetain 1 | 3.0.0 | Enable MQTT power retain on status update
PowerRetain 0 | 3.0.0 | (default) Disable MQTT power retain on status update
PulseTime | 3.0.6 | Show current PulseTime in 0.1 seconds
PulseTime off | 3.0.6 | (Default) Disable use of PulseTime
PulseTime 0 | 3.0.6 | (Default) Disable use of PulseTime
PulseTime 1 .. 111 | 3.0.6 | Set PulseTime with 0.1 seconds increment
PulseTime 112 .. 64900 | 3.1.9 | Set PulseTime with 1 seconds increment starting with 12 seconds (113 = 13 seconds etc.)
### Management
Command | Version | Description
------- | ------- | -----------
FriendlyName | 3.1.16 | Show friendly name as used by Alexa
FriendlyName 1 | 3.1.16 | Reset friendly name to ```user_config.h``` value (FRIENDLY_NAME)
FriendlyName \<your-name\> | 3.1.16 | Set friendly name
OtaUrl | | Show current otaurl
OtaUrl 1 | | Reset otaurl to ```user_config.h``` value
OtaUrl \<your-otaurl\> | | Set otaurl
Reset 1 | | Reset sonoff parameters to ```user_config.h``` values and restart
Reset 2 | 1.0.9 | Erase flash, reset sonoff parameters to ```user_config.h``` values and restart
Restart 1 | | Restart sonoff
Restart 99 | 1.0.23 | Force restart sonoff without config save
SaveData | 1.0.35 | Save parameter changes and show current state as Manual, On or every x seconds
SaveData on | 1.0.35 | (default) Save parameter changes every second
SaveData off | 1.0.35 | Save parameter changes only manually
SaveData 1 | 1.0.35 | (default) Save parameter changes every second
SaveData 0 | 1.0.35 | Save parameter changes only manually
SaveData \<your-secs\> | 1.0.35 | Save parameter changes between every 2 and 3600 seconds
SaveState | 2.0.3 | Show current SaveState state
SaveState on | 2.0.3 | (default) Save power changes and set relay after restart
SaveState off | 2.0.3 | Do not save power changes and do not set relay after restart
SaveState 1 | 2.0.3 | (default) Save power changes and set relay after restart
SaveState 0 | 2.0.3 | Do not save power changes and do not set relay after restart
Sleep | 3.2.12 | Show current sleep state as 0 (Off) or duration of up to 250 mSec
Sleep off | 3.2.12 | (default) Turn sleep off
Sleep 0 | 3.2.12 | (default) Turn sleep off
Sleep 1 - 250 | 3.2.12 | Set sleep duration from 1 to 250 mSec to enable energy saving
Status | | Show abbreviated status information
Status 0 | 1.0.15 | Show all status information
Status 1 | | Show more status information
Status 2 | | Show firmware information
Status 3 | 1.0.8 | Show syslog information
Status 4 | 1.0.8 | Show memory information
Status 5 | 1.0.9 | Show network information
Status 6 | 1.0.14 | Show MQTT information
Status 7 | 1.0.20 | Show Real Time Clock information
Status 8 | 2.0.5 | (Sonoff Pow only) Show Power usage
Status 9 | 2.0.6 | (Sonoff Pow only) Show Power thresholds
Timezone | | Show current timezone
Timezone -12 .. 12 | | Set timezone
Timezone 99 | 1.0.20 | Use Daylight Saving parameters from ```user_config.h```
Upgrade 1 | | Download ota firmware from your web server and restart
Upload 1 | 1.0.23 | Download ota firmware from your web server and restart
### Wifi
Command | Version | Description
------- | ------- | -----------
AP | 2.1.2 | Show current selected Wifi Access Point (AP)
AP 0 | 2.1.2 | Switch to other Wifi Access Point (AP)
AP 1 | 2.1.2 | Select Wifi Access Point 1 (AP)
AP 2 | 2.1.2 | Select Wifi Access Point 2 (AP)
Hostname | 1.0.26 | Show current hostname
Hostname 1 | 1.0.26 | Reset hostname to ```user_config.h``` value and restart
Hostname \<your-host\> | 1.0.26 | Set hostname and restart
Password | | Show AP1 current Wifi password
Password 1 | | Reset AP1 Wifi password to ```user_config.h``` value and restart
Password \<your-password\> | | Set AP1 Wifi password and restart
Password1 | 2.1.2 | Show AP1 current Wifi password
Password1 1 | 2.1.2 | Reset AP1 Wifi password to ```user_config.h``` value and restart
Password1 \<your-password\> | 2.1.2 | Set AP1 Wifi password and restart
Password2 | 2.1.2 | Show AP2 current Wifi password
Password2 1 | 2.1.2 | Reset AP2 Wifi password to ```user_config.h``` value and restart
Password2 \<your-password\> | 2.1.2 | Set AP2 Wifi password and restart
SmartConfig 1 | | (Deprecated - use wificonfig) Start smart config for 1 minute
SmartConfig 2 | 1.0.22 | (Deprecated - use wificonfig) Start wifi manager (web server at 192.168.4.1)
SSId | | Show AP1 current Wifi SSId
SSId 1 | | Reset AP1 Wifi SSId to ```user_config.h``` value and restart
SSId \<your-ssid\> | | Set AP1 Wifi SSId and restart
SSId1 | 2.1.2 | Show AP1 current Wifi SSId
SSId1 1 | 2.1.2 | Reset AP1 Wifi SSId to ```user_config.h``` value and restart
SSId1 \<your-ssid\> | 2.1.2 | Set AP1 Wifi SSId and restart
SSId2 | 2.1.2 | Show AP2 current Wifi SSId
SSId2 1 | 2.1.2 | Reset AP2 Wifi SSId to ```user_config.h``` value and restart
SSId2 \<your-ssid\> | 2.1.2 | Set AP2 Wifi SSId and restart
WebServer | 1.0.23 | Show current web server state
WebServer 0 | 1.0.23 | Stop web server
WebServer 1 | 1.0.23 | Start web server in user mode
WebServer 2 | 1.0.23 | Start web server in admin mode
WifiConfig | 1.0.32 | Show current config tool
WifiConfig 0 | 1.0.32 | (Deprecated) Start current config tool
WifiConfig 0 | 2.1.2 | Disable wifi config but restart (used with alternate AP)
WifiConfig 1 | 1.0.32 | Start smart config for 1 minute and set as current config tool
WifiConfig 2 | 1.0.32 | Start wifi manager (web server at 192.168.4.1) and set as current config tool
WifiConfig 3 | 1.0.32 | Start WPS config for 1 minute and set as current config tool
WifiConfig 4 | 3.0.5 | Disable wifi config but retry other AP without restart
### MQTT
Command | Version | Description
------- | ------- | -----------
ButtonRetain | 2.0.3 | Show current button MQTT retain flag state
ButtonRetain on | 2.0.3 | Set ButtonTopic to Topic and enable MQTT retain flag on button press
ButtonRetain off | 2.0.3 | (default) Disable use of MQTT retain flag
ButtonRetain 1 | 2.0.3 | Set ButtonTopic to Topic and enable MQTT retain flag on button press
ButtonRetain 0 | 2.0.3 | (default) Disable use of MQTT retain flag
ButtonTopic | 1.0.10 | Show current MQTT button topic
ButtonTopic 0 | 1.0.10 | Disable use of MQTT button topic
ButtonTopic 1 | 1.0.10 | Set MQTT button topic to Topic
ButtonTopic \<your-topic\> | 1.0.10 | Set MQTT button topic
GroupTopic | | Show current MQTT group topic
GroupTopic 1 | | Reset MQTT group topic to ```user_config.h``` value and restart
GroupTopic \<your-grouptopic\> | | Set MQTT group topic and restart
MessageFormat | 2.0.7 | (Until 4.0.0) Show current MQTT message format (0 = Legacy, 1 = JSON)
MessageFormat 0 | 2.0.7 | (Until 4.0.0) (default) Send legacy messages
MessageFormat 1 | 2.0.7 | (Until 4.0.0) Send JSON messages and Legacy power state message
MqttClient | 1.0.22 | Show current MQTT client
MqttClient 1 | 1.0.22 | Reset MQTT client to ```user_config.h``` value and restart
MqttClient \<your-client\> | 1.0.22 | Set MQTT client and restart. May use wildcard %06X to be replaced by last six characters of MAC address
MqttHost | | Show current MQTT host
MqttHost 1 | | Reset MQTT host to ```user_config.h``` value and restart
MqttHost \<your-host\> | | Set MQTT host and restart
MqttPassword | 1.0.22 | Show current MQTT password
MqttPassword 1 | 1.0.22 | Reset MQTT password to ```user_config.h``` value and restart
MqttPassword \<your-password\> | 1.0.22 | Set MQTT password and restart
MqttPort | 1.0.22 | Show current MQTT port
MqttPort 1 | 1.0.22 | Reset MQTT port to ```user_config.h``` value and restart
MqttPort \<your-port\> | 1.0.22 | Set MQTT port between 2 and 32766 and restart
MqttUser | 1.0.22 | (Until 4.0.0) Show current MQTT user name
MqttUser 1 | 1.0.22 | (Until 4.0.0) Reset MQTT user name to ```user_config.h``` value and restart
MqttUser \<your-user\> | 1.0.22 | (Until 4.0.0) Set MQTT user name and restart
MqttUnits | 2.0.5 | (Until 4.0.0) Show current MqttUnits state
MqttUnits on | 2.0.5 | (Until 4.0.0) Add units to MQTT messages
MqttUnits off | 2.0.5 | (Until 4.0.0) (default) Do not show units to MQTT messages
Units 1 | 4.0.0 | Add units to messages
Units 0 | 4.0.0 | (default) Do not show units to messages
Units | 4.0.0 | Show current Units state
Units on | 4.0.0 | Add units to messages
Units off | 4.0.0 | (default) Do not show units to messages
Units 1 | 4.0.0 | Add units to messages
Units 0 | 4.0.0 | (default) Do not show units to messages
PowerRetain | 3.0.0 | Show current MQTT power retain state
PowerRetain on | 3.0.0 | Enable MQTT power retain on status update
PowerRetain off | 3.0.0 | (default) Disable MQTT power retain on status update
PowerRetain 1 | 3.0.0 | Enable MQTT power retain on status update
PowerRetain 0 | 3.0.0 | (default) Disable MQTT power retain on status update
SwitchRetain | 3.2.9 | Show current button MQTT retain flag state
SwitchRetain on | 3.2.9 | Set ButtonTopic to Topic and enable MQTT retain flag on button press
SwitchRetain off | 3.2.9 | (default) Disable use of MQTT retain flag
SwitchRetain 1 | 3.2.9 | Set ButtonTopic to Topic and enable MQTT retain flag on button press
SwitchRetain 0 | 3.2.9 | (default) Disable use of MQTT retain flag
SwitchTopic | 3.2.9 | Show current MQTT button topic
SwitchTopic 0 | 3.2.9 | Disable use of MQTT button topic
SwitchTopic 1 | 3.2.9 | Set MQTT button topic to Topic
SwitchTopic \<your-topic\> | 3.2.9 | Set MQTT button topic
TelePeriod | 1.0.28 | Show current telemetry period in seconds
TelePeriod off | 1.0.28 | Disable telemetry messages
TelePeriod 0 | 1.0.28 | Disable telemetry messages
TelePeriod 1 | 1.0.28 | Reset telemetry period to ```user_config.h``` value
TelePeriod \<your-secs\> | 1.0.28 | Set telemetry period between 2 and 3600 seconds
Topic | | Show current MQTT topic
Topic 1 | | Reset MQTT topic to ```user_config.h``` value and restart
Topic \<your-topic\> | | Set MQTT topic AND button topic and restart
### Logging
Command | Version | Description
------- | ------- | -----------
LogHost | 1.0.7 | Show current syslog host
LogHost 1 | 1.0.7 | Reset syslog host to ```user_config.h``` value
LogHost \<your-host\> | 1.0.7 | Set syslog host
LogPort | 1.0.26 | Show current syslog port
LogPort 1 | 1.0.26 | Reset syslog port to ```user_config.h``` value
LogPort \<your-port\> | 1.0.26 | Set syslog port between 2 and 32766
SerialLog 0 | 1.0.7 | Disable serial logging
SerialLog 1 | 1.0.7 | Show only error messages
SerialLog 2 | 1.0.7 | Show error and info messages
SerialLog 3 | 1.0.7 | Show error, info and debug messages
SerialLog 4 | 1.0.7 | Show all messages
SysLog 0 | 1.0.7 | Disable syslog logging
SysLog 1 | 1.0.7 | Show only error messages
SysLog 2 | 1.0.7 | Show error and info messages
SysLog 3 | 1.0.7 | Show error, info and debug messages
SysLog 4 | 1.0.7 | Show all messages
WebLog 0 | 1.0.27 | Disable web logging
WebLog 1 | 1.0.27 | Show only error messages
WebLog 2 | 1.0.27 | Show error and info messages
WebLog 3 | 1.0.27 | Show error, info and debug messages
WebLog 4 | 1.0.27 | Show all messages
### Sonoff Pow
Command | Version | Description
------- | ------- | -----------
CurrentHigh | 2.0.6 | Show current current high threshold value
CurrentHigh off | 2.0.6 | (default) Disable current high threshold
CurrentHigh 0 | 2.0.6 | (default) Disable current high threshold
CurrentHigh \<milliamps\> | 2.0.6 | Set current high threshold value
CurrentLow | 2.0.6 | Show current current low threshold value
CurrentLow off | 2.0.6 | (default) Disable current low threshold
CurrentLow 0 | 2.0.6 | (default) Disable current low threshold
CurrentLow \<milliamps\> | 2.0.6 | Set current low threshold value
PowerHigh | 2.0.6 | Show current power high threshold value
PowerHigh off | 2.0.6 | (default) Disable power high threshold
PowerHigh 0 | 2.0.6 | (default) Disable power high threshold
PowerHigh \<watt\> | 2.0.6 | Set power high threshold value
PowerLow | 2.0.6 | Show current power low threshold value
PowerLow off | 2.0.6 | (default) Disable power low threshold
PowerLow 0 | 2.0.6 | (default) Disable power low threshold
PowerLow \<watt\> | 2.0.6 | Set power low threshold value
Status 8 | 2.0.5 | Show Power usage
Status 9 | 2.0.6 | Show Power thresholds
VoltageHigh | 2.0.6 | Show current voltage high threshold value
VoltageHigh off | 2.0.6 | (default) Disable voltage high threshold
VoltageHigh 0 | 2.0.6 | (default) Disable voltage high threshold
VoltageHigh \<voltage\> | 2.0.6 | Set voltage high threshold value
VoltageLow | 2.0.6 | Show current voltage low threshold value
VoltageLow off | 2.0.6 | (default) Disable voltage low threshold
VoltageLow 0 | 2.0.6 | (default) Disable voltage low threshold
VoltageLow \<voltage\> | 2.0.6 | Set voltage low threshold value
### Domoticz
Command | Version | Description
------- | ------- | -----------
DomoticzIdx | 2.0.7 | Show current Domoticz relay1 index
DomoticzIdx off | 2.0.7 | (default) Disable use of Domoticz
DomoticzIdx 0 | 2.0.7 | (default) Disable use of Domoticz
DomoticzIdx \<idx\> | 2.0.7 | Set Domoticz relay1 index
DomoticzIdx\<index\> | 3.1.1 | Show current Domoticz relay1 to relay4 index
DomoticzIdx\<index\> off | 3.1.1 | (default) Disable use of Domoticz
DomoticzIdx\<index\> 0 | 3.1.1 | (default) Disable use of Domoticz
DomoticzIdx\<index\> \<idx\> | 3.1.1 | Set Domoticz relay1 to relay4 index
DomoticzInTopic | 2.0.7 | Show current Domoticz MQTT In Topic
DomoticzInTopic 1 | 2.0.7 | Reset Domoticz MQTT In Topic to ```user_config.h``` value and restart
DomoticzInTopic \<your-topic\> | 2.0.7 | Set Domoticz MQTT In Topic and restart
DomoticzKeyIdx | 2.0.7 | Show current Domoticz key1 index
DomoticzKeyIdx 0 | 2.0.7 | (default) Disable use of key1 index
DomoticzKeyIdx \<idx\> | 2.0.7 | Set Domoticz key1 index. To use it you'll need to enable ButtonTopic too
DomoticzKeyIdx\<index\> | 3.1.1 | Show current Domoticz key1 to key4 index
DomoticzKeyIdx\<index\> 0 | 3.1.1 | (default) Disable use of key1 to key4 index
DomoticzKeyIdx\<index\> \<idx\> | 3.1.1 | Set Domoticz key1 to key4 index. To use it you'll need to enable ButtonTopic too
DomoticzOutTopic | 2.0.7 | Show current Domoticz MQTT Out Topic
DomoticzOutTopic 1 | 2.0.7 | Reset Domoticz MQTT Out Topic to ```user_config.h``` value and restart
DomoticzOutTopic \<your-topic\> | 2.0.7 | Set Domoticz MQTT Out Topic and restart
DomoticzSensorIdx | 3.9.3 | Show current Domoticz sensor1 index
DomoticzSensorIdx 0 | 3.9.3 | (default) Disable use of sensor1 index
DomoticzSensorIdx \<idx\> | 3.9.3 | Set Domoticz sensor1 index.
DomoticzSensorIdx\<index\> | 3.9.3 | Show current Domoticz sensor1 to sensor5 index
DomoticzSensorIdx\<index\> 0 | 3.9.3 | (default) Disable use of sensor1 to sensor5 index
DomoticzSensorIdx\<index\> \<idx\> | 3.9.3 | Set Domoticz sensor1 to sensor5 index.
DomoticzSwitchIdx | 3.9.3 | Show current Domoticz switch1 index
DomoticzSwitchIdx 0 | 3.9.3 | (default) Disable use of switch1 index
DomoticzSwitchIdx \<idx\> | 3.9.3 | Set Domoticz switch1 index. To use it you'll need to enable SwitchTopic too
DomoticzSwitchIdx\<index\> | 3.9.3 | Show current Domoticz switch1 to switch4 index
DomoticzSwitchIdx\<index\> 0 | 3.9.3 | (default) Disable use of switch1 to switch4 index
DomoticzSwitchIdx\<index\> \<idx\> | 3.9.3 | Set Domoticz switch1 to switch4 index. To use it you'll need to enable SwitchTopic too
DomoticzUpdateTimer | 2.0.7 | Show current Domoticz update timer value in seconds
DomoticzUpdateTimer off | 2.0.7 | (default) Disable sending interrim Domoticz status
DomoticzUpdateTimer 0 | 2.0.7 | (default) Disable sending interrim Domoticz status
DomoticzUpdateTimer \<your-secs\> | 2.0.7 | Send status to Domoticz between every 1 and 3600 seconds
### WS2812 Led string
Command | Version | Description
------- | ------- | -----------
Color | 3.2.9 | Show current strip/ring color setting as RRGGBB
Color \<RRGGBB\> | 3.2.9 | Set strip/ring color to RRGGBB hexadecimal value
Dimmer | 3.2.9 | Show current dimmer setting from 0 to 100%
Dimmer 0 - 100 | 3.2.9 | Set dimmer value from 0 to 100%
Fade | 3.2.9 | Show current color fade state
Fade Off | 3.2.9 | (default) Do not use fade while changing colors
Fade On | 3.2.9 | Use fade while changing colors
Fade 0 | 3.2.9 | (default) Do not use fade while changing colors
Fade 1 | 3.2.9 | Use fade while changing colors
Led1 - Led\<pixelcount\> | 3.2.9 | Show specific led current color as RRGGBB
Led1 - Led\<pixelcount\> \<RRGGBB\> | 3.2.9 | Set specific led to desired color RRGGBB
LedTable | 3.2.9 | Show current Led table color correction state
LedTable Off | 3.2.9 | (default) Do not use Led table for color correction
LedTable On | 3.2.9 | Use Led table for color correction
LedTable 0 | 3.2.9 | (default) Do not use Led table for color correction
LedTable 1 | 3.2.9 | Use Led table for color correction
Pixels | 3.2.9 | Show current pixel count
Pixels \<count\> | 3.2.9 | Set amount of pixels in strip or ring up to 256
Scheme | 3.2.9 | Show current selected scheme
Scheme 0 | 3.2.9 | (default) Use single color for all leds in strip/ring
Scheme 1 | 3.2.10 | Start wakeup light
Scheme 2 | 3.2.10 | Show clock
Scheme 3 | 3.2.10 | Show incandescent pattern
Scheme 4 | 3.2.10 | Show rgb pattern
Scheme 5 | 3.2.10 | Show Christmas pattern
Scheme 6 | 3.2.10 | Show Hanukkah pattern
Scheme 7 | 3.2.10 | Show Kwanzaa pattern
Scheme 8 | 3.2.10 | Show rainbow pattern
Scheme 9 | 3.2.10 | Show fire pattern
Speed | 3.2.9 | Show current fade speed selection
Speed 1 - 5 | 3.2.9 | Select desired fade speed from 1 = fast to 5 = slow
Wakeup | 3.2.10 | Show current wake up light duration in seconds
Wakeup 1 - 3600 | 3.2.10 | Set wake up light duration in seconds
Width | 3.2.10 | Show current led group width
Width 0 - 4 | 3.2.10 | Set led group width used by Schemes 3 - 9
### Next Generation
Command | Version | Description
------- | ------- | -----------
Modules | 4.0.0 | Show available modules by name and index
Module | 4.0.0 | Show active module by name and index
Module \<index\> | 4.0.0 | Switch to selected module and restart
Gpios | 4.0.0 | Show available sensors and devices by name and index for user selection
Gpio | 4.0.0 | Show current GPIO usage for current module
Gpio\<pin\> \<sensor\> | 4.0.0 | Select sensor to be connected to \<pin\>
### Optional
Command | Version | Description
------- | ------- | -----------
I2Cscan | 2.0.20 | Scan I2C bus and show device addresses found
SwitchMode | 2.0.18 | Show current external switch mode
SwitchMode 0 | 2.0.18 | (default) Set switch mode to TOGGLE
SwitchMode 1 | 2.0.18 | Set switch mode to FOLLOW (0 = Off, 1 = On)
SwitchMode 2 | 2.0.18 | Set switch mode to inverted FOLLOW (0 = On, 1 = Off)
SwitchMode 3 | 3.0.2 | Set switch mode to PUSHBUTTON (Normally 1, 0 = toggle)
SwitchMode 4 | 3.0.2 | Set switch mode to inverted PUSHBUTTON (Normally 0, 1 = toggle)

84
Compile-and-Upload.md Normal file

@ -0,0 +1,84 @@
In the Arduino IDE for sonoff select from ```Tools Board Generic ESP8266 Module``` and set the following options:
- Flash Mode: DIO
- Flash Frequency: 40MHz
- Upload Using: Serial
- CPU Frequency: 80MHz
- Flash Size: 1M (64K SPIFFS)
- Debug Port: Disabled
- Debug Level: None
- Reset Method: ck
- Upload Speed: 115200
- Port: Your COM port connected to sonoff
Load the file ```sonoff.ino``` into the IDE.
Update ```user_config.h``` with your specific MODULE (SONOFF, SONOFF_2, SONOFF_POW, MOTOR_CAC or ELECTRO_DRAGON) until version 4, Wifi and MQTT parameters.
Verify and/or compile the project and upload once to sonoff using the serial connection as shown in [Peter Scargill's blog](http://tech.scargill.net/itead-slampher-and-sonoff). See below for specific Sonoff Module information.
<img alt="Connection diagram" src="https://github.com/arendst/arendst.github.io/blob/master/media/ProgramESP8266.jpg" height="260" /><br/>
**Do not connect AC power during the flash cable connection**.
### Sonoff RF
<img alt="S20 Smart Socket" src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffrffix.jpg" width="230" align="right" />
The Sonoff RF needs some tweeking as the connection needed during programming between the button and GPIO0 might not be present.
[Phalox](http://phalox.be/wp/electronics/itead-sonoff-slampher-custom-firmware-fix/) explains the case with a picture where you have to install a jumper wire for R21. I received the same result using a small screwdriver and shorting both solder pads of R21 while holding down the button during programming.
Pairing a RF remote is the same as with iTead software:
- two short button presses will blink a red led shortly and start RF signal recognition. Three longer blinks signal RF reception.
- three short button presses will keep the red led on for some seconds and erase the known RF code.
I was unable to pair the Sonoff RF 434MHz receiver with any of my KaKu switches so to me the RF functionality is a bit disappointing.
### Sonoff Dual
<img alt="Dual GPIO0 grounded" src="https://github.com/arendst/arendst.github.io/blob/master/media/dual2a.jpg" width="230" align="right" />
Programming the Sonoff Dual is also more difficult as the button is not connected to GPIO0 which is needed to put the ESP8266 in programming mode during power up.
I suggest to solder a 4 pin header for the serial interface as shown in the image on the right (the vertical connector) and use the small inter layer VIA to ground GPIO0 using the GND pin from the button 0 and button 1 header.
The 4 pin header in the middle, which is normally not present, is not needed but might be used in programming the ESP8266 as there must be a better way for itead to get the initial code loaded ...
### S20 Smart Socket
<img alt="S20 Smart Socket" src="https://github.com/arendst/arendst.github.io/blob/master/media/s20b.jpg" width="230" align="right" />
The picture on the right, provided by ThomDietrich, shows how to program the S20 Smart Socket powered by the FTDI USB converter.
Remember that during programming the Smart Socket is **NOT** connected to mains.
### Sonoff Pow - WARNING
Trying to program the Sonoff Pow [comrade MySKU](http://mysku.ru/blog/china-stores/45762.html) learned the hard way how to brick it.
<img alt="Sonoff Pow Bricked" src="https://github.com/arendst/arendst.github.io/blob/master/media/pow1.jpg" width="230" align="right" />
As the Sonoff Pow power monitoring hardware connects AC power to the logic ground of the ESP8266 it is utterly mandatory to **NOT CONNECT AC POWER WHILE SERIAL CONNECTION IS BEING USED**.
During both AC connection and Serial connection you may connect the life AC wire with your PC's DC ground leading to a power short, broken Sonoff Pow and laptop Power Supply as MySKU has experienced.
### Sonoff Touch
<img alt="Sonoff Touch EU" src="https://github.com/arendst/arendst.github.io/blob/master/media/toucheu.jpg" width="230" align="right" />
As the Sonoff Touch is based on the ESP8285 using Flash Mode DOUT you will have to make some changes to the proposed Arduino IDE settings as follows:
- Tools Board Generic ESP8285 Module
- Flash Size: 1M (64K SPIFFS)
Programming the Sonoff touch is as easy as the Sonoff Basic.
<img alt="Sonoff Touch US" src="https://github.com/arendst/arendst.github.io/blob/master/media/touchus.jpg" width="230" align="right" />
Remove the top PCA containing the ESP8285 from the assembly as shown in the pictures on the right.
The pictures show for both the EU version (top) and the US version (bottom) where to connect your FTDI cable (Gnd, TxD, RxD and 3.3V). The GPIO0 pin needs to be connected to Ground to put the Sonoff Touch in programming mode.
Remember that during programming the Sonoff Touch is **NOT** connected to mains.
### iTead Motor Clockwise/Anticlockwise
<img alt="MotorCAC" src="https://github.com/arendst/arendst.github.io/blob/master/media/motorcac1.jpg" width="230" align="right" />
This USB powered or external powered board provides one GPIO controlling two alternating relays with Normally Open (NO) and Normally Closed (NC) contacts. It can be used for changing directions of a connected motor.
Programming the onboard 3.3V [PSA-B](https://www.itead.cc/psa-01.html) is possible when Rx (pin7), Tx (pin8) and Gnd (pin9) are connected to the FTDI interface, the button is pressed and (USB) power is provided.
### Upload image
Verify and upload an OTA image to your web server with option ```Upload Using: OTA_upload```.
Since version 1.0.26 you may also use sonoffs web server and upload the file directly.
Enable debug messages with command ```seriallog 3```.

@ -0,0 +1,23 @@
### REMOTE BUTTON
I have a cabin that is remote from my house, and I'm using a Sonoff to turn on/off the heaters remotely, so the place can be warm when I get there. The Sonoff(heater control) is located near the fuse box, and it controls a relay which switches the 120V/30A to the heaters.
It's awkward to get at the Sonoff(heater control) to physically press the toggle button, so when I'm using it, I use MQTT commands to control the heaters. But I have some family members that are not comfortable with MQTT usage and certainly don't want to open the fuse box.
So I built a small ESP-01 and a DHT22 and a push button, and used this project code to drive it (>rev 1.0.30). I use the `cmnd/my_DHT/buttontopic` to set the mqtt command to control the heaters. Yes, you can program a sonoff so that the button sends out any arbitrary command. In this case, I'm using the button to control the other sonoff. This ESP+DHT device is in the common area of the cabin, so my family members can simply push the button to toggle the heater.
In other words, I'm using _one_ trivial (DHT+button) wifi device to control the _other_ (sonoff+heater relay). This technique uses Theo's flexible design, since _buttontopic_ can be made different from _topic_.
### Schematic ![schematic of trivial DHT + ESP01](http://alt.pbeirne.com/images/esp_dht2.png)
NOTE: with this schematic, the DHT sensor is on GPIO2. You'll have to change the` #define DHT_PIN ` in this project's source code from 14 to 2. Also, make sure you use the `black` ESP01 with 1MB of flash; most 2016 purchases should be ok. Of course you can use an ESP12 if you wish.
The optional block shown attaches an LED to the DHT data line, so you can watch when the data is being fetched from the DHT device.
Power regulator, 5V to 3.3V: search eBay for `5v/3.3v power 1117`<br>
ESP: search eBay for `esp-01` and pick a black one<br>
DHT22: search eBay for `dht22` ; any AM2302, DHT11 or DHT12 will do in its place; or you can omit the DHT and just use the button<br>
Cost (2016-09-05) USB-5V-adapter: CAD$1 + DC5V->3.3V: CAD$1 + ESP01: CAD$2.62 + DHT12: CAD$1.50 = CAD$6.12 = EUR 4.25
This little device has two _inputs_ (DHT & button), and no _output_. You can use either the Sonoff or the ElectroDragon version of this project, but because this has no output, the following commands don't make any sense: `power, light, ledstate`. You may also want to change the `#define APP_NAME` and `#define PROJECT` to reflect that this isn't a real Sonoff.
Pat B

50
Domoticz.md Normal file

@ -0,0 +1,50 @@
<img alt="Sonoff" src="https://github.com/arendst/arendst.github.io/blob/master/media/domoticz2.jpg" width="250" align="right" />
Sonoff supports Domoticz MQTT 'out of the box'. Find below the procedure to start using it.
## Assumptions
The following servers should be made available:
- You have installed/access to a MQTT server and made contact with your sonoff
- You have installed Domoticz
## Domoticz
Configure MQTT and Virtual Sensor hardware
1. On the hardware page add Type ```MQTT Client Gateway with LAN interface```
1. Give it a name
2. Configure the interface with access to your MQTT server (```Remote Address```, ```Port```, ```Username``` and ```Password```)
3. Set the ```Public Topic``` to flat (which seems to relate to ```out``` in the select field)
2. On the hardware page add Type ```Dummy (used for virtual switches)```
1. Give it a name
3. Make a new virtual switch to be used with Sonoff by clicking ```Create Virtual Sensors```
1. Give it a name
2. Select ```Sensor Type Switch```
4. On the Devices page find the new switch by it's name
1. Remember it's Idx number
## Sonoff
<img alt="Sonoff" src="https://github.com/arendst/arendst.github.io/blob/master/media/domoticz1.jpg" width="250" align="right" />
Sonoff provides several ways of configuring Domoticz parameters.
- Make updates to the Domoticz section of ```user_config.h``` but remember that these changes are only propagated if you also change the CFG_HOLDER define. This is NOT my preferred way of configuring.
1. Set ```DOMOTICZ_IN_TOPIC``` to ```domoticz/in``` as hardcoded in Domoticz
2. Set ```DOMOTICZ_OUT_TOPIC``` to ```domoticz/out``` as hardcoded in Domoticz
3. Configure ```DOMOTICZ_RELAY_IDX1``` to the value read in step 4.1
- Use the webinterface and select ```Configuration - Configure Domoticz```
1. Set ```In topic``` to ```domoticz/in``` as hardcoded in Domoticz
2. Set ```Out topic``` to ```domoticz/out``` as hardcoded in Domoticz
3. Configure ```Idx 1``` to the value read in step 4.1
- Use MQTT and execute commands
1. ```cmnd/sonoff/DomoticzInTopic``` with payload ```domoticz/in``` as hardcoded in Domoticz
2. ```cmnd/sonoff/DomoticzOutTopic``` with payload ```domoticz/out``` as hardcoded in Domoticz
3. ```cmnd/sonoff/DomoticzIdx1``` with payload value read in step 4.1
- Use the serial interface and execute commands
1. ```DomoticzInTopic``` with ```domoticz/in``` as hardcoded in Domoticz
2. ```DomoticzOutTopic``` with ```domoticz/out``` as hardcoded in Domoticz
3. ```DomoticzIdx1``` with the value read in step 4.1
## Domoticz
That's it! You can now switch Sonoff from the Domoticz user interface.
- On the Switches page scroll down and find your Switch as configured in step 3
- Toggle the light bulb; Sonoff should respond

44
Home.md

@ -1 +1,43 @@
Welcome to the Sonoff-Tasmota wiki!
## Sonoff-Tasmota
<img alt="Sonoff" src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffbasic.jpg" width="250" align="right" />
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
## Supported devices
The following devices are supported with Serial, Web and MQTT control:
- [iTead Sonoff Basic](http://sonoff.itead.cc/en/products/sonoff/sonoff-basic)
<img alt="Sonoff" src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff_th.jpg" width="250" align="right" />
- [iTead Sonoff RF](http://sonoff.itead.cc/en/products/sonoff/sonoff-rf)
- [iTead Sonoff SV](https://www.itead.cc/sonoff-sv.html)
- [iTead Sonoff TH10/TH16 with temperature sensor](http://sonoff.itead.cc/en/products/sonoff/sonoff-th)
- [iTead Sonoff Dual](http://sonoff.itead.cc/en/products/sonoff/sonoff-dual)
- [iTead Sonoff Pow](http://sonoff.itead.cc/en/products/sonoff/sonoff-pow)
- [iTead Sonoff 4CH](http://sonoff.itead.cc/en/products/sonoff/sonoff-4ch)
- [iTead S20 Smart Socket](http://sonoff.itead.cc/en/products/residential/s20-socket)
- [iTead Slampher](http://sonoff.itead.cc/en/products/residential/slampher-rf)
- [iTead Sonoff Touch](http://sonoff.itead.cc/en/products/residential/sonoff-touch)
- [iTead Sonoff Led](http://sonoff.itead.cc/en/products/appliances/sonoff-led)
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
## Planned support
- [iTead Sonoff SC](http://sonoff.itead.cc/en/products/residential/sonoff-sc)
## Features
<img alt="Sonoff" src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff4ch.jpg" width="250" align="right" />
The following features are available:
- Multiple devices can be addressed by MQTT ```GroupTopic```
- Firmware upload by OTA or via web page upload
- Expanded Status messages
- UDP syslog messages can be filtered on program name starting with ```ESP-```
- The button can send a different MQTT message defined with ```ButtonTopic```
- Initial Wifi setup by user_config.h, Serial, Smartconfig, Wifi manager or WPS config
- A web server provides control of Sonoff and contains a firmware upload facility
- Support for DHTxx, AM2301 or DS18B20 temperature sensors as used in Sonoff TH10/TH16
- Support for I2C sensors like BH1750, BME280 and HTU21
- Telemetry data can be send using optional different prefix from status messages
- Native Domoticz MQTT support
- Wemo and Hue emulation for Amazon Echo (Alexa) support
## Community
See [Community](https://groups.google.com/d/forum/sonoffusers) for forum and additional user experience

25
MQTT-Features.md Normal file

@ -0,0 +1,25 @@
Sonoff responds to the following MQTT commands using MQTT Topic for ```cmnd/sonoff/<command>``` and MQTT Message/Payload for ```<parameter>```:
- the relay can be controlled with ```cmnd/sonoff/power on```, ```cmnd/sonoff/power off``` or ```cmnd/sonoff/power toggle```. The LED will blink twice and sends a MQTT status message like ```stat/sonoff/POWER ON```. The same function can be initiated with ```cmnd/sonoff/light on```.
- starting with version 3.0.0 the power state message can be sent with the retain flag set. Enable this with ```cmnd/sonoff/PowerRetain on```.
- starting with version 3.0.0 for sonoff dual the relays need to be addressed with ```cmnd/sonoff/power1 toggle``` and ```cmnd/sonoff/power2 toggle```. From version 2.0.0 until version 3.0.0 the relays could be addressed with ```cmnd/sonoff/1/power toggle``` and ```cmnd/sonoff/2/power toggle```.
- the MQTT topic can be changed with ```cmnd/sonoff/topic sonoff1``` which reboots sonoff and makes it available for MQTT commands like ```cmnd/sonoff1/power on```.
- the OTA firmware location can be made known to sonoff with ```cmnd/sonoff/otaurl http://domus1:80/api/sonoff/user1.bin``` where domus1 is your webserver hosting the firmware. Reset to default with ```cmnd/sonoff/otaurl 1```.
- upgrade OTA firmware with ```cmnd/sonoff/upgrade 1```.
- show all status information with ```cmnd/sonoff/status 0```.
- The button can send a MQTT message to the broker that in turn will switch the relay. To configure this you need to perform ```cmnd/sonoff/ButtonTopic sonoff``` where sonoff equals to Topic. The message can also be provided with the retain flag by ```cmnd/sonoff/ButtonRetain on```.
- Sonoff Pow status can be retreived with ```cmnd/sonoff/status 8``` or periodically every 5 minutes using ```cmnd/sonoff/TelePeriod 300```. If units appended to the message are needed execute command ```cmnd/sonoff/MqttUnits on```.
- When a Sonoff Pow threshold like PowerLow has been met a message ```tele/sonoff/POWER_LOW ON``` will be sent. When the error is corrected a message ```tele/sonoff/POWER_LOW OFF``` will be sent.
Most MQTT commands will result in a status feedback like ```stat/sonoff/POWER ON``` and/or {"POWER":"ON"} depending of ```cmnd/sonoff/MessageFormat Legacy|JSON```. The power state will ALWAYS be returned in Legacy mode (for easy triggering by home automation tool) and optionally in JSON.
Telemetry data will be sent by prefix ```tele``` like ```tele/sonoff/TEMPERATURE 24.7```

205
MQTT-for-Newbies.md Normal file

@ -0,0 +1,205 @@
# Notes on MQTT for Newbies
## MQTT Message flow
Here is a diagram showing the connection phase and the 4 network transactions required to turn a sonoff device on.
![mqtt flow](http://alt.pbeirne.com/images/sonoff_cmnd_flow.jpg)
In a typical setup, you'll have multiple Sonoff's (or other devices using this project's code) on the left hand side.
![mqtt flow multiple devices](http://alt.pbeirne.com/images/sonoff_cmnd_flow2.png)
There are lots of ways to control your devices. One typically uses a laptop/desktop to configure and test your Sonoffs and perhaps a smartphone to keep track of what's happening. In the long run you might want to integrate your device in a home-automation system like node-RED, openHAB, HomeAssistant, HomeBridge, Domoticz, ...
|Message|Issued by|Intent
|---|---|---
|`cmnd`|devices shown on the right hand side|control the Sonoff; set configuration; ask for status|
|`stat`|the Sonoffs|report back status or configuration message}
|`tele`|some Sonoffs (like temperature measuring devices)|report unsolicited telemetry info at periodic intervals|
<style type="text/css"> .codehilite {padding: 5px 15px; background: #e0e0e0; } </style>
## Programming examples for the Sonoff-MQTT-OTA-Arduino
### TL;DR
mosquitto_sub -h mqtt_server_name.com -t stat/my_sonoff/POWER -v # listen for status
mosquitto_pub -h mqtt_server_name.com -t cmnd/my_sonoff/power -m 1 # turn on the light
### General
See the wiki's [Command List](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands)
for the definitive list of operations that you can perform. The first word in the column marked
`Command` is the text that
you need to put at the end of a `cmnd` string when you issue a publication message. The 2nd word
is the contents of the payload. If there is no 2nd word, you
can simply send an empty payload. For example, the first line on the Commands page reads
Command|Version|Description
-----|---|------
Power | | Show current power state as On or Off
Power on | | Turn power On
Power off | | Turn power Off
To execute these, issue (publish) these MQTT requests
MQTT topic MQTT payload
cmnd/my_device/power <empty>
cmnd/my_device/power on
cmnd/my_device/power off
The sonoff will respond with these publications:
MQTT topic MQTT payload
stat/my_device/POWER ON
stat/my_device/POWER ON
stat/my_device/POWER OFF
If you have subscribed to these `stat` messages, you can be informed of changes on the device.
#### Connecting to MQTT
You'll need an MQTT server somewhere to communicate with your Sonoff. Some people use publicly available servers, such as iot.eclipse.org. There's a list at http://moxd.io/2015/10/public-mqtt-brokers/
Other people think the MQTT server should reside inside your private LAN. You could use a Raspberry/Orange Pi, or just about any Linux machine as the server/broker; you might even squeeze it into your router if you're using OpenWRT.
#### Creating your own MQTT server/broker
See these sites: [Rufio howto](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands)
[Wingsquare howto](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands)
[Instructables howto on Raspberry Pi](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands)
### Linux/Cygwin command line
You can install the mosquitto client system using either
[Cygwin] setup mosquitto_client
[Ubuntu/Debian] apt install mosquitto_client
[Centos/Fedora] yum install mosquitto_client
#### Controlling (Publishing)
You can control the relay in your Sonoff with mosquitto_pub. Suppose your Sonoff topic is "my_house_living_room" and your mqtt broker is "control_central". To turn on the Sonoff, type this on the command line:
mosquitto_pub -h control_central -t cmnd/my_house_living_room/power -m 1
You can turn the Sonoff back off again with:
mosquitto_pub -h control_central -t cmnd/my_house_living_room/power -m 0
If you want to found out what state your sonoff is, issue this command with an empty payload to trigger a status response (see below for how to listen):
mosquitto_pub -h control_central -t cmnd/my_house_living_room/status -n
#### Listening (Subscribing)
To keep track of your sonoff, just subscribe to messages starting with `stat`, followed by your topic. For example, to pick up status messages from your sonoff, use
mosquitto_sub -h control_central -t stat/my_house_living_room/STATUS -v
The optional `-v` will show you the topic _and_ payload.
These Sonoffs can provide specific information if you wish. To just monitor the relay state, try
mosquitto_sub -h control_central -t stat/my_house_living_room/POWER
You can also use wildcards in your subscription. To pick up _every_ message from this sonoff, you can use
mosquitto_sub -h control_central -t stat/my_house_living_room/+
and then some some other code to just pick out the messages you want. If you have a collection of sonoffs, you can listen to them all by either using the group topic
mosquitto_sub -h control_central -t stat/my_house_collection/POWER
or by using a wildcard in the 2nd position
mosquitto_sub -h control_central -t stat/+/POWER
### Python
Of course you can always call `system()` or `subprocess()` to run the `mosquitto_pub` and `mosquitto_sub` command lines as shown above. But if you wish, you can install the paho-mqtt package and communicate with MQTT using Python objects.
Let's turn the lights on, wait a few seconds, turn them off, check the status and wait for a time stamp
```
import paho.mqtt.client as mqtt, time, sys
last_topic = ""
lasy_payload = ""
# main
def on_connect(client, userdata, flags, rc):
print("Connected")
client.is_connected = True
def on_message(client, userdata, message):
''' note: message is a tuple of (topic, payload, qos, retain)'''
global last_topic, last_payload
last_topic = message.topic
last_payload = message.payload
print("Got a message with topic: [" + last_topic + "] and payload [" + last_payload + "]")
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.is_connected = False
client.loop_start()
client.connect("control_central")
time.sleep(6)
if not client.is_connected:
print("problem connecting to the MQTT server; please check your settings")
sys.exit(1)
client.subscribe("stat/my_house_living_room/POWER")
client.publish("cmnd/my_house_living_room/power","1")
# wait a little bit
time.sleep(15)
client.publish("cmnd/my_house_living_room/power","0")
# ask for system status
time.sleep(1)
client.subscribe("stat/my_house_living_room/STATUS")
client.publish("cmnd/my_house_living_room/status",None)
# now wait for a time stamp from the sonoff; this could take an hour
client.subscribe("tele/my_house_living_room/+")
while 1:
if last_topic.startswith("tele/") and last_topic.endswith("TIME"):
print("the sonoff thinks the time is: "+last_payload)
break
time.sleep(5)
client.loop_stop()
client.disconnect()
```
Ref: [Python MQTT](https://pypi.python.org/pypi/paho-mqtt/1.1)
### JavaScript
...is anyone interested in writing this section?...
### Android phone MQTT Dashboard
The [MQTT Dashboard](https://play.google.com/store/apps/details?id=com.thn.iotmqttdashboard)
provides the ability to connect and control Sonoff devices directly.
On the first page, enter the details of how your phone should connect to the MQTT broker. On the SUBSCRIBE page, you
can create widgets which listen for publications from the Sonoff. A typical subscription for a power controller might be
`stat/my_device/POWER`
You could also pick up _all_ your devices with
`stat/+/POWER`
On the PUBLISH page you can create widgets to toggle or on/off your Sonoff. Typically you'd send a
`cmnd/my_device/power` as the topic, and `on` or `off` as the _publish value_. Note that you can also have separate words
on the app's user interface, such as `illuminated` and `extinguished`; these are _not_ sent out via MQTT, they're just
user interface.
Alternatively, if you're using a home automation system, there may be an Andriod/iOS app to link to your home automation.
That's not covered in this how-to.

@ -0,0 +1,29 @@
<img alt="Exterior" src="https://github.com/arendst/arendst.github.io/blob/master/media/wkaku1a.jpg" width="170" align="left" />
<img alt="Kaku" src="https://github.com/arendst/arendst.github.io/blob/master/media/kaku2a.jpg" width="170" align="right" />
The Dutch Klik Aan Klik Uit PAR-1000 434MHz Power socket might suffer from Capacitor degeneration. In effect the power needed to engage the relay is to low. Replacing the Yellow Capacitor often solves the problem.
<br/>
<br/>
I have several of these lying around and they can be used very well with sonoff functionality. As the sonoff PCA is a bit too large I decided to design my own PCA using kicad.
<br/>
<br/>
<img alt="wKaku prototype" src="https://github.com/arendst/arendst.github.io/blob/master/media/wkaku2a.jpg" width="170" align="left" />
<img alt="wKaku v1.3" src="https://github.com/arendst/arendst.github.io/blob/master/media/wkaku4a.jpg" width="170" align="right" />
During Proof of Concept I used 5V power supplies from itead. After three units were built one crashed caused by debris on the PS PCA resulting in an AC short which in turn blew the large resistor. As the selected Songle relay has the control leads close to the AC leads I also changed the relay.
<br/>
<br/>
I decided to select the HiLink 5V power supply as it was also favourable on other sites. The relay now has the same connections as the one used in sonoff.
<br/>
<br/>
<img alt="wKaku parts" src="https://github.com/arendst/arendst.github.io/blob/master/media/wkaku5a.jpg" width="170" align="left" />
<img alt="wKaku pca" src="https://github.com/arendst/arendst.github.io/blob/master/media/wkaku6b.jpg" width="170" align="right" />
The parts used are:<br/>
= HiLink 5V power supply HLK-PM01 (aliexpress)<br/>
= 5V to 3V3 step down (aliexpress)<br/>
= 5V relay OJE-SH-105DM (ebay)<br/>
= ESP12-F (aliexpress)<br/>
= Capacitors and led from kaku PCA<br/>
= 2 x 1k and 1 x 10k Resistors
The image on the right shows how I mounted the ESP12-F vertically. Notice the 10k resistor from GPIO15 to the board.
The firmware used is sonoff without modification!

18
Prerequisite.md Normal file

@ -0,0 +1,18 @@
Install the ESP8266 Arduino development environment from [esp8266 Arduino](https://github.com/esp8266/Arduino). The software is supported with Arduino IDE versions 1.6.10 until 1.8.1 and esp8266 Arduino stable version 2.3.0.
- I prefer a standalone version of the IDE allowing easy ESP8266 file manipulation. This can be achieved by downloading the Arduino IDE ZIP file for non admin install. After unzipping and before executing ```arduino.exe``` add an empty directory called ```portable```
- Follow the procedure from the ESP8266 Arduino README.md to install the development environment using the Arduino IDE Board Manager
- Copy the ```sonoff``` directory to your sketchfolder
Download and unzip the [pubsubclient](https://github.com/knolleary/pubsubclient) MQTT library into directory ```portable\sketchbook\libraries``` and rename to pubsubclient. Update default value in file ```pubsubclient\src\PubSubClient.h```
- Change ```MQTT_MAX_PACKET_SIZE``` from 128 to at least 400
Optionally install php and a local web server (ie apache) for OTA and copy directory ```api``` in webroot.
### "Over The Air" updates
If you want to be able to upload the OTA file from the IDE to your web server perform the following changes to the Arduino IDE environment:
- Copy file ```espupload.py``` to directory ```portable\packages\esp8266\hardware\esp8266\2.3.0\tools``` and change HOST_ADDR to refer to your web server
- Replace files ```boards.txt``` and ```platform.txt``` in directory ```portable\packages\esp8266\hardware\esp8266\2.3.0```
This will provide an additional option ```Tools - Upload Using: OTA_upload```.

10
Sonoff-Dual.md Normal file

@ -0,0 +1,10 @@
## Solving intermittent relay switch errors
Where most Sonoff's use GPIO to control one or more relays the Sonoff Dual and 4 Channel Inching Relay Assy do use the standard SERIAL interface to control the relays.
Commands are send from the ESP8266 via a 19200 baud serial connection to a dedicated chip that controls the relays.
It is therefore important to disable any serial communication to and from the device once you have debugged any anomalies.
To assist easy installation serial logging is enabled by default in user_config.h for all Sonoffs. Once in production it's wise to turn it off for all Sonoffs. For the Dual it is almost mandatory to turn it off.
Execute command ```seriallog 0``` once to turn all communication on the serial port off.

77
Sonoff-Pow.md Normal file

@ -0,0 +1,77 @@
## Calibration
Sonoff Pow might need calibration as correct measurements are influenced by hardware and timing differences.
I used the following procedure to calibrate.
1. Prerequisites
- Calibrated multimeter ;-)
- Optional calibrated power meter ;-)
- 60W light bulb
2. Enable the calibration commands by updating define ```USE_POWERCALIBRATION``` in ```user_config.h```
3. Recompile and upload to Sonoff Pow
4. Connect the Pow to the optional power meter.
5. Connect the 60W light bulb
6. Open a webbrowser to Pow showing the main page and another webbrowser showing the Console
7. Turn power on and wait a few seconds for the pow to settle on a stable power reading
8. Verify the power reading with the power meter or expected 60W and if needed change the power offset value with command ```HLWPcal```
9. Verify the voltage reading with the multimeter and if needed change the voltage offset value with command ```HLWUcal```
10. Verify the current reading with the calculated value of P (step 8) / U (step 9) and if needed change the current offset with command ```HLWIcal```
11. Optionally disable the calibration commands by recompiling and uploading the firmware
## Result explanation
The Sonoff Pow can provide Energy, Power, Voltage and Current information in different ways.
### Push result using Telemetry
The preffered way is using the periodic telemetry data. Setting ```teleperiod 300``` will send telemetry data every 5 minutes. Depending on messageformat and mqttunits the result would be:
- Result when ```messageformat 0``` (Legacy) and ```mqttunits 0```:
```
tele/pow1/YESTERDAY_ENERGY 0.234
tele/pow1/TODAY_ENERGY 0.016
tele/pow1/PERIOD_ENERGY 5
tele/pow1/CURRENT_POWER 53
tele/pow1/POWER_FACTOR 1.00
tele/pow1/VOLTAGE 214
tele/pow1/CURRENT 0.247
tele/pow1/TIME 2017-01-01T13:50:17
```
- Result when ```messageformat 0``` (Legacy) and ```mqttunits 1```:
```
tele/pow1/YESTERDAY_ENERGY 0.234 kWh
tele/pow1/TODAY_ENERGY 0.016 kWh
tele/pow1/PERIOD_ENERGY 5 Wh
tele/pow1/CURRENT_POWER 53 W
tele/pow1/POWER_FACTOR 1.00
tele/pow1/VOLTAGE 214 V
tele/pow1/CURRENT 0.247 A
tele/pow1/TIME 2017-01-01T13:50:17
```
- Result when ```messageformat 1``` (JSON):
```
tele/pow1/TELEMETRY {"Time":"2017-01-01T13:50:17", "Energy":{"Yesterday":"0.234", "Today":"0.016", "Period":5, "Power":53, "Factor":"1.00", "Voltage":214, "Current":"0.247"}}
```
### Pull result using status message 8
To request information you can use command ```status 8``` which results in one of the following messages:
- Result when ```messageformat 0``` (Legacy):
```
stat/pow1/RESULT PWR: Voltage 214 V, Current 0.247 A, Power 53 W, Today 0.016 kWh, Factor 1.00
```
- Result when ```messageformat 1``` (JSON):
```
stat/pow1/RESULT {"StatusPWR":{"Voltage":214, "Current":"0.247", "Power":53, "Today":"0.016", "Factor":"1.00"}}
```
### Meaning
The presented information has the following meaning:
Legacy | JSON | Unit | Description
------ | ---- | ---- | -----------
YESTERDAY_ENERGY | Yesterday | kWh | Total Energy usage between 00:00 and 24:00 yesterday
TODAY_ENERGY | Today | kWh | Total Energy usage today from 00:00 until now
PERIOD_ENERGY | Period | Wh | Energy usage between previous message and now
CURRENT_POWER | Power | W | Current power load
VOLTAGE | Voltage | V | Current line voltage
CURRENT | Current | A | Current line current
POWER_FACTOR | Factor | | The ratio of the real power flowing to the load to the apparent power in the circuit

8
Sonoff-RF.md Normal file

@ -0,0 +1,8 @@
## Pairing a RF remote control
During programming a connection for R21 is needed in order to use a button press to ground GPIO0.
To pair a RF remote control with the Sonoff RF it is important that there is NO connection made for R21.
User [gadjet](https://github.com/gadjet) installed a jumper in place of R21 allowing easy programming (jumper in), pairing (jumper out) and normal use (jumper out).
<img alt="RF jumper" src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffrfjmpr.jpg" align="left" />

22
Tips.md Normal file

@ -0,0 +1,22 @@
Find below some background and other information.
### Topic, GroupTopic and FallBack Topic
Initially I had one MQTT configurable topic planned called TOPIC but soon found out that when two sonoffs come online with the same topic this would be a challenge at least...
I then introduced a unique, non-configurable topic which I call fallback topic that allows me to always change the MQTT configurable topic to a new unique topic. This fallback topic is just what it is meant to be: A FALLBACK TOPIC in case of emergency.
All MQTT status messages will be sent using the configurable TOPIC which should be made unique by the user. It might be called bedroom but it could also have been called titanic10 as long as the user knows what it is and where to find it.
Having two sonoffs with the same topic allowed for MQTT commands to be sent once to make them act in sono. That inspired me to add a third topic to subscribe to which I call GROUPTOPIC. Sonoffs with the same GROUPTOPIC will react to the same MQTT command. I use it to update firmware to all my sonoffs using separate groups for plain sonoff, pow sonoffs and th sonoffs.
BTW changing TOPIC can be done online using the fallback topic and is only needed once. There is no need to change user_config.h all the time, as many users seem to think they have to do with any new release. All changes are stored in flash and I make a lot of effort to keep these changes available between versions.
### For Flash afficionados
- To stop saving parameter changes to Flash or Spiffs use command ```SaveData off```.
- To stop saving power changes only to Flash or Spiffs use command ```SaveState off```. This will disable the relay from returning to the same state after power on UNLESS you use the MQTT retain flag in which case the MQTT broker will send the last known MQTT state on restart or power on. The command ```ButtonRetain on``` will configure the button to send a MQTT command with Topic and the MQTT retain flag set.
### Debugging
- For debugging purposes you can use the serial interface with command ```SerialLog 4``` and the Arduino IDE set to 115200 baud (19200 for Sonoff Dual) and both NL & CR or the web console with command ```WebLog 4```.
- To aid in finding the IP address of sonoff the network name will be ```<MQTT_TOPIC>-<last 4 decimal chars of MAC address>```. So the default name is ```sonoff-1234```. Another option is MQTT command ```Status 5```.

22
_Sidebar.md Normal file

@ -0,0 +1,22 @@
[**Home**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki)
**Getting Started**
- [**Prerequisite**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Prerequisite)
- [**Compile and Upload**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Compile-and-Upload)
**Usage**
- [**Button**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Button-usage)
- [**MQTT Features**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/MQTT-Features)
- [**Commands**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands)
**Tips**
- [**MQTT for Newbies**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/MQTT-for-Newbies)
- [**General**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Tips)
- [**Sonoff Dual**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Sonoff-Dual)
- [**Sonoff Pow**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Sonoff-Pow)
- [**Sonoff RF**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Sonoff-RF)
- [**Domoticz**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Domoticz)
**User Experience**
- [**Remote Button**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Control-a-Sonoff-using-a-remote-button)
- [**Modified Kaku**](https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Modify-KaKu-to-WKaKu-Power-Socket)