Gas fireplace doesn’t turn on when cold
With a millivolt control valve your problem may be in the timer that shuts it down at night. You said it was a thermostat but not all thermostats are millivolt compatible. If it worked correctly and just recently started having problems I would suggest replacing the thermostat as it sounds like the contacts are becoming pitted or carbon fouled and that is probably why it is intermittent.