Suppress some notifications for state transistions from unknown

I would like to suppress notifications when a service state is coming back from unknown to its previous “known” state.
For example, a state was Warning, then transits to unknown and finally back to Warning.
If repeated notifications for single events is turned off, this still triggers three notifications:

  • state OK → Warning
  • state Warning - Unknown
  • state Unknown - Warning

I want to suppress the last two. To accomplish this, my idea is to save the last state of the service if it is not unknown and use this when a state is coming back from unknown.

Is there a way to save a state for each service which is not lost once the service check is over (like static in c) or any other way to get rid of the additional emails?