ESP + Wemos D1 get freezes when wifi connection lost

yes, you are right.

can you try the same test by uploading the basic esp8266 code from the cayenne library?

have a look at this workaround How can i end the {cayenne.loop()} if there is no connection? - #5 by ahmed.blacky.xaver3

i mean when wifi is disconnected or no internet, the code goes in an infinite loop to search for connection and stops all the other code. So your entire code is never executed when there is no connection.