From eb7e926bc02b11174de0fb10489da028c8355ee4 Mon Sep 17 00:00:00 2001
From: Michael Ingraham <34340210+meingraham@users.noreply.github.com>
Date: Thu, 5 Sep 2019 22:25:51 -0400
Subject: [PATCH] Updated Buttons and Switches (markdown)
---
Buttons-and-Switches.md | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/Buttons-and-Switches.md b/Buttons-and-Switches.md
index 38255c8a..f7d6f8f5 100644
--- a/Buttons-and-Switches.md
+++ b/Buttons-and-Switches.md
@@ -1,32 +1,26 @@
-Buttons and switches are primarily used to toggle (turn ON or OFF) device relays.
+Buttons and switches are primarily used to toggle (turn ON or OFF) device relays. A typical device usually has at least one button (exception being bulbs and some lights) to control the relay(s). Additional buttons and switches can be [wired](Expanding-Sonoffs#connect-switch) to a free GPIO and configured in Module or Template settings.
-A standard device usually has at least one button (exception being bulbs and some lights) to control the relay(s).
-
-Additional buttons and switches can be [wired](Expanding-Sonoffs#connect-switch) to a free GPIO and configured in Module or Template settings.
-
-> Tasmota does not automatically publish the state of the switch. It only sends commands directly to the corresponding relay or to an MQTT topic.
+> Other than relays, Tasmota does not publish the state of components (switches, buttons, sensors, etc.) in real-time. Only messages corresponding to relays are transmitted in real-time. The state of components is transmitted automatically each [TelePeriod](Commands#teleperiod) via the `SENSORS` message.
## Button vs. Switch
A button (also called a push-button) is a momentary or non-latching switch which causes a temporary change in the state of an electrical circuit only while the switch is pressed. An automatic mechanism (i.e. a spring) returns the switch to its default position immediately afterwards, restoring the initial circuit condition.
-A switch (more precisely a latching switch), when activated by the user, remains in that state until activated again.
+A switch (more precisely a latching or toggle switch), when activated by the user, remains in that state until activated again.
+
Learn more about buttons and switches in [this video](https://www.youtube.com/watch?v=jNvCQVrEpDQ).
-Both have a similar function but Tasmota distinguishes between a "Button" and a "Switch" in other ways.
-# Button
-
-Tasmota `Button` is normally the button supplied on the device. In most cases it is a momentary push-button (capacitive touch button in wall switches).
+Both have a similar function, but Tasmota distinguishes between a "Button" and a "Switch" in other ways.
-By default a button toggles the corresponding relay. Every time the button gets pressed the relay changes `Power` state (ON or OFF).
+# Button
+
+
+For Tasmota, a `Button` is typically a momentary push-button (or a capacitive touch button in some light switches). By default a button toggles the corresponding relay. Every time the button gets pressed the relay changes its `Power` state (ON or OFF). Besides toggling the `Power` state, a button is also used to activate [multi press button functions](Button-usage#multi-press-functions), to do long press (HOLD) actions, or send messages to different MQTT topics. See [Button-usage](Button-usage) for a detailed multi-press function list, `ButtonTopic` options, and changing default Button functionality.
A push-to-make button should use a `Button` component while a push-to-break button should use `Buttoni` (i.e., inverted).
-Besides toggling the `Power` state, a button is also used to activate [multi press button functions](Button-usage#multi-press-functions).
-
-See [Button-usage](Button-usage) on a detailed multi press function list, ButtonTopic options and changing default Button functionality.
-
# Switch
+
In Tasmota a `Switch` is any switch or push-button additionally connected to a free GPIO. Some possibilities include:
- [mechanical toggle switch](https://en.wikipedia.org/wiki/Switch#Toggle_switch) - also called a rocker switch
@@ -35,18 +29,16 @@ In Tasmota a `Switch` is any switch or push-button additionally connected to a f
- [PIR](https://en.wikipedia.org/wiki/Passive_infrared_sensor) - even though it's technically a sensor it is configured as a switch in Tasmota
- [mechanical push-button](https://en.wikipedia.org/wiki/Push-button)
-By default a switch toggles the corresponding relay. Every time the switch gets pressed the relay changes its state (ON or OFF).
-
-Apart from the default toggling of the relay, switches can be configured to do long press (HOLD) actions, send messages to different MQTT topics or commands to other Tasmota devices.
+By default a switch toggles the corresponding relay. Every time the switch gets flipped, the relay changes its state (ON or OFF). Apart from the default toggling of the relay, switches can be configured to send messages to different MQTT topics, or send commands to other Tasmota devices.
>Now, to make everything a little confusing: A push-button can be configured as a `Switch` and a toggle switch can be configured as a `Button`. Configuring a toggle switch as a `Button` is not recommended!
## [SwitchMode](Commands#switchmode)
> For visual learners: [Tasmota Switchmode Explained](https://www.youtube.com/watch?v=kiXAGkyqFeU) - video by Dr Zzs
-To change the behavior of an input peripheral configured as a Tasmota `Switch` component, whether a toggle switch or a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (i.e., a push-button), use the `SwitchMode` command. If there is more than one `Switch` component, use `SwitchMode` where `` is the number of your switch from GPIO configuration.
+To change the behavior of a physical input peripheral configured as a Tasmota `Switch` component, whether a toggle switch or a [momentary switch](https://en.wikipedia.org/wiki/Switch#Biased_switches) (i.e., a push-button), use the `SwitchMode` command. If there is more than one `Switch` component, use `SwitchMode` where `` is the number of your switch from the Tasmota GPIO configuration.
-SwitchMode, as the name implies, applies _**ONLY**_ to GPIO configured in Tasmota as a `Switch` [component](Components) (9-16 & 82-89). SwitchMode has _**NO**_ impact on the behavior of GPIO configured as `Button` [components](Components) (17-20, 90-93, & 112-129). SwitchMode is intended to set the desired behavior of a `Switch` component based on whether a switch or a push-button (i.e., a momentary switch) is physically connected to the GPIO.
+SwitchMode, as the name implies, applies _**ONLY**_ to GPIO configured in Tasmota as a `Switch` [component](Components) (9-16 & 82-89). SwitchMode has _**NO**_ impact on the behavior of GPIO configured as `Button` [components](Components) (17-20, 90-93, & 112-129). SwitchMode sets the desired behavior of a `Switch` component based on whether it's a switch or a push-button (i.e., a momentary switch) that is physically connected to the GPIO.
**`SwitchMode 0`** (_Tasmota default_)