Open/Close Widget (gate remote control)

Hello everyone. I need help with my project “gate remote control”. It is only simply project to open and close our entrance gate using the Sonoff Dual with Android App Cayenne and the Cayenne dashboard on PC.
I wrote the code (see below), everything works, but there is a problem with the open/close widget. It works properly on the PC (see picture), but it does not work on the phone. (see second picture)
I do not know what I am doing wrong…

Code:

#include <CayenneMQTTESP8266.h>

#define CAYENNE_PRINT Serial // zakomentuj pokud chces usetrit misto
#define BUTTON_1 9 // koncak vrat
#define ACTUATOR_PIN 12 // auto
#define LED_PIN 13 // LED signalizace zapnuto
#define ACTUATOR2_PIN 5 // chodec
#define SWITCH 10 // tlacitko sonoff

char ssid = “hhhh”;
char wifiPassword = “hhhh”;

char username = “hhhh”;
char password = “hhhh”;
char clientID = “hhhh”;

void setup(){
Serial.begin(9600);
pinMode(ACTUATOR_PIN, OUTPUT);
pinMode(ACTUATOR2_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_1, INPUT);
pinMode(SWITCH, INPUT);
digitalWrite(ACTUATOR_PIN, LOW);
digitalWrite(ACTUATOR2_PIN, LOW);
digitalWrite(LED_PIN, LOW);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void Stav_Vrat(){
if (digitalRead(BUTTON_1) == LOW) {
Cayenne.virtualWrite(V1, 0, “digital_sensor”, “d”);
Serial.println(“Vrata: zavreno…”);
}
else {
Cayenne.virtualWrite(V1, 1, “digital_sensor”, “d”);
Serial.println(“Vrata: otevreno…”);
}
}

void Sepnuti_tlacitka(){
if (digitalRead(SWITCH) == LOW) {
digitalWrite(ACTUATOR_PIN, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN, LOW);
}
}

void loop(){

Cayenne.loop(); //spusteni Cayenne
Stav_Vrat();
Sepnuti_tlacitka();
}

// This function is called when data is sent from Cayenne.
CAYENNE_IN(V2)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 1) {
digitalWrite(ACTUATOR_PIN, HIGH);
//digitalWrite(LED_PIN, LOW);

/*delay(2000);

digitalWrite(ACTUATOR_PIN, LOW);
digitalWrite(LED_PIN, LOW); */

}
else {
digitalWrite(ACTUATOR_PIN, LOW);
//digitalWrite(LED_PIN, HIGH);
}
}

CAYENNE_IN(V3)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 1) {
digitalWrite(ACTUATOR2_PIN, HIGH);
//digitalWrite(LED_PIN, LOW);

/*delay(2000);

digitalWrite(ACTUATOR_PIN, LOW);
digitalWrite(LED_PIN, LOW); */

}
else {
digitalWrite(ACTUATOR2_PIN, LOW);
//digitalWrite(LED_PIN, HIGH);
}
}
CAYENNE_OUT(V4){

Cayenne.virtualWrite(V4, WiFi.RSSI()); //display signal WiFi connection
}

Picture 1:
PC dashboard

Picture 2:

Thanks for answer

this function is called continuously and thus you are publishing data at a very rapid rate. Sending MQTT messages within rate limits
Also, change the channel number. once you make the changes, remove the widget from the dashboard and let it re-add.

So it didn’t help, I still have a problem with the widget in the android app. There is a different widget than on the pc and after adding it I get two widgets on the pc. (Pictures and code below) I’m sorry, but I’m a beginner.
Thanks for the answers.

#include <CayenneMQTTESP8266.h>

#define CAYENNE_PRINT Serial  // zakomentuj pokud chces usetrit misto
#define BUTTON_1 9 // koncak vrat
#define ACTUATOR_PIN 12 // auto
#define LED_PIN 13 // LED signalizace zapnuto
#define ACTUATOR2_PIN 5 // chodec
#define SWITCH 10 // tlacitko sonoff

char ssid[] = "1234";
char wifiPassword[] = "1234";

char username[] = "1234";
char password[] = "1234";
char clientID[] = "1234";

void setup(){
    Serial.begin(9600);
    pinMode(ACTUATOR_PIN, OUTPUT);
    pinMode(ACTUATOR2_PIN, OUTPUT);
    pinMode(LED_PIN, OUTPUT);
    pinMode(BUTTON_1, INPUT);
    pinMode(SWITCH, INPUT);
    digitalWrite(ACTUATOR_PIN, LOW);
    digitalWrite(ACTUATOR2_PIN, LOW);
    digitalWrite(LED_PIN, LOW);
    Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void Sepnuti_tlacitka(){
 if (digitalRead(SWITCH) == LOW) {
     digitalWrite(ACTUATOR_PIN, HIGH);
       }
  else {
    delay(1000);
     digitalWrite(ACTUATOR_PIN, LOW);
     }
}

void loop(){
  
  Cayenne.loop(); //spusteni Cayenne
  Sepnuti_tlacitka();
    }

// This function is called when data is sent from Cayenne.
CAYENNE_IN(2)
{
  // Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
  if (getValue.asInt() == 1) {
    digitalWrite(ACTUATOR_PIN, HIGH);
    }
  else {
    digitalWrite(ACTUATOR_PIN, LOW);
    }
}

CAYENNE_IN(3)
{
  // Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
  if (getValue.asInt() == 1) {
    digitalWrite(ACTUATOR2_PIN, HIGH);
    }
  else {
    digitalWrite(ACTUATOR2_PIN, LOW);
    }
}
CAYENNE_OUT_DEFAULT(){
  
Cayenne.virtualWrite(4, WiFi.RSSI());       //display signal WiFi connection 
}

CAYENNE_OUT(5){
  
 if (digitalRead(BUTTON_1) == LOW) {
     Cayenne.virtualWrite(5, 0, "digital_sensor", "d");
     Serial.println("Vrata: zavreno...");
  }
  else {
     Cayenne.virtualWrite(5, 1, "digital_sensor", "d");
     Serial.println("Vrata: otevreno..."); 
     }
}

PC dashboard:
PC dashboard

Android app:

PC dashboard after adding the offered widget in the Android app:
PC dashboard 2

Android app after adding the offered widget:

the open/close widget type is not supported on the app. you will need to use the generic digital sensor widget type.

And is there a chance of supporting this widget in the future?
Otherwise, is my code about publishing data correct?
Thanks

it is not about the code, but we do not support the feature of changing the state from device.

I thought the correctness of my code about publishing data at a very rapid rate.

what do you mean by this?

i mean this…

that the different issue with your code.