Problem with sonoff Tasmota 4ch pro r2 and Mosquitto

i’ve configured the Sonoff ( Tasmota firmware) 4ch pro r2 to act into pulse mode changing the "PulseTime1 10 "
(for all the 4 relay)in the consolle of the sonoff, and it’s works ok, the problem come in when i connect it to the mosquitto broker of HA, every time it’s connect at the broker ( by a soft reboot of the sonoff or a reboot of the HA) all the 4 switches turn on for 1 second ,
this in my config:

- platform: mqtt  
name: "Allarme Totale"
state_topic: "stat/Allarme_sonoff/POWER1"
command_topic: "cmnd/Allarme_sonoff/POWER1"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: true

By setting retain: true you have told the broker to save the message in its database and transmit it when a client (your sonoff) subscribes to the broker. This causes the sonoff to receive the message and to toggle the light.

I don’t think you need the retain behaviour, so you need to set retain: false and then remove the message from the broker’s database.

To remove the message from the broker’s database, you need to send a message to that topic with the retain flag set and a null payload.

With mosquitto_pub

mosquitto_pub -t cmnd/Allarme_sonoff/POWER1 -r -n

Or by using the mqtt.publish service with these parameters

Hi, if i connect to raspberry pi via ssh, if i give the command
mosquitto_pub -t cmnd/Allarme_sonoff/POWER1 -r -n
it says : address not available

I suggest you use the other method I suggested. The servces page is available from the developer tools section of the HA interface.

ok your suggestion did the trick! thank you very much :slight_smile:

1 Like