Side effects with using MQTT messages
If MQTT is defined and PowerRetain
is used the last state will be stored permanently in MQTT database.
PowerRetain |
Show current MQTT power retain state.0 / off = disable MQTT power retain on status update (default) 1 / on = enable MQTT power retain on status update |
A message in your MQTT broker flagged as 'retained' will always override the PowerOnState
. This is usually the cause for "ghost switching". Learn more in MQTT retained messages explained. Check out this tutorial for troubleshooting switch ghosting.
Clearing retained messages
To check, if there is a retain flag set for the switch's power topic, monitor cmnd/+/power
in a MQTT client (recommended MQTT.fx for Windows or Eclipse Mosquitto in linux).
You can use Tasmota Device Manager to clear all retained messages for selected device with a single click.
or use the following tutorials/forum threads:
- Clearing retained messages with mosquitto
- Remove retained messages in Home Assistant
- Remove retained messages in hass.io MQTT addon
Predefined PowerOnState functionality
PowerOnState |
Control relay state after powering up the device.0 / OFF = keep relay(s) OFF after power up 1 / ON = turn relay(s) ON after power up 2 / TOGGLE = toggle relay(s) from last saved state 3 = switch relay(s) to their last saved state (default) 4 = turn relay(s) ON and disable further relay control 5 = after a PulseTime period turn relay(s) ON (acts as inverted PulseTime mode) |
The PowerOnState
device configuration parameter is applied when the device is initially powered up. It does not apply to device warm restarts.
Tasmota tracks the relays' state in a masked variable. A set bit (1
) means the corresponding relay is turned ON. The associated GPIO state will be high or low according to whether the relay is configured as Relay<x>
or Relay<x>i
. Every command for setting the relay state is "recorded" in the variable and saved to flash (depending on SetOption0
). The setting of the relay GPIO is then executed.
After a warm restart, the mask variable is re-initialised with the saved state from flash and the relay(s) set to that state. PowerOnState
is not executed. During any a device restart, the relay power feedback state is scanned according to the setting of SetOption63
. Scanning the relay state attempts to READ from GPIOs that are configured as relays, i.e., OUTPUTS! The result will not always be what is expected as it depends on how the device relays are wired to the GPIO. SetOption63
was introduced to make this scan optional. With SetOption63
set to 0
(the default), each GPIO assigned as a Relay<x>
or Relay<x>i
is scanned using 'digitalRead'. The mask variable will be updated with the detected values. The state of the relay(s) will not be changed. READING from an OUTPUT GPIO may result in the mask value being different from the state the relays are in. Thus, SetOption63
was introduced to disable the startup scan for devices where the scan leads to undefined results.
SetOption63
is executed after PowerOnState
or restart initialization.
Wiki has moved to link on the left.