Rereading your post caught my eye at the above quote. Both Z-Wave and wifi thermostats aren't getting updated? Now that would appear to be more of a program execution issue. The fact that it started after an upgrade to 5.9.1 is also suspect. I'd add test code, such as incrementing a variable in the same program, just to see that it's going through the statements. One before and one after. Something like this:
Then increment variable 1
Then set Z-wave termistat
Then set wifi thermostat
Then increment variable 2
And check it every day to keep track of the variable values (or write them down along with the date).