To get the state of the relay on power on to the dashboard, look at my example below that runs in setup. It sets the dashboard states to the same as the arduino so no matter what the last state was on the dashboard, on reset both match. randomProgram is a button, program and wait are sliders on the dashboard.
If your trying to get the dashboard state on reset, I don’t believe thats possible right now. I don’t believe the Cayenne.syncAll() does anything with MQTT connection, I think thats just for the older Cayenne connection. Someone correct me if I’m wrong
byte randomProgram = 0;
byte program = 4;
int wait = 200;
void setup()
{
system_update_cpu_freq(160);
system_phy_set_max_tpw(82);
wifi_set_opmode(0x01);
// Serial.begin(9600);
Wire.begin(sdaPin,sclPin);
Wire.setClockStretchLimit(40000);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
//below sets the dashboard states, needs to be after Cayenne.begin()
Cayenne.virtualWrite(2, randomProgram, "digital_actuator", "d");
Cayenne.virtualWrite(1, program, "analog_actuator", "null");
Cayenne.virtualWrite(3, wait, "analog_actuator", "null");
Cayenne.virtualWrite(20, 0, "digital_sensor", "d");
}