Updated Buttons and Switches (markdown)

Michael Ingraham 2019-09-05 10:16:33 -04:00
parent 2abe3ac13f
commit 9d848586fe
1 changed files with 18 additions and 23 deletions

@ -51,66 +51,61 @@ Apart from the default toggling of the relay, switches can be configured to do l
To change the mode of a switch or button use the [`SwitchMode`](Commands#switchmode) command. If there is more than one, use `SwitchMode<x>` where `<x>` is the number of your switch or button from GPIO configuration. To change the mode of a switch or button use the [`SwitchMode`](Commands#switchmode) command. If there is more than one, use `SwitchMode<x>` where `<x>` is the number of your switch or button from GPIO configuration.
**`SwitchMode 0`** **`SwitchMode 0`** (_Tasmota default_)
```Default Tasmota switch mode (toggle)``` ```Set switch to toggle mode```
Sends toggle command on switching the switch (closing or opening the circuit). Tasmota sends `TOGGLE` command each time the state of the circuit changes (closing or opening).
**`SwitchMode 1`** **`SwitchMode 1`**
```Set switch to follow mode (0 = OFF, 1 = ON)``` ```Set switch to follow mode (0 = OFF, 1 = ON)```
While pressing the switch (closing the circuit) the button will send `ON` and when released (open circuit) send `OFF` . At the time when the circuit is closed, Tasmota will send `ON` and opening the circuit sends `OFF`.
> You want to use `SwitchMode 1` when connecting a [toggle switch](https://en.wikipedia.org/wiki/Switch#Toggle_switch) to your device (e.g. a classic light switch). This way the "software switch" will mirror the state of the "hardware switch". > You want to use `SwitchMode 1` when connecting a [toggle switch](https://en.wikipedia.org/wiki/Switch#Toggle_switch) (e.g. a classic light switch) to your device. This way the "software switch" will mirror the state of the "hardware switch". If the real switch is in the "ON" position, the state in Tasmota is `ON` as well.
If the real switch is in the "ON" position, the state in Tasmota is `ON` as well.
**`SwitchMode 2`** **`SwitchMode 2`**
```Set switch to inverted follow mode (0 = ON, 1 = OFF)``` ```Set switch to inverted follow mode (0 = ON, 1 = OFF)```
While pressing the switch (closing the circuit) the button will send `OFF` and when released (open circuit) send `ON` . At the time when the circuit is closed, Tasmota will send `OFF` and opening the circuit sends `ON`.
**`SwitchMode 3`** **`SwitchMode 3`**
```Set switch to push-button mode (Default 1 = ON, 0 = toggle)``` ```Set push-button mode (0 = TOGGLE, 1 = ON (_default_))```
The switch will send a toggle command when the switch is released (opening the circuit). When pressing the switch (closing the circuit) nothing will happen. Default switch state is ON and when pressed its OFF. (This trigger is known as [falling-edge](https://en.wikipedia.org/wiki/Signal_edge)) Tasmota will send a `TOGGLE` command when the button is released (opening the circuit). When pressing the button (closing the circuit) nothing will happen. Default state is ON and when pressed it's OFF. (This trigger is known as [falling-edge](https://en.wikipedia.org/wiki/Signal_edge))
**`SwitchMode 4`** **`SwitchMode 4`**
```Set switch to inverted push-button mode (Default 0 = OFF, 1 = toggle)``` ```Set inverted push-button mode (0 = OFF (_default_), 1 = TOGGLE)```
The switch will send a toggle command when pressing switch (closing the circuit). When the switch is released (opening the circuit) nothing will happen. Default switch state is OFF and when pressed its ON. (This trigger is known as [rising-edge](https://en.wikipedia.org/wiki/Signal_edge)) Tasmota will send a `TOGGLE` command when the button is pressed (closing the circuit). When the button is released (opening the circuit) nothing will happen. Default state is OFF and when pressed it's ON. (This trigger is known as [rising-edge](https://en.wikipedia.org/wiki/Signal_edge))
>When connecting a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (a push-button) you will want to use `SwitchMode 3` or `SwitchMode 4`. >When connecting a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (i.e., a push-button) you will want to use `SwitchMode 3` or `SwitchMode 4`.
**`SwitchMode 5`** **`SwitchMode 5`**
```Set switch to push-button with long press mode (Default 1 = ON, 0 = toggle, long press = HOLD )``` ```Set push-button with long press mode (0 = TOGGLE, 1 = ON (_default_), long press = HOLD)```
The switch will send a toggle command when the switch is released (opening the circuit). When pressing the switch (closing the circuit) nothing will happen. Default switch state is ON and when pressed its OFF. Tasmota will send a `TOGGLE` command when the button is released (opening the circuit). When pressing the button (closing the circuit) nothing will happen. Default state is ON and when pressed it's OFF. When held for the time set in `SetOption32` (_default = 4s_), Tasmota sends `HOLD` (use Switch<x>#state=3 in rules).
When held for time set in `SetOption32` (default = 4s) sends HOLD message (Use Switch<x>#state=3 in rules).
**`SwitchMode 6`** **`SwitchMode 6`**
```Set switch to inverted push-button with long press mode (Default 0 = OFF, 1 = toggle, long press = HOLD )``` ```Set inverted push-button with long press mode (Default 0 = OFF, 1 = toggle, long press = HOLD)```
The switch will send a toggle command when pressed (closing the circuit). When the switch is released (opening the circuit) nothing will happen. Default switch state is OFF and when pressed its ON. Tasmota will send a `TOGGLE` command when the button pressed (closing the circuit). When the button is released (opening the circuit) nothing will happen. Default state is OFF and when pressed it's ON. When held for the time set in `SetOption32` (_default = 4s_), Tasmota sends `HOLD` (use Switch<x>#state=3 in rules).
When held for time set in `SetOption32` (default = 4s) sends HOLD message (Use Switch<x>#state=3 in rules).
>Long press or hold can be used in [conjunction with rules](Rule-cookbook#1-use-long-press-action-on-a-switch) to create additional features or to control another Tasmota device. >Long press or hold can be used in [conjunction with rules](Rule-cookbook#1-use-long-press-action-on-a-switch) to create additional features or to control another Tasmota device.
**`SwitchMode 7`** **`SwitchMode 7`**
```Set switch to toggle PUSHBUTTON (0 = toggle, 1 = toggle)``` ```Set toggle push-button mode```
The switch will send a toggle command when pressed and another toggle command when released. Tasmota will send a `TOGGLE` command when pressed and another `TOGGLE` command when released.
>Not sure why you would use this one, but hey, its here when you need it. >For example, when the button is pressed, toggle the relay to ring the doorbell; when the button is released, ring the doorbell again.
## [SwitchTopic](Commands#switchtopic) ## [SwitchTopic](Commands#switchtopic)
SwitchTopic and ButtonTopic are almost identical in use. You can use this guide interchangeably for both or read [ButtonTopic](Button-usage#ButtonTopic). SwitchTopic and ButtonTopic are almost identical in use. You can use this guide interchangeably for both or read [ButtonTopic](Button-usage#ButtonTopic).