<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _set_rain_delay(self, zoneid, value):
 """Generic method to set auto_watering program."""

        # current index for rain_delay starts in 0
        zoneid -= 1

        if isinstance(value, int):
            if value > MAX_RAIN_DELAY_DAYS or value < 0:
                return None
            elif value == 0:
                value = 'off'
            elif value == 1:
                value = '1day'
            elif value >= 2:
                value = str(value) + 'days'
        elif isinstance(value, str):
            if value.lower() != 'off':
                return None

        ddata = self.preupdate()
        attr = 'zone{}_rain_delay_select'.format(zoneid)
        ddata[attr] = value
        self.submit_action(ddata)
        return True