Sonoff S26 button and UDP command not working well

Hello,

I have made an program to control an Sonoff S26 with the button on the unit en to send commands to the unit over UDP.

It is working for 95%

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "****";
const char* password = "****";

WiFiUDP Udp;
unsigned int localUdpPort = 7;  // local port to listen on
char incomingPacket[255];  // buffer for incoming packets
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];    //Buffer for received data

// GPIO0 Push Button HIGH = off, LOW = on
// GPIO12  Relay and Red LED
// GPIO13  Blue Status LED

int relayState=0;
int gpio_0_switch = 0;
int gpio_13_led = 13;
int gpio_12_relay = 12;
int buttonNew;
int buttonOld=1;
int dt=100;

void setup()
{
  pinMode(gpio_13_led, OUTPUT);
  digitalWrite(gpio_13_led, LOW);
  
  pinMode(gpio_12_relay, OUTPUT);
  digitalWrite(gpio_12_relay, LOW);
  
  Serial.begin(115200);
  Serial.println();

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    digitalWrite(gpio_13_led, LOW);
    delay(500);
    Serial.print(".");
    digitalWrite(gpio_13_led, HIGH);
    delay(500);
  }
  Serial.println(" connected");

  Udp.begin(localUdpPort);

  Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPort);
}

void loop(){
int packetSize = Udp.parsePacket();
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);    //if data received read it
buttonNew=digitalRead(gpio_0_switch);

  if(strcmp(packetBuffer, "UDP-ON") == 0){
     digitalWrite(gpio_12_relay, HIGH);
     digitalWrite(gpio_13_led, HIGH);
     relayState=1;
  }
  if(strcmp(packetBuffer, "UDP-OFF") == 0){
     digitalWrite(gpio_12_relay, LOW);
     digitalWrite(gpio_13_led, LOW);
     relayState=0;
  }
  if(buttonOld==0 && buttonNew==1) {
    if (relayState==0) {
      digitalWrite(gpio_12_relay, HIGH);
      digitalWrite(gpio_13_led, HIGH);
      relayState=1;
    }
    else{
      digitalWrite(gpio_12_relay, LOW);
      digitalWrite(gpio_13_led, LOW);
      relayState=0;
    }
  }
  buttonOld=buttonNew;
}

when I powered on I can control the unit with the button that is working,
to send the commands over UDP two times.
What also works is when I push the button to on then I can send the command off that is working

I hope some one can help me with this

thanks in advance!