mirror of https://github.com/arendst/Tasmota.git
Updated Buttons and Switches (markdown)
parent
aef413419f
commit
eb7e926bc0
|
@ -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).
|
> 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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Button vs. Switch
|
## 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 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).
|
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.
|
Both have a similar function, but Tasmota distinguishes between a "Button" and a "Switch" in other ways.
|
||||||
# Button
|
|
||||||
<img align=right src="https://user-images.githubusercontent.com/5904370/57244172-2273ba80-7038-11e9-89ce-49ef46cb36d6.png" width=100>
|
|
||||||
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).
|
|
||||||
|
|
||||||
By default a button toggles the corresponding relay. Every time the button gets pressed the relay changes `Power` state (ON or OFF).
|
# Button
|
||||||
|
<img align=right src="https://user-images.githubusercontent.com/5904370/57244172-2273ba80-7038-11e9-89ce-49ef46cb36d6.png" width=100>
|
||||||
|
|
||||||
|
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<x>` component while a push-to-break button should use `Button<x>i` (i.e., inverted).
|
A push-to-make button should use a `Button<x>` component while a push-to-break button should use `Button<x>i` (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
|
# Switch
|
||||||
<img align=right src="https://user-images.githubusercontent.com/5904370/57244373-84ccbb00-7038-11e9-85a9-3af6531c9f6d.png" width=100>
|
<img align=right src="https://user-images.githubusercontent.com/5904370/57244373-84ccbb00-7038-11e9-85a9-3af6531c9f6d.png" width=100>
|
||||||
|
|
||||||
In Tasmota a `Switch` is any switch or push-button additionally connected to a free GPIO. Some possibilities include:
|
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
|
- [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
|
- [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)
|
- [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).
|
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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
>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!
|
>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)
|
## [SwitchMode](Commands#switchmode)
|
||||||
> For visual learners: [Tasmota Switchmode Explained](https://www.youtube.com/watch?v=kiXAGkyqFeU) - video by Dr Zzs
|
> 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<x>` 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<x>` component, use `SwitchMode<x>` where `<x>` is the number of your switch from GPIO configuration.
|
To change the behavior of a physical input peripheral configured as a Tasmota `Switch<x>` 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<x>` component, use `SwitchMode<x>` where `<x>` 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<x>` [component](Components) (9-16 & 82-89). SwitchMode has _**NO**_ impact on the behavior of GPIO configured as `Button<x>` [components](Components) (17-20, 90-93, & 112-129). SwitchMode is intended to set the desired behavior of a `Switch<x>` 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<x>` [component](Components) (9-16 & 82-89). SwitchMode has _**NO**_ impact on the behavior of GPIO configured as `Button<x>` [components](Components) (17-20, 90-93, & 112-129). SwitchMode sets the desired behavior of a `Switch<x>` 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_)
|
**`SwitchMode 0`** (_Tasmota default_)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue