How can i end the {cayenne.loop()} if there is no connection?

I’m new to Cayenne and really like the stability of the connection from it. For disconnection detection & reset i use a script from another user i found here (also how i discovered Cayenne), stanislas.guiot.sams

The script makes use of a sensor, actuator and triggers to write and read values from the device to the Cayenne server. if connection is ok, the values are equal. If values (adjustable timers) aren’t equal, it means that the Arduino couldn’t read the value from the Cayenne server, then the script resets my Arduino.