Can'no use the home-assistant for the sonoff

home-assistant version:0.43.0
Sonoff-Tasmota version:5.0.0

home-assistant configuration.yaml:

mqtt:
  broker: domus1
  port: 1883
  client_id: home-assistant-1
  keepalive: 60
  username: pi_mqtt
  password: chenfengfeng
  protocol: 3.1
  birth_message:
    topic: "tele/hass1/LWT"
    payload: "Online"
    qos: 1
    retain: true
  will_message:
    topic: "tele/hass1/LWT"
    payload: "Offline"
    qos: 1
    retain: true

switch:
  - platform: mqtt
    name: "sonoff-1"
    state_topic: "stat/sonoff/POWER"
    command_topic: "cmnd/sonoff/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

Sonoff-Tasmota user_config.h:

#define PROJECT                "sonoff"
#ifdef USE_MQTT_TLS
  #define MQTT_HOST            "m20.cloudmqtt.com" 
  #define MQTT_FINGERPRINT     "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07"  
  #define MQTT_PORT            20123              
  #define MQTT_USER            "cloudmqttuser"    
  #define MQTT_PASS            "cloudmqttpassword"
#else
  #define MQTT_HOST            "domus1"        
  #define MQTT_PORT            1883            
  #define MQTT_USER            "pi_mqtt"       
  #define MQTT_PASS            "chenfengfeng"    
#endif

#define MQTT_CLIENT_ID         "DVES_%06X"       

#define SUB_PREFIX             "cmnd"            
#define PUB_PREFIX             "stat"            
#define PUB_PREFIX2            "tele"            
                                                 
#define MQTT_TOPIC             PROJECT           
#define MQTT_GRPTOPIC          "sonoffs"         
#define MQTT_BUTTON_RETAIN     0                 
#define MQTT_POWER_RETAIN      1                 
#define MQTT_SWITCH_RETAIN     0                 

#define MQTT_STATUS_OFF        "OFF"             
#define MQTT_STATUS_ON         "ON"              
#define MQTT_CMND_TOGGLE       "TOGGLE"          

// -- MQTT - Telemetry ----------------------------
#define TELE_PERIOD            300               

// -- MQTT - Domoticz -----------------------------
#define USE_DOMOTICZ                             
  #define DOMOTICZ_IN_TOPIC      "domoticz/in"   
  #define DOMOTICZ_OUT_TOPIC     "domoticz/out"  
  #define DOMOTICZ_UPDATE_TIMER  0  

Not sure about this but it seems as if the MQTT settings differs between your configuration.yaml and user_config.h?

The HASS uses an MQTT server called domus1 on port 1883 and the sonoff uses m20.cloudmqtt.com on port 20123, i.e. two totally different MQTT servers. Right?

Perhaps this is of some use??

Have a look at my config:

- platform: mqtt
  name: "kitchen_tv"
  state_topic: "stat/kitchen_tv/POWER"
  command_topic: "cmnd/kitchen_tv/power"
  payload_on: "ON"
  payload_off: "OFF"

i think the mqtt run in “domus1”

can you gei me the mqtt config?

thank you,let me see

mqtt:
  broker:    !secret mqtt_address
  port:      !secret mqtt_port
  client_id: !secret mqtt_clientid
  username:  !secret mqtt_user
  password:  !secret mqtt_password

:joy:thanks
but i can’no use you config

Have you checked to make sure that MQTT is working properly, separate from the Sonoff?

For my install, from shell, I can subscribe with

mosquitto_sub -d -u username -P password -t dev/test

then open another shell session and publish

mosquitto_pub -d -u username -P password -t dev/test -m "Hello world"

thanks! I know the question,the MQTT ip error,has been modified.