code: def check_for_flexible_downtime(self, timeperiods, hosts, services):
          
          status_updated = False
          for downtime_id in self.downtimes:
              downtime = self.downtimes[downtime_id]
              # Activate flexible downtimes (do not activate triggered downtimes)
              # Note: only activate if we are between downtime start and end time!
              if downtime.fixed or downtime.is_in_effect:
                  continue
              if downtime.start_time <= self.last_chk and downtime.end_time >= self.last_chk \
                      and self.state_id != 0 and downtime.trigger_id in ['', '0']:
                  # returns downtimestart notifications
                  self.broks.extend(downtime.enter(timeperiods, hosts, services))
                  status_updated = True
          if status_updated is True:
              self.broks.append(self.get_update_status_brok())
docs: Enter in a downtime if necessary and raise start notification
          When a non Ok state occurs we try to raise a flexible downtime.
  
          :param timeperiods: Timeperiods objects, used for downtime period
          :type timeperiods: alignak.objects.timeperiod.Timeperiods
          :param hosts: hosts objects, used to enter downtime
          :type hosts: alignak.objects.host.Hosts
          :param services: services objects, used to enter downtime
          :type services: alignak.objects.service.Services
          :return: None