Using the "SWITCHMODE" command with the firmware Sonoff-Tasmota

3 minutes of reading
AIMS OF THE GUIDE
  • Learn to use the command "SWITCHMODE”Of the firmware Sonoff-Tasmota in order to drive an intelligent switch Sonoff in different ways of behavior
  • Difficulty level: basso
CONCEPTS FACED:
  • software configuration
SOFTWARE COMPONENTS USED:
PHYSICAL DEVICES USED:
  • a home automation actuator ITEAD Sonoff Smart Home riproprogrammed Sonoff-Tasmota (here a MASTERGUIDE on proreimbursement orderproprogramming)
GUIDE best suited for:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.

ITEAD Sonoff Basic

The adoption of the firmware Sonoff-Tasmota on devices ITEAD Sonoff "Smart Home” enables a whole range of features that, by default, they would not be provided.

First of all, this approccio free these domotic devices from the "cage" indirectly imposed by the proditore in the exclusive use of proman app "EWeLink" to configure and control them; Furthermore, open to unexpected features (think, trivially, of the implementation by the proMQTT tocollo) as well as very wide configuration possibilities, well beyond the factory ones.

The firmware Sonoff-Tasmota provides, in fact, a long list of commands which can be used to customize very punctually the behavior of the profirst device Sonoff, with different specificities from model to model (eg. it will not be possible to use the controls related to temperature and humidity management on models that do not offer these features).

On this occasion we will focus on the command "SWITCHMODE“, Which is typically appit is suitable for all models that offer the function of an intelligent switch, for example the puppy of the family, the Sonoff Basic.

This command allows to customize behavior of the relay (or of the relays) present on the front device of an external control implemented through switch o button (NC or NO): many switch models Sonoff, in fact, they have pins on the board which can be used to check the status of the relay - despite, of course, the presence of the firmware on board Sonoff-Tasmota. For the model Basic we have dedicated a guide apposita to control via external switch / button.

Usually the pins in question ("Ground" and - usually - the "GPIO14"), when put in contact, cause the excitation of the relay, therefore the supply of the output voltage to the device (on). When the short is removed, the excitation ends and the voltage is no longer delivered (off).

Using the command "SWITCHMODE"You can change this behavior. Let's see how.

CommandType of controllerBehavior
SWITCHMODEQuery and return the mode currently in use by the device.
SWITCHMODE 0
SwitchChanging the position of the switch reverses the state of the relay, whatever it is (TOGGLE).

Examples:

  • relay energized (on) and switch open: if I close the switch, the relay de-energises (turns off). If you go againpro, turns on again;
  • relay energized (on) and switch open: if from web interface Tasmota (or in any case via home automation) I switch off, the relay is de-energized (off); if immediately after I close the switch, the relay energizes (turns on).
SWITCHMODE 1SwitchFOLLOW defined behavior.

Examples:

  • relay energized (on) and switch open: if I close the switch, the relay de-energises (turns off). If you go againpro, remains excited (on);
  • relay energized (on) and switch open: if from web interface Tasmota (or in any case via home automation) I switch off, the relay is de-energized (off); if immediately after I close the switch, the relay remains de-energized (off); if further after apro switch, the relay energizes (turns on);
  • relay energized (on) and switch open: if I close the switch, the relay de-energises (turns off). If immediately after from web interface Tasmota (or in any case via domotics) I switch on again and then apro switch, the relay remains energized (on).
SWITCHMODE 2SwitchBehavior defined INVERTED FOLLOW.

Examples:

  • relay energized (on) and switch open: if I close the switch, the relay remains energized (on). If you go againpro, the relay de-energises (turns off)
  • relay energized (on) and switch open: if from web interface Tasmota (or in any case via home automation) I switch off, the relay is de-energized (off); if immediately after I close the switch, the relay energizes (turns on); if further after apro switch, the relay de-energises (turns off);
  • relay energized (on) and switch open: if I close the switch, the relay remains energized (on). If immediately after from web interface Tasmota (or in any case via domotica) I switch off and then apro switch, the relay remains de-energized (off).
SWITCHMODE 3ButtonThe activation of the button reverses the state of the relay, whichever it is. It is used with the "normally open" buttons (TOGGLE).
SWITCHMODE 4ButtonThe activation of the button reverses the state of the relay, whichever it is. It is used with the "normally closed" buttons (INVERTED TOGGLE).
SWITCHMODE 5ButtonThe activation of the button reverses the state of the relay, whatever it is, but unlike the "3" mode, the state change occurs when the button (HOLD) is released, not immediately upon contact.

It is used with the "normally open" buttons (TOGGLE).

SWITCHMODE 6ButtonThe activation of the button reverses the state of the relay, whatever it is, but unlike the "4" mode, the state change occurs when the button (HOLD) is released, not immediately upon contact.

It is used with the "normally open" buttons (INVERTED TOGGLE).

SWITCHMODE 7SwitchActivation of the switch reverses the state of the relay, whichever it is.

Demo


ITEAD Sonoff BasicATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Sonoff (and more generally to devices ESP8266), for any doubt, question, information on the specific merit of these components.


Please comment below