Clarified retain issues and added link to TDM

blakadder 2019-02-18 14:51:20 +01:00
parent 7bd7325c69
commit 1312c72b92
1 changed files with 23 additions and 13 deletions

@ -1,6 +1,6 @@
## Predefined PowerOnState functionality
`PowerOnState | | Show current relay power on state`
`PowerOnState | Show current relay power on state`
`PowerOnState | 0 | off | Keep relay(s) off after power on`
`PowerOnState | 1 | on | Turn relay(s) on after power on`
`PowerOnState | 2 | toggle | Toggle relay(s) on from last saved`
@ -18,29 +18,39 @@ If MQTT is defined and PowerRetain is used the last state will be stored permane
`PowerRetain | 0 | off | (default) Disable MQTT power retain on status update`
`PowerRetain | 1 | on | Enable MQTT power retain on status update`
The stored MQTT message will always **override the PowerOnState!!!**
Stored retain message in your MQTT broker will always ***override the PowerOnState*** and is usually the cause for "ghost switching".
To check, if there is a value set for the power switch you can use mosquitto_sub
### Clearing retained messages
You can use [Tasmota Device Manager](https://github.com/jziolkowski/tdm) (TDM) to clear all retained messages for a device with a single click.
`mosquitto_sub -p 1883 -u <username> -P <password> -t cmnd/+/power`
![Tasmota Device Manager](https://i.postimg.cc/C1kPFMFP/tdmdemo.png)
or do it manually.
To check, if there is a retain value set for the power switch monitor topic `cmnd/+/power` in a MQTT client (recomended [MQTT.fx](https://mqttfx.jensd.de/) for Windows or [Eclipse Mosquitto](https://mosquitto.org/) in linux).
>Using mosquitto:
>
>`mosquitto_sub -p 1883 -u <username> -P <password> -t cmnd/+/power`
If there are retained messages there should be an output similar to: (the "r1" shows that this message was retained)
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/setting/ESP_004554/power', ... (1 bytes))`
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/sonoff/power', ... (1 bytes))`
`on`
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/setting/ESP_267688/power', ... (1 bytes))`
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/sonoff/power', ... (1 bytes))`
`off`
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/setting/ESP_675667/power', ... (1 bytes))`
`Client mosqsub/3795-raspberryp received PUBLISH (d0, q0, r1, m0, 'cmnd/sonoff/power', ... (1 bytes))`
`on`
cmnd/+/power could also something different depending what you have defined as IN folder for commands. "power" needs to be replaced by power1,power2 and so on, if you have more relays or use "cmnd/#". Be aware that MQTT does **NOT SUPPORT **wildcards "cmnd/+/Power?"
`cmnd/+/power` could also show something different depending what you have defined as IN folder for commands. If you have more relays "power" needs to be replaced by power1, power2 and so on respectively, or use "cmnd/#". Be aware that MQTT does **NOT SUPPORT** wildcards such as "cmnd/+/Power?"
`#define SUB_PREFIX "cmnd" `
Now you can see, if there are messages stored that Power ON/OFF and need to be deleted. To delete use:
Now you can see, if there are messages stored that Power ON/OFF and need to be deleted. To delete send empty message to topic `cmnd/%topic%/power`.
`mosquitto_pub -p 1883 -u <username> -P <password> -d -n -r -t cmnd/ESP_0C220C/power`
The -n sends an empty key and the -r sets the retain flag to store this change permanently
>Using mosquitto:
>
>`mosquitto_pub -p 1883 -u <username> -P <password> -d -n -r -t cmnd/sonoff/power`
>
>The -n sends an empty key and the -r sets the retain flag to store this change permanently