Relay with MQTT activate every time that my esp8266 reload or start

Hello Guys, i need help here.
I have an relay in my NodeMCU works fine with Home Assistant, the problem is that if i reload the board or need restart the board i every time i receive in my topic the value to activate the relay.
I am use these topics bellow:
“porta/trava/status” - to read the relay status
“porta/trava/switch” - to activate the relay

for some reason when the board start, in the callback function i receive the value 1 the topic “porta/trava/switch” and it activate the relay.

Follow my config from the NodeMCU and Home Assistant

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <SoftwareSerial.h>
#include <RDM6300.h>

#define wifi_ssid “XXXXXXxx”
#define wifi_password “XXXXXXXx”
#define mqtt_server “192.168.1.50”
#define mqtt_user “xxxxxxxxxx”
#define mqtt_password “xxxxxxxxxx”
#define outTopic “porta/trava/status”
#define inTopic “porta/trava/switch”

WiFiClient espClient;
PubSubClient client(espClient);
//long lastMsg = 0;
//char msg[50];
//int value = 0;

int relay_pin = D1;

void setup_wifi() {

delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(wifi_ssid);

WiFi.begin(wifi_ssid, wifi_password);

while (WiFi.status() != WL_CONNECTED) {

delay(500);
Serial.print(".");

}
Serial.println("");
Serial.println(“WiFi connected”);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
Serial.print(“Message arrived [”);
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
// Switch on the relay if an 1 was received as first character
if ((char)payload[0] == ‘1’) {
digitalWrite(relay_pin, HIGH);
client.publish(“porta/trava/status”, “1”, true);
delay(3000);
digitalWrite(relay_pin, LOW);
client.publish(“porta/trava/status”, “0”, true);
}
else {
digitalWrite(relay_pin, LOW);
client.publish(“porta/trava/status”, “0”, true);
}

}

void reconnect() {
// Loop until we’re reconnected
while (!client.connected()) {
Serial.print(“Attempting MQTT connection…”);
// Attempt to connect
if (client.connect(“Porta”, mqtt_user, mqtt_password)) {
Serial.println(“connected”);
// Once connected, publish an announcement…
client.publish(outTopic, “0”);
// … and resubscribe
client.subscribe(inTopic);

} else {
  Serial.print("failed, rc=");
  Serial.print(client.state());
  Serial.println(" try again in 5 seconds");
  // Wait 5 seconds before retrying
  delay(5000);
}

}
}

void setup() {
pinMode(relay_pin, OUTPUT); //relay output
digitalWrite(relay_pin, LOW); //relay disable

Serial.begin(115200);
setup_wifi(); // Connect to wifi
client.setServer(mqtt_server, 1883);
client.setCallback(callback);

}

void loop() {

if (!client.connected()) {
reconnect();
}
client.loop();

}

Home Assistant
mqtt:
switch:
name: “Trava”
state_topic: “porta/trava/status”
command_topic: “porta/trava/switch”
qos: 0
payload_on: “0”
payload_off: “1”
retain: true