TTS not consistent

I'm using a sonoff contact sensor on my patio door and TTS to notify me when it is open and closed.
The problem is sometimes I get no "the door is open" message but I do get a "the door is closed" message when the patio door is shut. There other times when "the door is open" sounds when the door is actually closed and just the opposite when the door is open. How do I fix this to where the correct message happens when the door open and when it is closed.

Debugging this needs more information:

  1. How are you doing the notification? Using the Notifications app or something else? Can you post a screenshot of the setup for this automation.
  2. What TTS device are you using?
  3. Are all state changes correctly recorded in the event log of the sensor?