removed old mosquitto guide due to it being obfuscated and added a few links to better tutorials and relevant forum threads. updated tdm screenshot

blakadder 2019-03-15 23:41:55 +01:00
parent 5027a7ebc6
commit 1306886ef4
1 changed files with 7 additions and 32 deletions

@ -14,41 +14,16 @@ If MQTT is defined and [`PowerRetain`](Commands#powerretain) is used the last st
|-|-|
[`PowerRetain`](Commands#powerretain) | Show current MQTT power retain state.<BR> `0` / `off` = disable MQTT power retain on status update *(default)* <BR> `1` / `on` = enable MQTT power retain on status update
Stored retain message in your MQTT broker will always ***override the `PowerOnState`*** and is usually the cause for "ghost switching".
Stored retain message in your MQTT broker will always ***override the `PowerOnState`*** and is usually the cause for "ghost switching". Learn more in [MQTT retained messages explained](http://www.steves-internet-guide.com/mqtt-retained-messages-example/).
### 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.
![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 (recommended [MQTT.fx](https://mqttfx.jensd.de/) for Windows or [Eclipse Mosquitto](https://mosquitto.org/) in linux).
Using mosquitto:
You can use [Tasmota Device Manager](https://github.com/jziolkowski/tdm) to clear all retained messages for selected device with a single click.
`mosquitto_sub -p 1883 -v -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/sonoff/power', ... (1 bytes))
on
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/sonoff/power', ... (1 bytes))
on
```
`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 send empty message to topic `cmnd/%topic%/power`.
Using mosquitto:
`mosquitto_pub -p 1883 -u <username> -P <password> -d -n -r -t cmnd/%topic%/power`
The -n sends an empty key and the -r sets the retain flag to store this change permanently
![Tasmota Device Manager](https://user-images.githubusercontent.com/5904370/54465515-cd27d500-477b-11e9-92b8-bfda02325686.png)
or use the following tutorials/forum threads:
* [Clearing retained messages with mosquitto](https://community.openhab.org/t/clearing-mqtt-retained-messages/58221)
* [Remove retained messages in Home Assistant](https://community.home-assistant.io/t/mqtt-how-to-remove-retained-messages/79029)
* [Remove retained messages in hass.io MQTT addon](https://community.home-assistant.io/t/clear-hass-io-mosquitto-broker-add-on-retain-messages/57250/3)