mirror of https://github.com/arendst/Tasmota.git
Correction for SwitchTopic options
parent
7830a5b23b
commit
0d29a971d6
|
@ -20,20 +20,14 @@ Video tutorial: [Tasmota SwitchMode Explained](https://www.youtube.com/watch?v=k
|
|||
|
||||
By default the configuration for a "switch" is like this:
|
||||
|
||||
```
|
||||
SwitchMode=0 (Set switch mode to TOGGLE)
|
||||
SwitchTopic=0 (Disable use of MQTT switch topic)
|
||||
```
|
||||
`SwitchMode 0` (Set switch mode to TOGGLE) - every time the button gets pressed the relay changes its state (on/off).
|
||||
|
||||
`SwitchMode=0` means every time the button gets pressed the relay changes its state (on/off).
|
||||
`SwitchTopic<x> 0` (Disable use of MQTT switch topic) Does not publish an MQTT message to the switch topictopic. Instead the relay will be controlled directly. Once the relay changes its state the firmware will publish an MQTT message with the new state.
|
||||
|
||||
`SwitchTopic=0` means the button press will not send a topic via MQTT.
|
||||
Instead the relay will be controlled directly. Once the relay changes its state the firmware will send an MQTT message with the new state.
|
||||
e.g.: `stat/sonoff01/POWER ON`
|
||||
|
||||
**Important**:
|
||||
The Sonoff-Tasmota firmware does not publish the state of the switch in any way!
|
||||
It only send commands (directly to the corresponding relay or via MQTT to a topic).
|
||||
The Sonoff-Tasmota firmware does not publish the state of the switch in any way! It only send commands (directly to the corresponding relay or via MQTT to a topic).
|
||||
|
||||
|
||||
## [SwitchMode](Commands#switchmode)
|
||||
|
@ -44,71 +38,77 @@ You can change the mode for a switch by executing a [command](Commands#switchmod
|
|||
|
||||
**`SwitchMode 1`**
|
||||
|
||||
> Set switch mode to FOLLOW (0 = Off, 1 = On)
|
||||
Set switch mode to FOLLOW (0 = Off, 1 = On)
|
||||
|
||||
While pressing the button/switch (closing the circuit) the button will send `ON` (directly or via MQTT depending on [SwitchTopic](Commands#switchmode)) and `OFF` when released (open circuit).
|
||||
|
||||
|
||||
**`SwitchMode 2`**
|
||||
|
||||
> Set switch mode to inverted FOLLOW (0 = On, 1 = Off)
|
||||
Set switch mode to inverted FOLLOW (0 = On, 1 = Off)
|
||||
|
||||
The opposite of Mode 1.
|
||||
|
||||
#### Conclusion
|
||||
|
||||
You properly want to use `SwitchMode=1` when connecting a [toggle switch](https://en.wikipedia.org/wiki/Switch#Toggle_switch) to your Sonoff device. This way the 'software switch' will have the same state as the 'hardware switch'.
|
||||
You probably want to use `SwitchMode 1` when connecting a [toggle switch](https://en.wikipedia.org/wiki/Switch#Toggle_switch) to your Sonoff device. This way the 'software switch' will have the same state as the 'hardware switch'.
|
||||
If the real switch is in the "on" position, the state of the software switch is `ON` as well.
|
||||
|
||||
### SwitchMode 3 and 4
|
||||
|
||||
**`SwitchMode 3`**
|
||||
|
||||
> Set switch mode to PUSHBUTTON (Normally 1, 0 = toggle)
|
||||
Set switch mode to PUSHBUTTON (Normally 1, 0 = toggle)
|
||||
|
||||
The switch will send a command (directly or via MQTT) when the switch opens the circuit (`OFF`). When closing the circuit (`ON`), nothing will happen.
|
||||
|
||||
**`SwitchMode 4`**
|
||||
|
||||
> Set switch mode to inverted PUSHBUTTON (Normally 0, 1 = toggle)
|
||||
Set switch mode to inverted PUSHBUTTON (Normally 0, 1 = toggle)
|
||||
|
||||
The switch will send a command when changing to `ON`. Nothing happens when changing to `OFF`.
|
||||
|
||||
|
||||
#### Conclusion
|
||||
|
||||
When connecting a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (a push button) you want to use `SwitchMode=3` or `SwitchMode=4`.
|
||||
`SwitchMode=4` is the same as the default behavior (`SwitchMode=0`) for Sonoff devices.
|
||||
When connecting a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (a push button) you want to use `SwitchMode 3` or `SwitchMode 4`.
|
||||
`SwitchMode 4` is the same as the default behavior (`SwitchMode 0`) for Sonoff devices.
|
||||
|
||||
## [SwitchTopic](Commands#switchtopic)
|
||||
|
||||
**`SwitchTopic 0`**
|
||||
**`SwitchTopic<x> 0`**
|
||||
|
||||
> Disable use of MQTT switch topic
|
||||
Disable use of MQTT switch topic
|
||||
|
||||
No MQTT message will be published on account of the new switch state. The message you see in MQTT is the new state of the relay that gets changed, like explained above.
|
||||
|
||||
e.g.: `stat/sonoff01/POWER ON`
|
||||
|
||||
**`SwitchTopic 1`**
|
||||
**`SwitchTopic<x> 1`**
|
||||
|
||||
> Set MQTT switch topic to Topic
|
||||
Set MQTT switch topic to device MQTT Topic
|
||||
|
||||
When changing the state of the switch (depending on the `SwitchMode`) an MQTT command gets send via MQTT. This command will have the topic defined as the default topic of the Sonoff device.
|
||||
|
||||
When changing the state of the switch (depending on the `SwitchMode`) an MQTT command gets send via MQTT.
|
||||
This command will have the topic defined as the default topic of the Sonoff device.
|
||||
e.g.: `cmnd/sonoff01/POWER ON` (Notice the `cmnd` instead of the `stat` at the beginning.)
|
||||
This command will be received by the device itself and the relay will be set to the defined state.
|
||||
Just like receiving the same command from any other MQTT source.
|
||||
|
||||
**`SwitchTopic 2`**
|
||||
This command will be received by the device itself and the relay will be set to the defined state. Just like receiving the same command from any other MQTT source.
|
||||
|
||||
> Set MQTT switch topic (32 chars max)
|
||||
**`SwitchTopic<x> 2`**
|
||||
|
||||
Set MQTT switch topic to firmware default `MQTT_SWITCH_TOPIC`. Typically `MQTT_SWITCH_TOPIC` is set to `0` unless you compile your own firmware and change this value in `user_config_override.h`. If `MQTT_SWITCH_TOPIC` is set to a string, then this command will have the same behavior as outlined below.
|
||||
|
||||
**`SwitchTopic<x> <value>`**
|
||||
|
||||
Set MQTT switch topic (32 chars max)
|
||||
|
||||
This will send a MQTT message with a user-defined topic.
|
||||
|
||||
Whether this message will trigger anything depends on the setup of the user.
|
||||
|
||||
For example, when setting the topic to `sonoff2` this could trigger the relay on the Sonoff device that listens to messages with this specific topic.
|
||||
|
||||
### Use case
|
||||
To trigger something within your smart home automation hub you can define the `SwitchTopic` to `sonoff01-switch1` (for example).
|
||||
To trigger something within your smart home automation hub you can define the `SwitchTopic<x>` to `sonoff01-switch1` (for example).
|
||||
|
||||
This will send a message like this: `cmnd/sonoff01-switch1/POWER ON`
|
||||
|
||||
|
@ -120,15 +120,17 @@ Switch Sonoff01_Switch1 "Sonoff01 Switch1 [%s]" <switch> { mqtt="<[mosquitto:cmn
|
|||
|
||||
### Conclusion
|
||||
|
||||
`SwitchTopic=0` controls the relay directly.
|
||||
`SwitchTopic=1` sends a message with the default topic to MQTT. This message will get picked up by the device itself and sets the state of the relay accordingly.
|
||||
While `SwitchTopic=2` sends a command with a custom topic via MQTT. This will not get picked up unless you configure any device to subscribe to this topic.
|
||||
`SwitchTopic<x> 0` controls the relay directly.
|
||||
|
||||
`SwitchTopic<x> 1` sends a message with the default device topic to MQTT. This message will get picked up by the device itself and sets the state of the relay accordingly.
|
||||
|
||||
`SwitchTopic<x> <value>` sends a command with a custom topic of `<value>` via MQTT. This will not get picked up unless you configure any device to subscribe to this topic.
|
||||
|
||||
[Examples with Rules](Rules#16-using-an-external-button-with-single-press---double-press-and-hold)
|
||||
|
||||
### ⚠️ MQTT broker not available ⚠️
|
||||
|
||||
When using `SwitchTopic=2` and the MQTT broker is not available, Tasmota falls back using `SwitchTopic=0`.
|
||||
When using `SwitchTopic<x> <value>` and the MQTT broker is not available, Tasmota falls back using `SwitchTopic<x> 0`.
|
||||
To prevent this, a rule like the following can be set:
|
||||
|
||||
```
|
||||
|
@ -136,5 +138,3 @@ rule1
|
|||
rule1 on switch1#state=1 do publish YOUR-CUSTOM-SWITCH-TOPIC ON endon
|
||||
rule1 on
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue