HELP , sonoffdual(tasmota) mqtt, forced on on sonoff power reboot

Hi, i’ve configured a blind on homeassistant.
the project works, but when the sonoff is restarted, the relays automatically switch to power on.
if I turn off the raspberry pi, the sonoff normally works, so it’s a communication problem at the start of the mqtt communication.
I tried to play with the retain parameters, and to disable all automations and scripts, but nothing, always starts ON

I paste the configuration:
SONOFF

sonoff log:

00:00:06 DNS: Initialized
00:00:06 HTP: Web server active on tapparellacucina-6467.local with IP address 192.168.1.100
09:46:04 MQT: stat/tapparellacucina/POWER2 = ON
09:46:04 RSL: Received Topic cmnd/tapparellacucina/POWER1, Data Size 2, Data ON
09:46:04 RSL: Group 0, Index 1, Command POWER, Data ON
09:46:04 MQT: stat/tapparellacucina/RESULT = {“POWER1”:“ON”}
09:46:04 MQT: stat/tapparellacucina/POWER1 = ON
09:46:04 RSL: Received Topic cmnd/tapparellacucina/POWER2, Data Size 2, Data ON
09:46:04 RSL: Group 0, Index 2, Command POWER, Data ON
09:46:04 MQT: stat/tapparellacucina/RESULT = {“POWER2”:“ON”}
09:46:04 MQT: stat/tapparellacucina/POWER2 = ON
09:46:04 CFG: Saved to flash at F4, Count 737, Bytes 1648
09:46:05 MQT: stat/tapparellacucina/RESULT = {“POWER1”:“ON”}
09:46:05 MQT: stat/tapparellacucina/POWER1 = ON
09:46:05 MQT: stat/tapparellacucina/RESULT = {“POWER2”:“ON”}
09:46:05 MQT: stat/tapparellacucina/POWER2 = ON
09:46:12 MQT: tele/tapparellacucina/STATE = {“Time”:“2018-04-14T09:46:12”, “Uptime”:0, “Vcc”:3.213, “POWER1”:“ON”, “POWER2”:“ON”, “Wifi”:{“AP”:1, “SSId”:“Davide WiFi”, “RSSI”:100, “APMac”:“34:21:09:01:9E:7W”}}
09:46:22 WIF: Checking connection…
09:46:22 WIF: Connected

CONFIGURATION YAML

mqtt:
broker: 192.168.1.119
port: 1883
username: username
password: ********
protocol: 3.1
switch:
###SONOFF SOGGIORNO####

  • platform: mqtt
    name: “Tapparella Soggiorno Apertura”
    state_topic: “stat/tapparellacucina/POWER1”
    command_topic: “cmnd/tapparellacucina/POWER1”
    qos: 0
    payload_on: “ON”
    payload_off: “OFF”
    retain: true
    optimistic: false
  • platform: mqtt
    name: “Tapparella Soggiorno Chiusura”
    state_topic: “stat/tapparellacucina/POWER2”
    command_topic: “cmnd/tapparellacucina/POWER2”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true
    optimistic: false

thank you in advance who will help me

By setting the retain flag, you are telling the broker to send the last message received for that topic to any client that subsequently subscribes to the topic. So when the tasmota turns on, it connects and subscribes to the topic, and the broker sends the POWER1 message. The data will depend on which message HA sent last.

Obviously, if the pi is off, the broker cannot send the message.

The broker continues to retain the message no matter if subsequent messages do not have the retain flag set. So just turning this off in HA will not affect the outcome.

To clear the retain flag in the broker you need to send a message on that topic with the retain flag set and a null payload. I’m not sure if this is really what you need to do, as I’m not sure on the functionality of the switch.

Thanks for the reply. I also tried to set retain: false, but continues to restart POWER ON.
the system is quite simple, I have a boolean input, which causes a script to start and turn the relay on for a few seconds and then turn it off.
could you kindly give me an example of how to disable it?

Using mosquitto_pub it is something like

mosquitto_pub -h 192.168.1.119 -u username -P password -t cmnd/tapparellacucina/POWER1 -n -r

That is from memory, so the parameters may need tweaking. The important thing is the -n which sends a zero length message and -r which sends the retain flag.

You can also send the same from the HA developer tools mqtt section. You have to specify the data as json, and it is something like

{"retain": True, "message": None}

I have put the correct syntax in other posts, so if you want to go down that route you can search through these forums.

sorry i’ve not found your post on forum, can you link me?

Capture

i’ve used mosquitto_pub and works, many thanks :slight_smile:

1 Like